Note
This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the What you really need to know section for the big picture.
julearn.base.WrapModel#
- class julearn.base.WrapModel(model, apply_to=None, needed_types=None, **params)#
Wrap a model to make it a julearn estimator.
- Parameters:
- modelModelLike
The model to wrap.
- apply_tostr or list of str or set of str or ColumnTypes
The column types to apply the model to. If None, the model is applied to continuous type (default is None).
- needed_typesstr or list of str or set of str or ColumnTypes
The column types needed by the model. If None, there are no needed types (default is None)
- **params
The parameters to set on the model.
- __init__(model, apply_to=None, needed_types=None, **params)#
- fit(X, y=None, **fit_params)#
Fit the model.
This method will fit the model using only the columns selected by apply_to.
- Parameters:
- Xpd.DataFrame
The data to fit the model on.
- yDataLike, optional
The target data (default is None).
- **fit_paramsAny
Additional parameters to pass to the model’s fit method.
- Returns:
- WrapModel
The fitted model.
- predict(X)#
Predict using the model.
- Parameters:
- Xpd.DataFrame
The data to predict on.
- Returns:
- DataLike
The predictions.
- score(X, y)#
Score the model.
- Parameters:
- Xpd.DataFrame
The data to predict on.
- yDataLike
The true target values.
- Returns:
- float
The score.
- predict_proba(X)#
Compute probabilities of possible outcomes for samples in X.
- Parameters:
- Xpd.DataFrame
The data to predict on.
- Returns:
- np.ndarray
Returns the probability of the sample for each class in the model. The columns correspond to the classes in sorted order, as they appear in the attribute classes_.
- decision_function(X)#
Evaluate the decision function for the samples in X.
- Parameters:
- Xpd.DataFrame
The data to obtain the decision function.
- Returns:
- Xarray-like of shape (n_samples, n_class * (n_class-1) / 2)
Returns the decision function of the sample for each class in the model.
- predict_log_proba(X)#
Compute probabilities of possible outcomes for samples in X.
- Parameters:
- Xpd.DataFrame
The data to predict on.
- Returns:
- np.ndarray
Returns the probability of the sample for each class in the model. The columns correspond to the classes in sorted order, as they appear in the attribute classes_.
- get_params(deep=True)#
Get the parameters of the model.
- Parameters:
- deepbool, default=True
If True, will return the parameters for this model and contained subobjects that are estimators.
- Returns:
- paramsdict
Parameter names mapped to their values.
- set_params(**kwargs)#
Set the parameters of this model.
The method works on simple models as well as on nested objects (such as
sklearn.pipeline.Pipeline
). The latter have parameters of the form<component>__<parameter>
so that it’s possible to update each component of a nested object.- Parameters:
- **kwargsdict
Model parameters.
- Returns:
- WrapModel
WrapModel instance.
- filter_columns(X)#
Get the apply_to columns of a pandas DataFrame.
- Parameters:
- Xpd.DataFrame
The DataFrame to filter.
- Returns:
- pd.DataFrame
The DataFrame with only the apply_to columns.
- get_apply_to()#
Get the column types the estimator applies to.
- Returns:
- ColumnTypes
The column types the estimator applies to.
- get_metadata_routing()#
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
- routingMetadataRequest
A
MetadataRequest
encapsulating routing information.
- get_needed_types()#
Get the column types needed by the estimator.
- Returns:
- ColumnTypes
The column types needed by the estimator.