Class: SparseCoder
Sparse coding.
Finds a sparse representation of data against a fixed, precomputed dictionary.
Each row of the result is the solution to a sparse coding problem. The goal is to find a sparse array code
such that:
Constructors
new SparseCoder()
new SparseCoder(
opts
?):SparseCoder
Parameters
Parameter | Type | Description |
---|---|---|
opts ? | object | - |
opts.dictionary ? | ArrayLike [] | The dictionary atoms used for sparse coding. Lines are assumed to be normalized to unit norm. |
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.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.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 algorithm='omp' , alpha is the tolerance parameter: the value of the reconstruction error targeted. In this case, it overrides n_nonzero_coefs . If undefined , default to 1. |
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' and is overridden by alpha in the omp case. If undefined , then transform_n_nonzero_coefs=int(n_features / 10) . |
Returns SparseCoder
Defined in generated/decomposition/SparseCoder.ts:25
Properties
Property | Type | Default value | Defined in |
---|---|---|---|
_isDisposed | boolean | false | generated/decomposition/SparseCoder.ts:23 |
_isInitialized | boolean | false | generated/decomposition/SparseCoder.ts:22 |
_py | PythonBridge | undefined | generated/decomposition/SparseCoder.ts:21 |
id | string | undefined | generated/decomposition/SparseCoder.ts:18 |
opts | any | undefined | generated/decomposition/SparseCoder.ts:19 |
Accessors
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/SparseCoder.ts:380
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/SparseCoder.ts:83
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/SparseCoder.ts:135
fit()
fit(
opts
):Promise
<any
>
Do nothing and return the estimator unchanged.
This method is just there to implement the usual API and hence work in pipelines.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | any | Not used, present for API consistency by convention. |
opts.y ? | any | Not used, present for API consistency by convention. |
Returns Promise
<any
>
Defined in generated/decomposition/SparseCoder.ts:154
fit_transform()
fit_transform(
opts
):Promise
<any
[]>
Fit to data, then transform it.
Fits transformer to X
and y
with optional parameters fit_params
and returns a transformed version of X
.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.fit_params ? | any | Additional fit parameters. |
opts.X ? | ArrayLike [] | Input samples. |
opts.y ? | ArrayLike | Target values (undefined for unsupervised transformations). |
Returns Promise
<any
[]>
Defined in generated/decomposition/SparseCoder.ts:193
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/SparseCoder.ts:237
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/SparseCoder.ts:273
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/SparseCoder.ts:96
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/SparseCoder.ts:309
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 [] | 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/SparseCoder.ts:343