SelfTrainingClassifier
Self-training classifier.
This metaestimator allows a given supervised classifier to function as a semi-supervised classifier, allowing it to learn from unlabeled data. It does this by iteratively predicting pseudo-labels for the unlabeled data and adding them to the training set.
The classifier will continue iterating until either max_iter is reached, or no pseudo-labels were added to the training set in the previous iteration.
Read more in the User Guide.
Python Reference (opens in a new tab)
Constructors
constructor()
Signature
new SelfTrainingClassifier(opts?: object): SelfTrainingClassifier;
Parameters
Name | Type | Description |
---|---|---|
opts? | object | - |
opts.base_estimator? | any | An estimator object implementing fit and predict\_proba . Invoking the fit method will fit a clone of the passed estimator, which will be stored in the base\_estimator\_ attribute. |
opts.criterion? | "threshold" | "k_best" | The selection criterion used to select which labels to add to the training set. If 'threshold' , pseudo-labels with prediction probabilities above threshold are added to the dataset. If 'k\_best' , the k\_best pseudo-labels with highest prediction probabilities are added to the dataset. When using the ‘threshold’ criterion, a well calibrated classifier should be used. Default Value 'threshold' |
opts.k_best? | number | The amount of samples to add in each iteration. Only used when criterion='k\_best' . Default Value 10 |
opts.max_iter? | number | Maximum number of iterations allowed. Should be greater than or equal to 0. If it is undefined , the classifier will continue to predict labels until no new pseudo-labels are added, or all unlabeled samples have been labeled. Default Value 10 |
opts.threshold? | number | The decision threshold for use with criterion='threshold' . Should be in \0, 1). When using the 'threshold' criterion, a [well calibrated classifier should be used. Default Value 0.75 |
opts.verbose? | boolean | Enable verbose output. Default Value false |
Returns
Defined in: generated/semi_supervised/SelfTrainingClassifier.ts:27 (opens in a new tab)
Properties
_isDisposed
boolean
=false
Defined in: generated/semi_supervised/SelfTrainingClassifier.ts:25 (opens in a new tab)
_isInitialized
boolean
=false
Defined in: generated/semi_supervised/SelfTrainingClassifier.ts:24 (opens in a new tab)
_py
PythonBridge
Defined in: generated/semi_supervised/SelfTrainingClassifier.ts:23 (opens in a new tab)
id
string
Defined in: generated/semi_supervised/SelfTrainingClassifier.ts:20 (opens in a new tab)
opts
any
Defined in: generated/semi_supervised/SelfTrainingClassifier.ts:21 (opens in a new tab)
Accessors
base_estimator_
The fitted estimator.
Signature
base_estimator_(): Promise<any>;
Returns
Promise
<any
>
Defined in: generated/semi_supervised/SelfTrainingClassifier.ts:385 (opens in a new tab)
classes_
Class labels for each output. (Taken from the trained base\_estimator\_
).
Signature
classes_(): Promise<ArrayLike>;
Returns
Promise
<ArrayLike
>
Defined in: generated/semi_supervised/SelfTrainingClassifier.ts:412 (opens in a new tab)
feature_names_in_
Names of features seen during fit. Defined only when X
has feature names that are all strings.
Signature
feature_names_in_(): Promise<ArrayLike>;
Returns
Promise
<ArrayLike
>
Defined in: generated/semi_supervised/SelfTrainingClassifier.ts:520 (opens in a new tab)
labeled_iter_
The iteration in which each sample was labeled. When a sample has iteration 0, the sample was already labeled in the original dataset. When a sample has iteration -1, the sample was not labeled in any iteration.
Signature
labeled_iter_(): Promise<ArrayLike>;
Returns
Promise
<ArrayLike
>
Defined in: generated/semi_supervised/SelfTrainingClassifier.ts:466 (opens in a new tab)
n_features_in_
Number of features seen during fit.
Signature
n_features_in_(): Promise<number>;
Returns
Promise
<number
>
Defined in: generated/semi_supervised/SelfTrainingClassifier.ts:493 (opens in a new tab)
n_iter_
The number of rounds of self-training, that is the number of times the base estimator is fitted on relabeled variants of the training set.
Signature
n_iter_(): Promise<number>;
Returns
Promise
<number
>
Defined in: generated/semi_supervised/SelfTrainingClassifier.ts:547 (opens in a new tab)
py
Signature
py(): PythonBridge;
Returns
PythonBridge
Defined in: generated/semi_supervised/SelfTrainingClassifier.ts:72 (opens in a new tab)
Signature
py(pythonBridge: PythonBridge): void;
Parameters
Name | Type |
---|---|
pythonBridge | PythonBridge |
Returns
void
Defined in: generated/semi_supervised/SelfTrainingClassifier.ts:76 (opens in a new tab)
termination_condition_
The reason that fitting was stopped.
Signature
termination_condition_(): Promise<"max_iter" | "no_change" | "all_labeled">;
Returns
Promise
<"max_iter"
| "no_change"
| "all_labeled"
>
Defined in: generated/semi_supervised/SelfTrainingClassifier.ts:574 (opens in a new tab)
transduction_
The labels used for the final fit of the classifier, including pseudo-labels added during fit.
Signature
transduction_(): Promise<ArrayLike>;
Returns
Promise
<ArrayLike
>
Defined in: generated/semi_supervised/SelfTrainingClassifier.ts:439 (opens in a new tab)
Methods
decision_function()
Call decision function of the base\_estimator
.
Signature
decision_function(opts: object): Promise<ArrayLike[]>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | Array representing the data. |
Returns
Promise
<ArrayLike
[]>
Defined in: generated/semi_supervised/SelfTrainingClassifier.ts:150 (opens in a new tab)
dispose()
Disposes of the underlying Python resources.
Once dispose()
is called, the instance is no longer usable.
Signature
dispose(): Promise<void>;
Returns
Promise
<void
>
Defined in: generated/semi_supervised/SelfTrainingClassifier.ts:133 (opens in a new tab)
fit()
Fit self-training classifier using X
, y
as training data.
Signature
fit(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | Array representing the data. |
opts.y? | any | Array representing the labels. Unlabeled samples should have the label -1. |
Returns
Promise
<any
>
Defined in: generated/semi_supervised/SelfTrainingClassifier.ts:188 (opens in a new tab)
init()
Initializes the underlying Python resources.
This instance is not usable until the Promise
returned by init()
resolves.
Signature
init(py: PythonBridge): Promise<void>;
Parameters
Name | Type |
---|---|
py | PythonBridge |
Returns
Promise
<void
>
Defined in: generated/semi_supervised/SelfTrainingClassifier.ts:85 (opens in a new tab)
predict()
Predict the classes of X
.
Signature
predict(opts: object): Promise<ArrayLike>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | Array representing the data. |
Returns
Promise
<ArrayLike
>
Defined in: generated/semi_supervised/SelfTrainingClassifier.ts:230 (opens in a new tab)
predict_log_proba()
Predict log probability for each possible outcome.
Signature
predict_log_proba(opts: object): Promise<ArrayLike[]>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | Array representing the data. |
Returns
Promise
<ArrayLike
[]>
Defined in: generated/semi_supervised/SelfTrainingClassifier.ts:267 (opens in a new tab)
predict_proba()
Predict probability for each possible outcome.
Signature
predict_proba(opts: object): Promise<ArrayLike[]>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | Array representing the data. |
Returns
Promise
<ArrayLike
[]>
Defined in: generated/semi_supervised/SelfTrainingClassifier.ts:305 (opens in a new tab)
score()
Call score on the base\_estimator
.
Signature
score(opts: object): Promise<number>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | Array representing the data. |
opts.y? | ArrayLike | Array representing the labels. |
Returns
Promise
<number
>
Defined in: generated/semi_supervised/SelfTrainingClassifier.ts:343 (opens in a new tab)