-
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.
pipeline components added, readme, docs
- Loading branch information
1 parent
f00230a
commit 85bd0c0
Showing
9 changed files
with
289 additions
and
11 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
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())) |
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.discriminant_analysis import QuadraticDiscriminantAnalysis as QDA | ||
import numpy as np | ||
|
||
__all__ = ['QuadraticDiscriminantAnalysis'] | ||
|
||
class QuadraticDiscriminantAnalysis(Classifier): | ||
r"""Implementation of quadratic discriminant analysis classifier. | ||
Date: | ||
2020 | ||
Author: | ||
Luka Pečnik | ||
License: | ||
MIT | ||
See Also: | ||
* :class:`niaaml.classifiers.Classifier` | ||
""" | ||
Name = 'Quadratic Discriminant Analysis' | ||
|
||
def __init__(self, **kwargs): | ||
r"""Initialize QuadraticDiscriminantAnalysis instance. | ||
""" | ||
self.__qda = QDA() | ||
super(QuadraticDiscriminantAnalysis, self).__init__() | ||
|
||
def set_parameters(self, **kwargs): | ||
r"""Set the parameters/arguments of the algorithm. | ||
""" | ||
self.__qda.set_params(**kwargs) | ||
|
||
def fit(self, x, y, **kwargs): | ||
r"""Fit QuadraticDiscriminantAnalysis. | ||
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.__qda.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.__qda.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.__qda.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
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