Class: LabelSpreading
LabelSpreading model for semi-supervised learning.
This model is similar to the basic Label Propagation algorithm, but uses affinity matrix based on the normalized graph Laplacian and soft clamping across the labels.
Read more in the User Guide.
Constructors
new LabelSpreading()
new LabelSpreading(
opts
?):LabelSpreading
Parameters
Parameter | Type | Description |
---|---|---|
opts ? | object | - |
opts.alpha ? | number | Clamping factor. A value in (0, 1) that specifies the relative amount that an instance should adopt the information from its neighbors as opposed to its initial label. alpha=0 means keeping the initial label information; alpha=1 means replacing all initial information. |
opts.gamma ? | number | Parameter for rbf kernel. |
opts.kernel ? | "rbf" | "knn" | String identifier for kernel function to use or the kernel function itself. Only ‘rbf’ and ‘knn’ strings are valid inputs. The function passed should take two inputs, each of shape (n_samples, n_features), and return a (n_samples, n_samples) shaped weight matrix. |
opts.max_iter ? | number | Maximum number of iterations allowed. |
opts.n_jobs ? | number | The number of parallel jobs to run. undefined means 1 unless in a joblib.parallel_backend context. \-1 means using all processors. See Glossary for more details. |
opts.n_neighbors ? | number | Parameter for knn kernel which is a strictly positive integer. |
opts.tol ? | number | Convergence tolerance: threshold to consider the system at steady state. |
Returns LabelSpreading
Defined in generated/semi_supervised/LabelSpreading.ts:25
Properties
Property | Type | Default value | Defined in |
---|---|---|---|
_isDisposed | boolean | false | generated/semi_supervised/LabelSpreading.ts:23 |
_isInitialized | boolean | false | generated/semi_supervised/LabelSpreading.ts:22 |
_py | PythonBridge | undefined | generated/semi_supervised/LabelSpreading.ts:21 |
id | string | undefined | generated/semi_supervised/LabelSpreading.ts:18 |
opts | any | undefined | generated/semi_supervised/LabelSpreading.ts:19 |
Accessors
classes_
Get Signature
get classes_():
Promise
<ArrayLike
>
The distinct labels used in classifying instances.
Returns Promise
<ArrayLike
>
Defined in generated/semi_supervised/LabelSpreading.ts:392
feature_names_in_
Get Signature
get feature_names_in_():
Promise
<ArrayLike
>
Names of features seen during fit. Defined only when X
has feature names that are all strings.
Returns Promise
<ArrayLike
>
Defined in generated/semi_supervised/LabelSpreading.ts:492
label_distributions_
Get Signature
get label_distributions_():
Promise
<ArrayLike
[]>
Categorical distribution for each item.
Returns Promise
<ArrayLike
[]>
Defined in generated/semi_supervised/LabelSpreading.ts:417
n_features_in_
Get Signature
get n_features_in_():
Promise
<number
>
Number of features seen during fit.
Returns Promise
<number
>
Defined in generated/semi_supervised/LabelSpreading.ts:467
n_iter_
Get Signature
get n_iter_():
Promise
<number
>
Number of iterations run.
Returns Promise
<number
>
Defined in generated/semi_supervised/LabelSpreading.ts:517
py
Get Signature
get py():
PythonBridge
Returns PythonBridge
Set Signature
set py(
pythonBridge
):void
Parameters
Parameter | Type |
---|---|
pythonBridge | PythonBridge |
Returns void
Defined in generated/semi_supervised/LabelSpreading.ts:77
transduction_
Get Signature
get transduction_():
Promise
<ArrayLike
>
Label assigned to each item during fit.
Returns Promise
<ArrayLike
>
Defined in generated/semi_supervised/LabelSpreading.ts:442
X_
Get Signature
get X_():
Promise
<ArrayLike
[]>
Input array.
Returns Promise
<ArrayLike
[]>
Defined in generated/semi_supervised/LabelSpreading.ts:369
Methods
dispose()
dispose():
Promise
<void
>
Disposes of the underlying Python resources.
Once dispose()
is called, the instance is no longer usable.
Returns Promise
<void
>
Defined in generated/semi_supervised/LabelSpreading.ts:129
fit()
fit(
opts
):Promise
<any
>
Fit a semi-supervised label propagation model to X.
The input samples (labeled and unlabeled) are provided by matrix X, and target labels are provided by matrix y. We conventionally apply the label -1 to unlabeled samples in matrix y in a semi-supervised classification.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike | Training data, where n_samples is the number of samples and n_features is the number of features. |
opts.y ? | ArrayLike | Target class values with unlabeled points marked as -1. All unlabeled samples will be transductively assigned labels internally, which are stored in transduction_ . |
Returns Promise
<any
>
Defined in generated/semi_supervised/LabelSpreading.ts:148
get_metadata_routing()
get_metadata_routing(
opts
):Promise
<any
>
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.routing ? | any | A MetadataRequest encapsulating routing information. |
Returns Promise
<any
>
Defined in generated/semi_supervised/LabelSpreading.ts:187
init()
init(
py
):Promise
<void
>
Initializes the underlying Python resources.
This instance is not usable until the Promise
returned by init()
resolves.
Parameters
Parameter | Type |
---|---|
py | PythonBridge |
Returns Promise
<void
>
Defined in generated/semi_supervised/LabelSpreading.ts:90
predict()
predict(
opts
):Promise
<ArrayLike
>
Perform inductive inference across the model.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike [] | The data matrix. |
Returns Promise
<ArrayLike
>
Defined in generated/semi_supervised/LabelSpreading.ts:221
predict_proba()
predict_proba(
opts
):Promise
<ArrayLike
[]>
Predict probability for each possible outcome.
Compute the probability estimates for each single sample in X and each possible outcome seen during training (categorical distribution).
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike [] | The data matrix. |
Returns Promise
<ArrayLike
[]>
Defined in generated/semi_supervised/LabelSpreading.ts:255
score()
score(
opts
):Promise
<number
>
Return the mean accuracy on the given test data and labels.
In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | ArrayLike | Sample weights. |
opts.X ? | ArrayLike [] | Test samples. |
opts.y ? | ArrayLike | True labels for X . |
Returns Promise
<number
>
Defined in generated/semi_supervised/LabelSpreading.ts:289
set_score_request()
set_score_request(
opts
):Promise
<any
>
Request metadata passed to the score
method.
Note that this method is only relevant if enable_metadata_routing=True
(see sklearn.set_config
). Please see User Guide on how the routing mechanism works.
The options for each parameter are:
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | string | boolean | Metadata routing for sample_weight parameter in score . |
Returns Promise
<any
>