-
Notifications
You must be signed in to change notification settings - Fork 875
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 #50 from rasbt/refactor_base
v 0.4.1
- Loading branch information
Showing
106 changed files
with
3,283 additions
and
4,221 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
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file modified
BIN
-65 Bytes
(99%)
docs/sources/user_guide/classifier/Adaline_files/Adaline_20_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+120 Bytes
(100%)
docs/sources/user_guide/classifier/Adaline_files/Adaline_20_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+9 Bytes
(100%)
docs/sources/user_guide/classifier/Adaline_files/Adaline_22_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-53 Bytes
(99%)
docs/sources/user_guide/classifier/Adaline_files/Adaline_22_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+45 Bytes
(100%)
docs/sources/user_guide/classifier/Adaline_files/Adaline_24_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.38 KB
(120%)
docs/sources/user_guide/classifier/Adaline_files/Adaline_24_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
161 changes: 93 additions & 68 deletions
161
docs/sources/user_guide/classifier/LogisticRegression.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file modified
BIN
-415 Bytes
(95%)
...rces/user_guide/classifier/LogisticRegression_files/LogisticRegression_46_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+53 Bytes
(100%)
...rces/user_guide/classifier/LogisticRegression_files/LogisticRegression_46_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-68 Bytes
(99%)
...rces/user_guide/classifier/LogisticRegression_files/LogisticRegression_52_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-3 Bytes
(100%)
...rces/user_guide/classifier/LogisticRegression_files/LogisticRegression_52_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-274 Bytes
(97%)
...rces/user_guide/classifier/LogisticRegression_files/LogisticRegression_55_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+682 Bytes
(110%)
...rces/user_guide/classifier/LogisticRegression_files/LogisticRegression_55_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
856 changes: 856 additions & 0 deletions
856
docs/sources/user_guide/classifier/MultiLayerPerceptron.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file added
BIN
+12.8 KB
.../user_guide/classifier/MultiLayerPerceptron_files/MultiLayerPerceptron_26_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.68 KB
.../user_guide/classifier/MultiLayerPerceptron_files/MultiLayerPerceptron_27_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.7 KB
.../user_guide/classifier/MultiLayerPerceptron_files/MultiLayerPerceptron_31_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.37 KB
.../user_guide/classifier/MultiLayerPerceptron_files/MultiLayerPerceptron_34_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.46 KB
.../user_guide/classifier/MultiLayerPerceptron_files/MultiLayerPerceptron_39_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.94 KB
.../user_guide/classifier/MultiLayerPerceptron_files/MultiLayerPerceptron_45_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file modified
BIN
-631 Bytes
(93%)
docs/sources/user_guide/classifier/Perceptron_files/Perceptron_25_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+704 Bytes
(110%)
docs/sources/user_guide/classifier/Perceptron_files/Perceptron_25_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
136 changes: 83 additions & 53 deletions
136
docs/sources/user_guide/classifier/SoftmaxRegression.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file modified
BIN
+3.42 KB
(140%)
...ources/user_guide/classifier/SoftmaxRegression_files/SoftmaxRegression_34_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.87 KB
...ources/user_guide/classifier/SoftmaxRegression_files/SoftmaxRegression_34_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-256 Bytes
(98%)
...ources/user_guide/classifier/SoftmaxRegression_files/SoftmaxRegression_40_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-6.24 KB
(56%)
...ources/user_guide/classifier/SoftmaxRegression_files/SoftmaxRegression_40_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
222 changes: 91 additions & 131 deletions
222
docs/sources/user_guide/regressor/LinearRegression.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file modified
BIN
+27 Bytes
(100%)
docs/sources/user_guide/regressor/LinearRegression_files/LinearRegression_19_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-648 Bytes
(90%)
docs/sources/user_guide/regressor/LinearRegression_files/LinearRegression_20_0.png
Oops, something went wrong.
Binary file modified
BIN
+759 Bytes
(110%)
docs/sources/user_guide/regressor/LinearRegression_files/LinearRegression_22_1.png
Oops, something went wrong.
Binary file added
BIN
+7.16 KB
docs/sources/user_guide/regressor/LinearRegression_files/LinearRegression_23_0.png
Oops, something went wrong.
Binary file added
BIN
+6.26 KB
docs/sources/user_guide/regressor/LinearRegression_files/LinearRegression_25_1.png
Oops, something went wrong.
Binary file added
BIN
+7.58 KB
docs/sources/user_guide/regressor/LinearRegression_files/LinearRegression_26_0.png
Oops, something went wrong.
288 changes: 50 additions & 238 deletions
288
docs/sources/user_guide/tf_classifier/TfMultiLayerPerceptron.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file added
BIN
+7.55 KB
...uide/tf_classifier/TfMultiLayerPerceptron_files/TfMultiLayerPerceptron_15_0.png
Oops, something went wrong.
Binary file modified
BIN
-3.45 KB
(68%)
...uide/tf_classifier/TfMultiLayerPerceptron_files/TfMultiLayerPerceptron_17_0.png
Oops, something went wrong.
Binary file added
BIN
+7.33 KB
...uide/tf_classifier/TfMultiLayerPerceptron_files/TfMultiLayerPerceptron_25_0.png
Oops, something went wrong.
Binary file modified
BIN
+4.28 KB
(160%)
...uide/tf_classifier/TfMultiLayerPerceptron_files/TfMultiLayerPerceptron_25_1.png
Oops, something went wrong.
Binary file modified
BIN
+3.32 KB
(170%)
...uide/tf_classifier/TfMultiLayerPerceptron_files/TfMultiLayerPerceptron_29_0.png
Oops, something went wrong.
215 changes: 64 additions & 151 deletions
215
docs/sources/user_guide/tf_classifier/TfSoftmaxRegression.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file modified
BIN
-217 Bytes
(97%)
...user_guide/tf_classifier/TfSoftmaxRegression_files/TfSoftmaxRegression_22_1.png
Oops, something went wrong.
Binary file modified
BIN
-105 Bytes
(99%)
...user_guide/tf_classifier/TfSoftmaxRegression_files/TfSoftmaxRegression_22_2.png
Oops, something went wrong.
Binary file modified
BIN
-281 Bytes
(97%)
...user_guide/tf_classifier/TfSoftmaxRegression_files/TfSoftmaxRegression_25_1.png
Oops, something went wrong.
68 changes: 35 additions & 33 deletions
68
docs/sources/user_guide/tf_regressor/TfLinearRegression.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file modified
BIN
-636 Bytes
(93%)
...es/user_guide/tf_regressor/TfLinearRegression_files/TfLinearRegression_17_2.png
Oops, something went wrong.
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 |
---|---|---|
|
@@ -4,4 +4,4 @@ | |
# | ||
# License: BSD 3 clause | ||
|
||
__version__ = '0.4.1dev' | ||
__version__ = '0.4.1' |
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,19 @@ | ||
# Sebastian Raschka 2014-2016 | ||
# mlxtend Machine Learning Library Extensions | ||
# Author: Sebastian Raschka <sebastianraschka.com> | ||
# | ||
# License: BSD 3 clause | ||
|
||
from ._base_estimator import _BaseEstimator | ||
from ._base_supervised_estimator import _BaseSupervisedEstimator | ||
from ._base_unsupervised_estimator import _BaseUnsupervisedEstimator | ||
from ._base_classifier import _BaseClassifier | ||
from ._base_multiclass import _BaseMultiClass | ||
from ._base_multilayer import _BaseMultiLayer | ||
from ._base_regressor import _BaseRegressor | ||
from ._base_cluster import _BaseCluster | ||
|
||
__all__ = ["_BaseEstimator", | ||
"_BaseSupervisedEstimator", "_BaseUnsupervisedEstimator", | ||
"_BaseClassifier", "_BaseMultiClass", "_BaseMultiLayer", | ||
"_BaseRegressor", "_BaseCluster"] |
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,60 @@ | ||
# Sebastian Raschka 2014-2016 | ||
# mlxtend Machine Learning Library Extensions | ||
# | ||
# Base Clusteer (Clutering Parent Class) | ||
# Author: Sebastian Raschka <sebastianraschka.com> | ||
# | ||
# License: BSD 3 clause | ||
|
||
import numpy as np | ||
from ._base_supervised_estimator import _BaseSupervisedEstimator | ||
|
||
|
||
class _BaseClassifier(_BaseSupervisedEstimator): | ||
|
||
"""Parent Class Classifier | ||
A base class that is implemented by classifiers | ||
""" | ||
def __init__(self, print_progress=0, random_seed=0): | ||
super(_BaseClassifier, self).__init__( | ||
print_progress=print_progress, | ||
random_seed=random_seed) | ||
self._binary_classifier = False | ||
|
||
def _check_target_array(self, y, allowed=None): | ||
if not np.issubdtype(y[0], int): | ||
raise AttributeError('y must be an integer array.\nFound %s' | ||
% y.dtype) | ||
found_labels = np.unique(y) | ||
if (found_labels < 0).any(): | ||
raise AttributeError('y array must not contain negative labels.' | ||
'\nFound %s' % found_labels) | ||
if allowed is not None: | ||
found_labels = tuple(found_labels) | ||
if found_labels not in allowed: | ||
raise AttributeError('Labels not in %s.\nFound %s' | ||
% (allowed, found_labels)) | ||
|
||
def score(self, X, y): | ||
""" Compute the prediction accuracy | ||
Parameters | ||
---------- | ||
X : {array-like, sparse matrix}, shape = [n_samples, n_features] | ||
Training vectors, where n_samples is the number of samples and | ||
n_features is the number of features. | ||
y : array-like, shape = [n_samples] | ||
Target values (true class labels). | ||
Returns | ||
--------- | ||
acc : float | ||
The prediction accuracy as a float | ||
between 0.0 and 1.0 (perfect score). | ||
""" | ||
y_pred = self.predict(X) | ||
acc = np.sum(y == y_pred, axis=0) / float(X.shape[0]) | ||
return acc |
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,22 @@ | ||
# Sebastian Raschka 2014-2016 | ||
# mlxtend Machine Learning Library Extensions | ||
# | ||
# Base Clusteer (Clutering Parent Class) | ||
# Author: Sebastian Raschka <sebastianraschka.com> | ||
# | ||
# License: BSD 3 clause | ||
|
||
from ._base_unsupervised_estimator import _BaseUnsupervisedEstimator | ||
|
||
|
||
class _BaseCluster(_BaseUnsupervisedEstimator): | ||
|
||
"""Parent Class Unsupervised Estimator | ||
A base class that is implemented by clustering estimators | ||
""" | ||
def __init__(self, print_progress=0, random_seed=0): | ||
super(_BaseCluster, self).__init__( | ||
print_progress=print_progress, | ||
random_seed=random_seed) |
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,40 @@ | ||
# Sebastian Raschka 2014-2016 | ||
# mlxtend Machine Learning Library Extensions | ||
# | ||
# Base Clusteer (Clutering Parent Class) | ||
# Author: Sebastian Raschka <sebastianraschka.com> | ||
# | ||
# License: BSD 3 clause | ||
|
||
import numpy as np | ||
|
||
|
||
class _BaseMultiClass(object): | ||
"""Add-on Parent Class for Multi-class classifier""" | ||
|
||
def __init__(self): | ||
pass | ||
|
||
def _one_hot(self, y, n_labels, dtype): | ||
"""Returns a matrix where each sample in y is represented | ||
as a row, and each column represents the class label in | ||
the one-hot encoding scheme. | ||
Example: | ||
y = np.array([0, 1, 2, 3, 4, 2]) | ||
mc = _BaseMultiClass() | ||
mc._one_hot(y=y, n_labels=5, dtype='float') | ||
np.array([[1., 0., 0., 0., 0.], | ||
[0., 1., 0., 0., 0.], | ||
[0., 0., 1., 0., 0.], | ||
[0., 0., 0., 1., 0.], | ||
[0., 0., 0., 0., 1.], | ||
[0., 0., 1., 0., 0.]]) | ||
""" | ||
mat = np.zeros((len(y), n_labels)) | ||
for i, val in enumerate(y): | ||
mat[i, val] = 1 | ||
return mat.astype(dtype) |
Oops, something went wrong.