DocumentationClassesPolynomialCountSketch

Class: PolynomialCountSketch

Polynomial kernel approximation via Tensor Sketch.

Implements Tensor Sketch, which approximates the feature map of the polynomial kernel:

Python Reference

Constructors

new PolynomialCountSketch()

new PolynomialCountSketch(opts?): PolynomialCountSketch

Parameters

ParameterTypeDescription
opts?object-
opts.coef0?numberConstant term of the polynomial kernel whose feature map will be approximated.
opts.degree?numberDegree of the polynomial kernel whose feature map will be approximated.
opts.gamma?numberParameter of the polynomial kernel whose feature map will be approximated.
opts.n_components?numberDimensionality of the output feature space. Usually, n_components should be greater than the number of features in input samples in order to achieve good performance. The optimal score / run time balance is typically achieved around n_components = 10 * n_features, but this depends on the specific dataset being used.
opts.random_state?numberDetermines random number generation for indexHash and bitHash initialization. Pass an int for reproducible results across multiple function calls. See Glossary.

Returns PolynomialCountSketch

Defined in generated/kernel_approximation/PolynomialCountSketch.ts:23

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/kernel_approximation/PolynomialCountSketch.ts:21
_isInitializedbooleanfalsegenerated/kernel_approximation/PolynomialCountSketch.ts:20
_pyPythonBridgeundefinedgenerated/kernel_approximation/PolynomialCountSketch.ts:19
idstringundefinedgenerated/kernel_approximation/PolynomialCountSketch.ts:16
optsanyundefinedgenerated/kernel_approximation/PolynomialCountSketch.ts:17

Accessors

bitHash_

Get Signature

get bitHash_(): Promise<ArrayLike[]>

Array with random entries in {+1, -1}, used to represent the 2-wise independent hash functions for Count Sketch computation.

Returns Promise<ArrayLike[]>

Defined in generated/kernel_approximation/PolynomialCountSketch.ts:400


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/kernel_approximation/PolynomialCountSketch.ts:454


indexHash_

Get Signature

get indexHash_(): Promise<ArrayLike[]>

Array of indexes in range \0, n_components) used to represent the 2-wise independent hash functions for Count Sketch computation.

Returns Promise<[ArrayLike[]>

Defined in generated/kernel_approximation/PolynomialCountSketch.ts:373


n_features_in_

Get Signature

get n_features_in_(): Promise<number>

Number of features seen during fit.

Returns Promise<number>

Defined in generated/kernel_approximation/PolynomialCountSketch.ts:427


py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/kernel_approximation/PolynomialCountSketch.ts:61

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/kernel_approximation/PolynomialCountSketch.ts:117


fit()

fit(opts): Promise<any>

Fit the model with X.

Initializes the internal variables. The method needs no information about the distribution of data, so we only care about n_features in X.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLikeTraining data, where n_samples is the number of samples and n_features is the number of features.
opts.y?ArrayLikeTarget values (undefined for unsupervised transformations).

Returns Promise<any>

Defined in generated/kernel_approximation/PolynomialCountSketch.ts:136


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

ParameterTypeDescription
optsobject-
opts.fit_params?anyAdditional fit parameters.
opts.X?ArrayLike[]Input samples.
opts.y?ArrayLikeTarget values (undefined for unsupervised transformations).

Returns Promise<any[]>

Defined in generated/kernel_approximation/PolynomialCountSketch.ts:177


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/kernel_approximation/PolynomialCountSketch.ts:225


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/kernel_approximation/PolynomialCountSketch.ts:263


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/kernel_approximation/PolynomialCountSketch.ts:74


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/kernel_approximation/PolynomialCountSketch.ts:301


transform()

transform(opts): Promise<ArrayLike>

Generate the feature map approximation for X.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLikeNew data, where n_samples is the number of samples and n_features is the number of features.

Returns Promise<ArrayLike>

Defined in generated/kernel_approximation/PolynomialCountSketch.ts:337