Class: DictionaryLearning
Dictionary learning.
Finds a dictionary (a set of atoms) that performs well at sparsely encoding the fitted data.
Solves the optimization problem:
Constructors
new DictionaryLearning()
new DictionaryLearning(
opts
?):DictionaryLearning
Parameters
Parameter | Type | Description |
---|---|---|
opts ? | object | - |
opts.alpha ? | number | Sparsity controlling parameter. |
opts.callback ? | any | Callable 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 ? | number | Maximum number of iterations to perform. |
opts.n_components ? | number | Number of dictionary elements to extract. If undefined , then n_components is set to n_features . |
opts.n_jobs ? | number | 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.positive_code ? | boolean | Whether to enforce positivity when finding the code. |
opts.positive_dict ? | boolean | Whether to enforce positivity when finding the dictionary. |
opts.random_state ? | number | Used 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 ? | boolean | Whether 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 ? | number | Tolerance for numerical error. |
opts.transform_algorithm ? | "threshold" | "lars" | "lasso_lars" | "lasso_cd" | "omp" | Algorithm used to transform the data: |
opts.transform_alpha ? | number | If 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 ? | number | Maximum number of iterations to perform if algorithm='lasso_cd' or 'lasso_lars' . |
opts.transform_n_nonzero_coefs ? | number | Number 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 ? | boolean | To control the verbosity of the procedure. |
Returns DictionaryLearning
Defined in generated/decomposition/DictionaryLearning.ts:25
Properties
Property | Type | Default value | Defined in |
---|---|---|---|
_isDisposed | boolean | false | generated/decomposition/DictionaryLearning.ts:23 |
_isInitialized | boolean | false | generated/decomposition/DictionaryLearning.ts:22 |
_py | PythonBridge | undefined | generated/decomposition/DictionaryLearning.ts:21 |
id | string | undefined | generated/decomposition/DictionaryLearning.ts:18 |
opts | any | undefined | generated/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
Parameter | Type |
---|---|
pythonBridge | PythonBridge |
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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike [] | Training vector, where n_samples is the number of samples and n_features is the number of features. |
opts.y ? | any | Not 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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike [] | Training vector, where n_samples is the number of samples and n_features is the number of features. |
opts.y ? | any | Not 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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.input_features ? | any | Only 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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.routing ? | any | A 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
Parameter | Type |
---|---|
py | PythonBridge |
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
Parameter | Type | Description |
---|---|---|
opts | object | - |
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
Parameter | Type | Description |
---|---|---|
opts | object | - |
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