adapt.parameter_based.TransferForestClassifier
- class adapt.parameter_based.TransferForestClassifier(estimator=None, Xt=None, yt=None, algo='', bootstrap=False, cpy=True, verbose=1, random_state=None, **params)[source]
TransferForestClassifier: Modify a source Random Forest on a target dataset.
- Parameters
- estimatorsklearn RandomForestClassifier (default=None)
Source random forest classifier.
- Xtnumpy array (default=None)
Target input data.
- ytnumpy array (default=None)
Target output data.
- algostr or callable (default=””)
Leaves relabeling if “” or “relab”. “ser” and “strut” for SER and STRUT algorithms
- bootstrapboolean (default=True).
- copyboolean (default=True)
Whether to make a copy of
estimatoror not.- verboseint (default=1)
Verbosity level.
- random_stateint (default=None)
Seed of random generator.
References
- 1
[1] Segev, Noam and Harel, Maayan Mannor, Shie and Crammer, Koby and El-Yaniv, Ran “Learn on Source, Refine on Target: A Model Transfer Learning Framework with Random Forests”. In IEEE TPAMI, 2017.
- 2
[2] Minvielle, Ludovic and Atiq, Mounir Peignier, Sergio and Mougeot, Mathilde “Transfer Learning on Decision Tree with Class Imbalance”. In IEEE ICTAI, 2019.
- Attributes
- estimator_sklearn RandomForestClassifier
Transferred random forest classifier using target data.
- rf_sizeint.
- estimators_numpy array of TransferTreeClassifier.
Methods
__init__([estimator, Xt, yt, algo, ...])fit([Xt, yt])Fit TransferTreeClassifier.
fit_estimator(X, y[, sample_weight, ...])Fit estimator on X, y.
get_params([deep])Get parameters for this estimator.
predict(X[, domain])Return estimator predictions after adaptation.
predict_estimator(X, **predict_params)Return estimator predictions for X.
score(X, y[, sample_weight, domain])Return the estimator score.
set_params(**params)Set the parameters of this estimator.
unsupervised_score(Xs, Xt)Return unsupervised score.
- __init__(estimator=None, Xt=None, yt=None, algo='', bootstrap=False, cpy=True, verbose=1, random_state=None, **params)[source]
- fit(Xt=None, yt=None, **fit_params)[source]
Fit TransferTreeClassifier.
- Parameters
- Xtnumpy array (default=None)
Target input data.
- ytnumpy array (default=None)
Target output data.
- fit_paramskey, value arguments
Arguments for the estimator.
- Returns
- selfreturns an instance of self
- fit_estimator(X, y, sample_weight=None, random_state=None, warm_start=True, **fit_params)[source]
Fit estimator on X, y.
- Parameters
- Xarray
Input data.
- yarray
Output data.
- sample_weightarray
Importance weighting.
- random_stateint (default=None)
Seed of the random generator
- warm_startbool (default=True)
If True, continue to fit
estimator_, else, a new estimator is fitted based on a copy ofestimator. (Be sure to setcopy=Trueto usewarm_start=False)- fit_paramskey, value arguments
Arguments given to the fit method of the estimator and to the compile method for tensorflow estimator.
- Returns
- estimator_fitted estimator
- get_params(deep=True)[source]
Get parameters for this estimator.
- Parameters
- deepbool, default=True
Not used, here for scikit-learn compatibility.
- Returns
- paramsdict
Parameter names mapped to their values.
- predict(X, domain=None, **predict_params)[source]
Return estimator predictions after adaptation.
For feature-based method (object which implements a
transformmethod), the input featureXare first transformed. Then thepredictmethod of the fitted estimatorestimator_is applied on the transformedX.- Parameters
- Xarray
input data
- domainstr (default=None)
For antisymetric feature-based method, different transformation of the input X are applied for different domains. The domain should then be specified between “src” and “tgt”. If
Nonethe default transformation is the target one.
- Returns
- y_predarray
prediction of the Adapt Model.
- predict_estimator(X, **predict_params)[source]
Return estimator predictions for X.
- Parameters
- Xarray
input data
- Returns
- y_predarray
prediction of estimator.
- score(X, y, sample_weight=None, domain=None)[source]
Return the estimator score.
If the object has a
transformmethod, the estimator is applied on the transformed features X. For antisymetric transformation, a parameter domain can be set to specified between source and target transformation.Call score on sklearn estimator and evaluate on tensorflow Model.
- Parameters
- Xarray
input data
- yarray
output data
- sample_weightarray (default=None)
Sample weights
- domainstr (default=None)
This parameter specifies for antisymetric feature-based method which transformation will be applied between “source” and “target”. If
Nonethe transformation by default is the target one.
- Returns
- scorefloat
estimator score.