-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from lukapecnik/additional_features
Additional features
- Loading branch information
Showing
26 changed files
with
803 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,4 @@ | |
] | ||
|
||
__project__ = 'niaaml' | ||
__version__ = '1.0.0rc5' | ||
__version__ = '1.0.0rc6' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
from niaaml.classifiers.classifier import Classifier | ||
from niaaml.utilities import MinMax | ||
from niaaml.utilities import ParameterDefinition | ||
from sklearn.tree import DecisionTreeClassifier as DTC | ||
import numpy as np | ||
|
||
__all__ = ['DecisionTree'] | ||
|
||
class DecisionTree(Classifier): | ||
r"""Implementation of decision tree classifier. | ||
Date: | ||
2020 | ||
Author: | ||
Luka Pečnik | ||
License: | ||
MIT | ||
See Also: | ||
* :class:`niaaml.classifiers.Classifier` | ||
""" | ||
Name = 'Decision Tree Classifier' | ||
|
||
def __init__(self, **kwargs): | ||
r"""Initialize DecisionTree instance. | ||
""" | ||
self._params = dict( | ||
criterion = ParameterDefinition(['gini', 'entropy']), | ||
splitter = ParameterDefinition(['best', 'random']) | ||
) | ||
self.__decision_tree_classifier = DTC() | ||
|
||
def set_parameters(self, **kwargs): | ||
r"""Set the parameters/arguments of the algorithm. | ||
""" | ||
self.__decision_tree_classifier.set_params(**kwargs) | ||
|
||
def fit(self, x, y, **kwargs): | ||
r"""Fit DecisionTree. | ||
Arguments: | ||
x (pandas.core.frame.DataFrame): n samples to classify. | ||
y (pandas.core.series.Series): n classes of the samples in the x array. | ||
Returns: | ||
None | ||
""" | ||
self.__decision_tree_classifier.fit(x, y) | ||
|
||
def predict(self, x, **kwargs): | ||
r"""Predict class for each sample (row) in x. | ||
Arguments: | ||
x (pandas.core.frame.DataFrame): n samples to classify. | ||
Returns: | ||
pandas.core.series.Series: n predicted classes. | ||
""" | ||
return self.__decision_tree_classifier.predict(x) | ||
|
||
def to_string(self): | ||
r"""User friendly representation of the object. | ||
Returns: | ||
str: User friendly representation of the object. | ||
""" | ||
return Classifier.to_string(self).format(name=self.Name, args=self._parameters_to_string(self.__decision_tree_classifier.get_params())) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
from niaaml.classifiers.classifier import Classifier | ||
from niaaml.utilities import MinMax | ||
from niaaml.utilities import ParameterDefinition | ||
from sklearn.naive_bayes import GaussianNB as GNB | ||
import numpy as np | ||
|
||
__all__ = ['GaussianNB'] | ||
|
||
class GaussianNB(Classifier): | ||
r"""Implementation of gaussian Naive Bayes classifier. | ||
Date: | ||
2020 | ||
Author: | ||
Luka Pečnik | ||
License: | ||
MIT | ||
See Also: | ||
* :class:`niaaml.classifiers.Classifier` | ||
""" | ||
Name = 'Gaussian Naive Bayes' | ||
|
||
def __init__(self, **kwargs): | ||
r"""Initialize GaussianNB instance. | ||
""" | ||
self.__gaussian_nb = GNB() | ||
super(GaussianNB, self).__init__() | ||
|
||
def set_parameters(self, **kwargs): | ||
r"""Set the parameters/arguments of the algorithm. | ||
""" | ||
self.__gaussian_nb.set_params(**kwargs) | ||
|
||
def fit(self, x, y, **kwargs): | ||
r"""Fit GaussianNB. | ||
Arguments: | ||
x (pandas.core.frame.DataFrame): n samples to classify. | ||
y (pandas.core.series.Series): n classes of the samples in the x array. | ||
Returns: | ||
None | ||
""" | ||
self.__gaussian_nb.fit(x, y) | ||
|
||
def predict(self, x, **kwargs): | ||
r"""Predict class for each sample (row) in x. | ||
Arguments: | ||
x (pandas.core.frame.DataFrame): n samples to classify. | ||
Returns: | ||
pandas.core.series.Series: n predicted classes. | ||
""" | ||
return self.__gaussian_nb.predict(x) | ||
|
||
def to_string(self): | ||
r"""User friendly representation of the object. | ||
Returns: | ||
str: User friendly representation of the object. | ||
""" | ||
return Classifier.to_string(self).format(name=self.Name, args=self._parameters_to_string(self.__gaussian_nb.get_params())) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
from niaaml.classifiers.classifier import Classifier | ||
from niaaml.utilities import MinMax | ||
from niaaml.utilities import ParameterDefinition | ||
from sklearn.gaussian_process import GaussianProcessClassifier as GPC | ||
import numpy as np | ||
|
||
__all__ = ['GaussianProcess'] | ||
|
||
class GaussianProcess(Classifier): | ||
r"""Implementation of gaussian process classifier. | ||
Date: | ||
2020 | ||
Author: | ||
Luka Pečnik | ||
License: | ||
MIT | ||
See Also: | ||
* :class:`niaaml.classifiers.Classifier` | ||
""" | ||
Name = 'Gaussian Process Classifier' | ||
|
||
def __init__(self, **kwargs): | ||
r"""Initialize GaussianProcess instance. | ||
""" | ||
self._params = dict( | ||
max_iter_predict = ParameterDefinition(MinMax(50, 200), np.uint), | ||
warm_start = ParameterDefinition([True, False]), | ||
multi_class = ParameterDefinition(['one_vs_rest', 'one_vs_one']) | ||
) | ||
self.__gaussian_process = GPC() | ||
|
||
def set_parameters(self, **kwargs): | ||
r"""Set the parameters/arguments of the algorithm. | ||
""" | ||
self.__gaussian_process.set_params(**kwargs) | ||
|
||
def fit(self, x, y, **kwargs): | ||
r"""Fit GaussianProcess. | ||
Arguments: | ||
x (pandas.core.frame.DataFrame): n samples to classify. | ||
y (pandas.core.series.Series): n classes of the samples in the x array. | ||
Returns: | ||
None | ||
""" | ||
self.__gaussian_process.fit(x, y) | ||
|
||
def predict(self, x, **kwargs): | ||
r"""Predict class for each sample (row) in x. | ||
Arguments: | ||
x (pandas.core.frame.DataFrame): n samples to classify. | ||
Returns: | ||
pandas.core.series.Series: n predicted classes. | ||
""" | ||
return self.__gaussian_process.predict(x) | ||
|
||
def to_string(self): | ||
r"""User friendly representation of the object. | ||
Returns: | ||
str: User friendly representation of the object. | ||
""" | ||
return Classifier.to_string(self).format(name=self.Name, args=self._parameters_to_string(self.__gaussian_process.get_params())) |
Oops, something went wrong.