Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random Splitter #196

Merged
merged 16 commits into from
Jun 27, 2018
Merged

Random Splitter #196

merged 16 commits into from
Jun 27, 2018

Conversation

mottodora
Copy link
Member

@mottodora mottodora commented Jun 22, 2018

  • RandomSplitter
  • tests
  • documents

@codecov-io
Copy link

codecov-io commented Jun 22, 2018

Codecov Report

Merging #196 into master will increase coverage by 1.92%.
The diff coverage is 89.53%.

@@            Coverage Diff             @@
##           master     #196      +/-   ##
==========================================
+ Coverage   77.08%   79.01%   +1.92%     
==========================================
  Files          89       95       +6     
  Lines        3875     4193     +318     
==========================================
+ Hits         2987     3313     +326     
+ Misses        888      880       -8

1.)
if seed is not None:
numpy.random.seed(seed)
perm = numpy.random.permutation(len(dataset))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting numpy random seed may have side effect to other places.
How about using numpy.random.RandomState(seed).permutation(len(dataset))?

@corochann
Copy link
Member

So far looks good to me for the design, I think it is ok to separate PR, and merge it in current status
(only BaseSplitter & RandomSplitter for this PR).

@corochann
Copy link
Member

I also want to consider the case when we want to split only train and val, without test dataset.
How can we handle this case?

@mottodora mottodora changed the title [WIP] Splitter Random Splitter Jun 23, 2018
@mottodora mottodora changed the title Random Splitter [WIP] Random Splitter Jun 23, 2018
if return_index:
return train_inds, valid_inds, test_inds
else:
return dataset[train_inds], dataset[valid_inds], dataset[test_inds]
if type(dataset) == NumpyTupleDataset:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use isinstance(dataset, NumpyTupleDataset).

I think the different way is to introduce converter function as an argument, so that user can explicitly specify how to split based on dataset with given indices.

Default behavior would be...

def converter(dataset, indices):
    return dataset[indices]

and for NumpyTupleDataset, user can explicitly specify...

def converter_numpy_tuple_dataset(dataset, indices):
    return NumpyTupleDataset(*dataset.features[indices])

if type(dataset) == NumpyTupleDataset:
train = NumpyTupleDataset(*dataset[train_inds])
valid = NumpyTupleDataset(*dataset[valid_inds])
test = NumpyTupleDataset(*dataset[test_inds])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use features, NumpyTupleDataset(*dataset.features[indices]) ?

@mottodora
Copy link
Member Author

please merge after #200

@mottodora mottodora changed the title [WIP] Random Splitter Random Splitter Jun 26, 2018
@corochann
Copy link
Member

Copy link
Member

@corochann corochann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@corochann corochann merged commit 9bcc316 into chainer:master Jun 27, 2018
@mottodora mottodora deleted the splitter branch June 27, 2018 07:23
@mottodora mottodora added this to the 0.4.0 milestone Jul 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants