DocumentationClassesDictionaryLearning

Class: DictionaryLearning

Dictionary learning.

Finds a dictionary (a set of atoms) that performs well at sparsely encoding the fitted data.

Solves the optimization problem:

Python Reference

Constructors

new DictionaryLearning()

new DictionaryLearning(opts?): DictionaryLearning

Parameters

ParameterTypeDescription
opts?object-
opts.alpha?numberSparsity controlling parameter.
opts.callback?anyCallable that gets invoked every five iterations.
opts.code_init?ArrayLike[]Initial value for the code, for warm restart. Only used if code_init and dict_init are not undefined.
opts.dict_init?ArrayLike[]Initial values for the dictionary, for warm restart. Only used if code_init and dict_init are not undefined.
opts.fit_algorithm?"cd" | "lars"'lars': uses the least angle regression method to solve the lasso problem (lars_path);
opts.max_iter?numberMaximum number of iterations to perform.
opts.n_components?numberNumber of dictionary elements to extract. If undefined, then n_components is set to n_features.
opts.n_jobs?numberNumber 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.positive_code?booleanWhether to enforce positivity when finding the code.
opts.positive_dict?booleanWhether to enforce positivity when finding the dictionary.
opts.random_state?numberUsed for initializing the dictionary when dict_init is not specified, randomly shuffling the data when shuffle is set to true, and updating the dictionary. Pass an int for reproducible results across multiple function calls. See Glossary.
opts.split_sign?booleanWhether to split the sparse feature vector into the concatenation of its negative part and its positive part. This can improve the performance of downstream classifiers.
opts.tol?numberTolerance for numerical error.
opts.transform_algorithm?"threshold" | "lars" | "lasso_lars" | "lasso_cd" | "omp"Algorithm used to transform the data:
opts.transform_alpha?numberIf algorithm='lasso_lars' or algorithm='lasso_cd', alpha is the penalty applied to the L1 norm. If algorithm='threshold', alpha is the absolute value of the threshold below which coefficients will be squashed to zero. If undefined, defaults to alpha.
opts.transform_max_iter?numberMaximum number of iterations to perform if algorithm='lasso_cd' or 'lasso_lars'.
opts.transform_n_nonzero_coefs?numberNumber of nonzero coefficients to target in each column of the solution. This is only used by algorithm='lars' and algorithm='omp'. If undefined, then transform_n_nonzero_coefs=int(n_features / 10).
opts.verbose?booleanTo control the verbosity of the procedure.

Returns DictionaryLearning

Defined in generated/decomposition/DictionaryLearning.ts:25

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/decomposition/DictionaryLearning.ts:23
_isInitializedbooleanfalsegenerated/decomposition/DictionaryLearning.ts:22
_pyPythonBridgeundefinedgenerated/decomposition/DictionaryLearning.ts:21
idstringundefinedgenerated/decomposition/DictionaryLearning.ts:18
optsanyundefinedgenerated/decomposition/DictionaryLearning.ts:19

Accessors

components_

Get Signature

get components_(): Promise<ArrayLike[]>

dictionary atoms extracted from the data

Returns Promise<ArrayLike[]>

Defined in generated/decomposition/DictionaryLearning.ts:446


error_

Get Signature

get error_(): Promise<any>

vector of errors at each iteration

Returns Promise<any>

Defined in generated/decomposition/DictionaryLearning.ts:473


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/decomposition/DictionaryLearning.ts:527


n_features_in_

Get Signature

get n_features_in_(): Promise<number>

Number of features seen during fit.

Returns Promise<number>

Defined in generated/decomposition/DictionaryLearning.ts:500


n_iter_

Get Signature

get n_iter_(): Promise<number>

Number of iterations run.

Returns Promise<number>

Defined in generated/decomposition/DictionaryLearning.ts:554


py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/decomposition/DictionaryLearning.ts:145

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/decomposition/DictionaryLearning.ts:201


fit()

fit(opts): Promise<any>

Fit the model from data in X.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLike[]Training vector, where n_samples is the number of samples and n_features is the number of features.
opts.y?anyNot used, present for API consistency by convention.

Returns Promise<any>

Defined in generated/decomposition/DictionaryLearning.ts:218


fit_transform()

fit_transform(opts): Promise<ArrayLike[]>

Fit the model from data in X and return the transformed data.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLike[]Training vector, where n_samples is the number of samples and n_features is the number of features.
opts.y?anyNot used, present for API consistency by convention.

Returns Promise<ArrayLike[]>

Defined in generated/decomposition/DictionaryLearning.ts:257


get_feature_names_out()

get_feature_names_out(opts): Promise<any>

Get output feature names for transformation.

The feature names out will prefixed by the lowercased class name. For example, if the transformer outputs 3 features, then the feature names out are: \["class_name0", "class_name1", "class_name2"\].

Parameters

ParameterTypeDescription
optsobject-
opts.input_features?anyOnly used to validate feature names with the names seen in fit.

Returns Promise<any>

Defined in generated/decomposition/DictionaryLearning.ts:300


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

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

Returns Promise<any>

Defined in generated/decomposition/DictionaryLearning.ts:338


init()

init(py): Promise<void>

Initializes the underlying Python resources.

This instance is not usable until the Promise returned by init() resolves.

Parameters

ParameterType
pyPythonBridge

Returns Promise<void>

Defined in generated/decomposition/DictionaryLearning.ts:158


set_output()

set_output(opts): Promise<any>

Set output container.

See Introducing the set_output API for an example on how to use the API.

Parameters

ParameterTypeDescription
optsobject-
opts.transform?"default" | "pandas" | "polars"Configure output of transform and fit_transform.

Returns Promise<any>

Defined in generated/decomposition/DictionaryLearning.ts:376


transform()

transform(opts): Promise<ArrayLike[]>

Encode the data as a sparse combination of the dictionary atoms.

Coding method is determined by the object parameter transform_algorithm.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLike[]Test data to be transformed, must have the same number of features as the data used to train the model.

Returns Promise<ArrayLike[]>

Defined in generated/decomposition/DictionaryLearning.ts:412

Last updated on