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:
model (
ModelLike) – The model to wrap.apply_to (
list[str] |set[str] |str| ColumnTypes |None, default:None) – The column types to apply the model to. If None, the model is applied to continuous type (default is None).needed_types (
list[str] |set[str] |str| ColumnTypes |None, default:None) – 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.
- predict(X)¶
Predict using the model.
- Parameters:
X (
DataFrame) – The data to predict on.- Returns:
The predictions.
- score(X, y, sample_weight=None)¶
Score the model.
- predict_proba(X)¶
Compute probabilities of possible outcomes for samples in X.
- decision_function(X)¶
Evaluate the decision function for the samples in X.
- Parameters:
X (
DataFrame) – The data to obtain the decision function.- Returns:
Returns the decision function of the sample for each class in the model. Shape is (n_samples, n_class * (n_class-1) / 2).
- predict_log_proba(X)¶
Compute probabilities of possible outcomes for samples in X.
- get_params(deep=True)¶
Get the parameters of the model.
- Parameters:
deep (
bool, default:True) – If True, will return the parameters for this model and contained subobjects that are estimators (default is True).- Returns:
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:
**kwargs (
Any) – Model parameters.- Returns:
WrapModel instance.
- Raises:
ValueError – If a parameter is not a parameter of this model or of the wrapped model.
- filter_columns(X)¶
Get the apply_to columns of a pandas DataFrame.
- Parameters:
X (
DataFrame) – The DataFrame to filter.- Returns:
The DataFrame with only the apply_to columns.
- get_apply_to()¶
Get the column types the estimator applies to.
- Returns:
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:
A
MetadataRequestencapsulating routing information.
- get_needed_types()¶
Get the column types needed by the estimator.
- Returns:
The column types needed by the estimator.
- set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') WrapModel¶
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
sample_weight (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
sample_weightparameter inscore.- Returns:
The updated object.