Skip to content

Commit

Permalink
docstrings for Binarizer
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Kiggins committed Nov 20, 2017
1 parent 70b7b3f commit 51d1796
Showing 1 changed file with 47 additions and 1 deletion.
48 changes: 47 additions & 1 deletion neuroglia/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,63 @@
from sklearn.preprocessing import binarize

class Binarizer(BaseEstimator, TransformerMixin):
"""docstring for scikit learn Binarizer
"""Binarize data (set feature values to 0 or 1) according to a threshold
This transformer is a DataFram-friendly alternative to
sklearn.preprocessing.Binarizer
Values greater than the threshold map to 1, while values less than
or equal to the threshold map to 0. With the default threshold of 0,
only positive values map to 1.
Parameters
----------
threshold : float, optional (0.0 by default)
Feature values below or equal to this are replaced by 0, above it by 1.
Threshold may not be less than 0 for operations on sparse matrices.
copy : boolean, optional, default True
set to False to perform inplace binarization and avoid a copy (if
the input is already a numpy array or a scipy.sparse CSR matrix).
Notes
-----
If the input is a sparse matrix, only the non-zero values are subject
to update by the Binarizer class.
This estimator is stateless (besides constructor parameters), the
fit method does nothing but is useful when used in a pipeline.
"""

def __init__(self, threshold=0.0, copy=True):
self.threshold = threshold
self.copy = copy

def fit(self, X, y=None):
"""Do nothing and return the estimator unchanged
This method is here to implement the scikit-learn API and work in
scikit-learn pipelines.
Parameters
----------
X : array-like
Returns
-------
self
"""
return self

def transform(self, X):
"""Binarize each element of X
Parameters
----------
X : {array-like, sparse matrix}, shape [n_samples, n_features]
The data to binarize, element by element.
"""
df = True
try:
index = X.index
Expand Down

0 comments on commit 51d1796

Please sign in to comment.