Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to write a CV splitter for ragged data?#31281

Unanswered
Jacob-Stevens-Haas asked this question inQ&A
Discussion options

I was writing a gridsearch experiment for interpolation/smoothing. I train on some regular interval of data points, and validate on some intermediate points, so here's my splitter:

classInterpSplitter(BaseCrossValidator):def__init__(self,thin_step:int=2):ifthin_step<2:raiseValueError("thin_step must be >= 2")self.thin_step=thin_stepdefsplit(self,t_obs:np.ndarray,x:None=None,groups:None=None):n_obs=len(t_obs)train_set=tuple(range(n_obs))[::self.thin_step]test_set=tuple(sorted(set(range(n_obs))-set(train_set)))yieldnp.array(train_set),np.array(test_set)defget_n_splits(self,X=None,y=None,groups=None):return1

If I have a list of trajectories of the same length, it should work to stack the data in shape (n_obs, n_trajectories). However, if the trajectories are different lengths, I can't stack them. The only solution I can think of is to pad with nans and stack, but that's a bad idea: it requires changes to the library'smodel.fit(),predict() in order to implement a convention that only matters in client code.

Would love any advice on how to write a splitter for ragged (list of list) data. Or more generally, how to write a splitter for custom containers.

You must be logged in to vote

Replies: 0 comments

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
1 participant
@Jacob-Stevens-Haas

[8]ページ先頭

©2009-2025 Movatter.jp