Skip to content

Commit

Permalink
add default and random samplers
Browse files Browse the repository at this point in the history
  • Loading branch information
Maritza EBLING committed Dec 11, 2017
1 parent 7ddd7e0 commit 4558d14
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions enso/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
DATA = {
'Classify/AirlineComplaints',
'Classify/Disaster',
'Classify/Irony',
#'Classify/Irony',
# 'Classify/IMDB.small',
# 'Classify/Economy',
# 'Classify/Emotion',
Expand Down Expand Up @@ -53,7 +53,7 @@
TEST_SETUP = {
"train_sizes": [100, 250, 500, 1000],
"n_splits": 5,
"samplers": ['Random', 'RandomA']
"samplers": ['Default', 'Random']
}

# Visualizations to display
Expand Down
9 changes: 6 additions & 3 deletions enso/sample/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from numpy.random import choice


class Sampler(object):
"""Base class for all samples."""

Expand All @@ -16,11 +19,11 @@ def class_for(cls, sampler_string):
raise ValueError("Invalid sampler attempted ({})".format(sampler_string))


class Random(Sampler):
class Default(Sampler):
def sample(self):
return self.data_points[0:self.train_size]


class RandomA(Sampler):
class Random(Sampler):
def sample(self):
return self.data_points[(len(self.data_points)-self.train_size):]
return choice(self.data_points, self.train_size, replace=False)

0 comments on commit 4558d14

Please sign in to comment.