Documentation
Classes
LabelSpreading

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.

Python Reference (opens in a new tab)

Constructors

constructor()

Signature

new LabelSpreading(opts?: object): LabelSpreading;

Parameters

NameTypeDescription
opts?object-
opts.alpha?numberClamping 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. Default Value 0.2
opts.gamma?numberParameter for rbf kernel. Default Value 20
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. Default Value 'rbf'
opts.max_iter?numberMaximum number of iterations allowed. Default Value 30
opts.n_jobs?numberThe number of parallel jobs to run. undefined means 1 unless in a joblib.parallel\_backend (opens in a new tab) context. \-1 means using all processors. See Glossary for more details.
opts.n_neighbors?numberParameter for knn kernel which is a strictly positive integer. Default Value 7
opts.tol?numberConvergence tolerance: threshold to consider the system at steady state. Default Value 0.001

Returns

LabelSpreading

Defined in: generated/semi_supervised/LabelSpreading.ts:25 (opens in a new tab)

Methods

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/LabelSpreading.ts:136 (opens in a new tab)

fit()

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.

Signature

fit(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeTraining data, where n\_samples is the number of samples and n\_features is the number of features.
opts.y?ArrayLikeTarget 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:155 (opens in a new tab)

get_metadata_routing()

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Signature

get_metadata_routing(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.routing?anyA MetadataRequest encapsulating routing information.

Returns

Promise<any>

Defined in: generated/semi_supervised/LabelSpreading.ts:197 (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

NameType
pyPythonBridge

Returns

Promise<void>

Defined in: generated/semi_supervised/LabelSpreading.ts:90 (opens in a new tab)

predict()

Perform inductive inference across the model.

Signature

predict(opts: object): Promise<ArrayLike>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]The data matrix.

Returns

Promise<ArrayLike>

Defined in: generated/semi_supervised/LabelSpreading.ts:232 (opens in a new tab)

predict_proba()

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).

Signature

predict_proba(opts: object): Promise<ArrayLike[]>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]The data matrix.

Returns

Promise<ArrayLike[]>

Defined in: generated/semi_supervised/LabelSpreading.ts:267 (opens in a new tab)

score()

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.

Signature

score(opts: object): Promise<number>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]Test samples.
opts.sample_weight?ArrayLikeSample weights.
opts.y?ArrayLikeTrue labels for X.

Returns

Promise<number>

Defined in: generated/semi_supervised/LabelSpreading.ts:302 (opens in a new tab)

set_score_request()

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:

Signature

set_score_request(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.sample_weight?string | booleanMetadata routing for sample\_weight parameter in score.

Returns

Promise<any>

Defined in: generated/semi_supervised/LabelSpreading.ts:353 (opens in a new tab)

Properties

_isDisposed

boolean = false

Defined in: generated/semi_supervised/LabelSpreading.ts:23 (opens in a new tab)

_isInitialized

boolean = false

Defined in: generated/semi_supervised/LabelSpreading.ts:22 (opens in a new tab)

_py

PythonBridge

Defined in: generated/semi_supervised/LabelSpreading.ts:21 (opens in a new tab)

id

string

Defined in: generated/semi_supervised/LabelSpreading.ts:18 (opens in a new tab)

opts

any

Defined in: generated/semi_supervised/LabelSpreading.ts:19 (opens in a new tab)

Accessors

X_

Input array.

Signature

X_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/semi_supervised/LabelSpreading.ts:389 (opens in a new tab)

classes_

The distinct labels used in classifying instances.

Signature

classes_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/semi_supervised/LabelSpreading.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/LabelSpreading.ts:512 (opens in a new tab)

label_distributions_

Categorical distribution for each item.

Signature

label_distributions_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/semi_supervised/LabelSpreading.ts:437 (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/LabelSpreading.ts:487 (opens in a new tab)

n_iter_

Number of iterations run.

Signature

n_iter_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/semi_supervised/LabelSpreading.ts:537 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/semi_supervised/LabelSpreading.ts:77 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/semi_supervised/LabelSpreading.ts:81 (opens in a new tab)

transduction_

Label assigned to each item during fit.

Signature

transduction_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/semi_supervised/LabelSpreading.ts:462 (opens in a new tab)