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 29, 2018
2 parents 5d65ee4 + 5fbefd6 commit b131b58
Show file tree
Hide file tree
Showing 30 changed files with 145 additions and 96 deletions.
4 changes: 2 additions & 2 deletions src/skmultiflow/bayes/naive_bayes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ class NaiveBayes(StreamModel):
A mask for scikit-learn's Naive Bayes classifier.
Because scikit-multiflow's framework require a few interfaces, not present
int scikit-learn, this mask allows the first to use classifiers native to
Because scikit-multiflow's framework requires a few interfaces, not present
in scikit-learn, this mask allows the first to use classifiers native to
the latter.
"""
Expand Down
4 changes: 2 additions & 2 deletions src/skmultiflow/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def predict(self, X):
Parameters
----------
X : Numpy.ndarray of shape (n_samples, n_features)
The matrix of samples one wants to predict.
The matrix of samples one wants to predict the labels for.
Returns
-------
Expand All @@ -94,7 +94,7 @@ def predict_proba(self, X):
Parameters
----------
X : Numpy.ndarray of shape (n_samples, n_features)
The matrix of samples one wants to predict.
The matrix of samples one wants to predict the class probabilities for.
Returns
-------
Expand Down
6 changes: 3 additions & 3 deletions src/skmultiflow/core/base_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ class BaseObject(metaclass=ABCMeta):
""" BaseObject
The most basic object, from which classes in scikit-multiflow
derive from. It guarantees that all classes have at least the
two basic functions described in this base class.
derive. It guarantees that all classes have at least the two
basic functions described in this base class.
"""

Expand All @@ -28,7 +28,7 @@ def get_class_type(self):
def get_info(self):
""" get_info
A sum up of all important characteristics of a class.
A sum-up of all important characteristics of a class.
The default format of the return string is as follows:
ClassName: attribute_one: value_one - attribute_two: value_two \
Expand Down
3 changes: 1 addition & 2 deletions src/skmultiflow/core/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Pipeline(BaseObject):
The last step should be an estimator (learner), so it should implement
partial_fit, and predict at least.
Since it has an estimator as the last step, the Pipeline will act like as
Since it has an estimator as the last step, the Pipeline will act like
an estimator itself, in a way that it can be directly passed to evaluation
objects, as if it was a learner.
Expand Down Expand Up @@ -250,7 +250,6 @@ def _validate_steps(self):
"""

names, estimators = zip(*self.steps)
transforms = classifier = None
classifier = estimators[-1]
transforms = estimators[:-1]

Expand Down
2 changes: 1 addition & 1 deletion src/skmultiflow/lazy/sam_knn.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def predict(self, X):
for i in range(r):
distancesSTM = SAMKNN.get_distances(X[i], self._STMSamples)
predictedLabel.append(self.predictFct(X[i], None, distancesSTM))
return predictedLabel
return np.asarray(predictedLabel)

def predict_proba(self, X):
raise NotImplementedError
Expand Down
5 changes: 3 additions & 2 deletions src/skmultiflow/meta/adaptive_random_forests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from copy import deepcopy
import numpy as np
from sklearn.preprocessing import normalize

from skmultiflow.core.base_object import BaseObject
Expand Down Expand Up @@ -230,7 +231,7 @@ def predict(self, X):
Samples for which we want to predict the labels.
Returns
-------
list
numpy.ndarray
Predicted labels for all instances in X.
"""
r, _ = get_dimensions(X)
Expand All @@ -242,7 +243,7 @@ def predict(self, X):
predictions.append(0)
else:
predictions.append(max(votes, key=votes.get))
return predictions
return np.asarray(predictions)

def predict_proba(self, X):
""" Predicts the class probabilities for the X instance(s).
Expand Down
8 changes: 4 additions & 4 deletions src/skmultiflow/meta/leverage_bagging.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ def predict(self, X):
Returns
-------
list
A list with the label prediction for all the samples in X.
numpy.ndarray
A numpy.ndarray with the label prediction for all the samples in X.
"""
r, c = get_dimensions(X)
Expand All @@ -328,7 +328,7 @@ def predict(self, X):
proba = np.zeros((r, 1))
for i in range(r):
predictions.append(np.argmax(proba[i]))
return predictions
return np.asarray(predictions)

def predict_proba(self, X):
""" predict_proba
Expand Down Expand Up @@ -392,7 +392,7 @@ def predict_proba(self, X):
aux.append([x / sum_proba[i] for x in proba[i]])
else:
aux.append(proba[i])
return aux
return np.asarray(aux)

def predict_binary_proba(self, X):
""" predict_binary_proba
Expand Down
8 changes: 4 additions & 4 deletions src/skmultiflow/meta/oza_bagging.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ def predict(self, X):
Returns
-------
list
A list with the label prediction for all the samples in X.
numpy.ndarray
A numpy.ndarray with the label prediction for all the samples in X.
"""
r, c = get_dimensions(X)
Expand All @@ -207,7 +207,7 @@ def predict(self, X):
return None
for i in range(r):
predictions.append(np.argmax(proba[i]))
return predictions
return np.asarray(predictions)

def predict_proba(self, X):
""" predict_proba
Expand Down Expand Up @@ -267,7 +267,7 @@ def predict_proba(self, X):
aux.append([x / sum_proba[i] for x in proba[i]])
else:
aux.append(proba[i])
return aux
return np.asarray(aux)

def score(self, X, y):
raise NotImplementedError
Expand Down
7 changes: 4 additions & 3 deletions src/skmultiflow/neural_networks/perceptron.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import numpy as np
from skmultiflow.core.base import StreamModel
from sklearn.linear_model.perceptron import Perceptron

Expand Down Expand Up @@ -107,11 +108,11 @@ def predict(self, X):
Returns
-------
list
A list containing the predicted labels for all instances in X.
numpy.ndarray
A numpy.ndarray containing the predicted labels for all instances in X.
"""
return self.classifier.predict(X)
return np.asarray(self.classifier.predict(X))

def predict_proba(self, X):
""" predict_proba
Expand Down
Loading

0 comments on commit b131b58

Please sign in to comment.