sklearndf.wrapper.numpy.ClassifierNPDF#
- class sklearndf.wrapper.numpy.ClassifierNPDF(delegate, column_names=None)[source]#
Adapter class that delegates to
ClassifierDF
and accepts numpy arrays in addition topandas
data frames and series.Converts all numpy arrays to pandas series or data frames before deferring to the delegate estimator, and passes through pandas objects unchanged.
For use in meta-estimators that internally hand numpy arrays on to sub-estimators.
- Bases
SupervisedLearnerNPDF
[~T_DelegateClassifierDF],ClassifierDF
- Generic types
~T_DelegateClassifierDF(bound=
ClassifierDF
)- Metaclasses
- Parameters
delegate (
EstimatorNPDF
) – the sklearndf estimator to invoke after transforming the incoming numpy arrays to pandas data frames or seriescolumn_names (
Union
[Sequence
[str
],Callable
[[],Sequence
[str
]],None
]) – optional column names to use for the pandas data frame derived from the features numpy array; passed either as a sequence of strings, or as a function that dynamically provides the column names
Method summary
Make an unfitted clone of this estimator.
Compute the decision function for the given inputs.
Fit this estimator using the given inputs.
Get the parameters for this estimator.
Predict outputs for the given inputs.
Predict class log-probabilities for the given inputs.
Predict class probabilities for the given inputs.
Score this learner using the given inputs and outputs.
Set the parameters of this estimator.
Render this object as an expression.
Attribute summary
COL_FEATURE
Name assigned to an
Index
or aSeries
with the names of the features used to fit aEstimatorDF
.Get the classes predicted by this classifier as a numpy array of class labels for single-output problems, or a list of such arrays for multi-output problems
The pandas column index with the names of the features used to fit this estimator.
True
if this object is fitted,False
otherwise.The number of features used to fit this estimator.
The number of outputs used to fit this estimator.
The native estimator underlying this estimator.
The name(s) of the output(s) this supervised learner was fitted to.
delegate
The sklearndf estimator to invoke after transforming the incoming numpy arrays to pandas data frames or series.
column_names
Column names to use for the pandas data frame derived from the features numpy array.
Definitions
- clone()#
Make an unfitted clone of this estimator.
- Return type
- Returns
the unfitted clone
- decision_function(X, **predict_params)[source]#
Compute the decision function for the given inputs.
The inputs must have the same features as the inputs used to fit this learner. The features can be provided in any order since they are identified by their column names.
- Parameters
- Return type
- Returns
a data frame with observations as rows and classes as columns, and values as the raw values predicted per observation and class; for multi-output classifiers, a list of one observation/class data frames per output
- fit(X, y=None, **fit_params)#
Fit this estimator using the given inputs.
- Parameters
X (
Union
[ndarray
[Any
,dtype
[Any
]],spmatrix
,Series
,DataFrame
]) – input data frame with observations as rows and features as columnsy (
Union
[ndarray
[Any
,dtype
[Any
]],Series
,DataFrame
,None
]) – an optional series or data frame with one or more outputsfit_params (
Any
) – additional keyword parameters as required by specific estimator implementations
- Return type
- Returns
self
- get_params(deep=True)#
Get the parameters for this estimator.
- predict(X, **predict_params)#
Predict outputs for the given inputs.
The inputs must have the same features as the inputs used to fit this learner. The features can be provided in any order since they are identified by their column names.
- Parameters
- Return type
- Returns
predictions per observation as a series, or as a data frame in case of multiple outputs
- predict_log_proba(X, **predict_params)[source]#
Predict class log-probabilities for the given inputs.
The inputs must have the same features as the inputs used to fit this learner. The features can be provided in any order since they are identified by their column names.
- Parameters
- Return type
- Returns
a data frame with observations as rows and classes as columns, and values as log-probabilities per observation and class; for multi-output classifiers, a list of one observation/class data frames per output
- predict_proba(X, **predict_params)[source]#
Predict class probabilities for the given inputs.
The inputs must have the same features as the inputs used to fit this learner. The features can be provided in any order since they are identified by their column names.
- Parameters
- Return type
- Returns
a data frame with observations as rows and classes as columns, and values as probabilities per observation and class; for multi-output classifiers, a list of one observation/class data frames per output
- score(X, y, sample_weight=None)#
Score this learner using the given inputs and outputs.
- Parameters
X (
Union
[ndarray
[Any
,dtype
[Any
]],DataFrame
]) – data frame with observations as rows and features as columnsy (
Union
[ndarray
[Any
,dtype
[Any
]],Series
]) – a series or data frame with the true outputs per observationsample_weight (
Optional
[Series
]) – optional series of scalar weights, for calculating the resulting score as the weighted mean of the scores for the individual predictions
- Return type
- Returns
the score
- set_params(**params)#
Set the parameters of this estimator.
Valid parameter keys can be obtained by calling
get_params()
.- Parameters
params (
Any
) – the estimator parameters to set- Return type
- Returns
self
- to_expression()#
Render this object as an expression.
- Return type
- Returns
the expression representing this object
- property classes_: Union[numpy.ndarray[Any, numpy.dtype[Any]], List[numpy.ndarray[Any, numpy.dtype[Any]]]]#
Get the classes predicted by this classifier as a numpy array of class labels for single-output problems, or a list of such arrays for multi-output problems
- property feature_names_in_: pandas.Index#
The pandas column index with the names of the features used to fit this estimator.
- Raises
AttributeError – this estimator is not fitted
- Return type
- property n_features_in_: int#
The number of features used to fit this estimator.
- Raises
AttributeError – this estimator is not fitted
- Return type
- property n_outputs_: int#
The number of outputs used to fit this estimator.
- Raises
AttributeError – this estimator is not fitted
- Return type
- property native_estimator: sklearn.base.BaseEstimator#
The native estimator underlying this estimator.
This can be another estimator that this estimator delegates to, otherwise the native estimator is
self
.- Return type
- property output_names_: List[str]#
The name(s) of the output(s) this supervised learner was fitted to.
- Raises
sklearn.exceptions.NotFittedError – this estimator is not fitted
- Return type