Skip to content

Commit

Permalink
Merge branch 'master' of github.com:scikit-multiflow/scikit-multiflow
Browse files Browse the repository at this point in the history
  • Loading branch information
smastelini committed Oct 26, 2018
2 parents 60e616c + 6103e03 commit 5d65ee4
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 19 deletions.
4 changes: 4 additions & 0 deletions src/skmultiflow/bayes/naive_bayes.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ def predict(self, X):
A list containing the predicted labels for all instances in X.
"""
if not hasattr(self.classifier, "classes_"):
return [0]
return self.classifier.predict(X)

def predict_proba(self, X):
Expand All @@ -109,6 +111,8 @@ def predict_proba(self, X):
the probability that the i-th sample of X belongs to a certain label.
"""
if not hasattr(self.classifier, "classes_"):
return [0.0]
return self.classifier.predict_proba(X)

def score(self, X, y):
Expand Down
15 changes: 8 additions & 7 deletions src/skmultiflow/data/data_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,23 +359,24 @@ def next_sample(self, batch_size=1):
return self.current_sample_x, self.current_sample_y

def has_more_samples(self):
""" Returns the estimated number of remaining samples.
""" Checks if stream has more samples.
Returns
-------
int
Remaining number of samples.
Boolean
True if stream has more samples.
"""
return (self.n_samples - self.sample_idx) > 0

def n_remaining_samples(self):
"""
Checks if stream has more samples.
""" Returns the estimated number of remaining samples.
Returns
-------
Boolean
True if stream has more samples.
int
Remaining number of samples.
"""
return self.n_samples - self.sample_idx

Expand Down
15 changes: 8 additions & 7 deletions src/skmultiflow/data/file_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,23 +264,24 @@ def next_sample(self, batch_size=1):
return self.current_sample_x, self.current_sample_y

def has_more_samples(self):
""" Returns the estimated number of remaining samples.
""" Checks if stream has more samples.
Returns
-------
int
Remaining number of samples.
Boolean
True if stream has more samples.
"""
return (self.n_samples - self.sample_idx) > 0

def n_remaining_samples(self):
"""
Checks if stream has more samples.
""" Returns the estimated number of remaining samples.
Returns
-------
Boolean
True if stream has more samples.
int
Remaining number of samples.
"""
return self.n_samples - self.sample_idx

Expand Down
8 changes: 4 additions & 4 deletions src/skmultiflow/data/stagger_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ def next_sample(self, batch_size=1):
group = 0
desired_class_found = False
while not desired_class_found:
size = self.random_state.randint(2)
color = self.random_state.randint(2)
shape = self.random_state.randint(2)
size = self.random_state.randint(3)
color = self.random_state.randint(3)
shape = self.random_state.randint(3)

group = self._classification_functions[self.classification_function_idx](size, color, shape)

Expand Down Expand Up @@ -313,6 +313,6 @@ def classification_function_two(size, color, shape):
return 1 if (size == 1 or size == 2) else 0

def get_info(self):
return 'SineGenerator: classification_function: ' + str(self.classification_function_idx) + \
return 'STAGGERGenerator: classification_function: ' + str(self.classification_function_idx) + \
' - random_state: ' + str(self._original_random_state) + \
' - balance_classes: ' + str(self.balance_classes)
Binary file modified tests/data/stagger_stream.npz
Binary file not shown.
1 change: 0 additions & 1 deletion tests/data/test_stagger_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def test_stagger_generator(test_path):

assert stream.is_restartable() is True


# Load test data corresponding to first 10 instances
test_file = os.path.join(test_path, 'stagger_stream.npz')
data = np.load(test_file)
Expand Down

0 comments on commit 5d65ee4

Please sign in to comment.