Documentation
Classes
PolynomialCountSketch

PolynomialCountSketch

Polynomial kernel approximation via Tensor Sketch.

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

Python Reference (opens in a new tab)

Constructors

constructor()

Signature

new PolynomialCountSketch(opts?: object): PolynomialCountSketch;

Parameters

NameTypeDescription
opts?object-
opts.coef0?numberConstant term of the polynomial kernel whose feature map will be approximated. Default Value 0
opts.degree?numberDegree of the polynomial kernel whose feature map will be approximated. Default Value 2
opts.gamma?numberParameter of the polynomial kernel whose feature map will be approximated. Default Value 1
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. Default Value 100
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 (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/kernel_approximation/PolynomialCountSketch.ts:122 (opens in a new tab)

fit()

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.

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 values (undefined for unsupervised transformations).

Returns

Promise<any>

Defined in: generated/kernel_approximation/PolynomialCountSketch.ts:141 (opens in a new tab)

fit_transform()

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit\_params and returns a transformed version of X.

Signature

fit_transform(opts: object): Promise<any[]>;

Parameters

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

Returns

Promise<any[]>

Defined in: generated/kernel_approximation/PolynomialCountSketch.ts:185 (opens in a new tab)

get_feature_names_out()

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"\].

Signature

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

Parameters

NameTypeDescription
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:239 (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/kernel_approximation/PolynomialCountSketch.ts:279 (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/kernel_approximation/PolynomialCountSketch.ts:74 (opens in a new tab)

set_output()

Set output container.

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

Signature

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

Parameters

NameTypeDescription
optsobject-
opts.transform?"default" | "pandas"Configure output of transform and fit\_transform.

Returns

Promise<any>

Defined in: generated/kernel_approximation/PolynomialCountSketch.ts:319 (opens in a new tab)

transform()

Generate the feature map approximation for X.

Signature

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

Parameters

NameTypeDescription
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:356 (opens in a new tab)

Properties

_isDisposed

boolean = false

Defined in: generated/kernel_approximation/PolynomialCountSketch.ts:21 (opens in a new tab)

_isInitialized

boolean = false

Defined in: generated/kernel_approximation/PolynomialCountSketch.ts:20 (opens in a new tab)

_py

PythonBridge

Defined in: generated/kernel_approximation/PolynomialCountSketch.ts:19 (opens in a new tab)

id

string

Defined in: generated/kernel_approximation/PolynomialCountSketch.ts:16 (opens in a new tab)

opts

any

Defined in: generated/kernel_approximation/PolynomialCountSketch.ts:17 (opens in a new tab)

Accessors

bitHash_

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

Signature

bitHash_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/kernel_approximation/PolynomialCountSketch.ts:420 (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/kernel_approximation/PolynomialCountSketch.ts:474 (opens in a new tab)

indexHash_

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

Signature

indexHash_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/kernel_approximation/PolynomialCountSketch.ts:393 (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/kernel_approximation/PolynomialCountSketch.ts:447 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/kernel_approximation/PolynomialCountSketch.ts:61 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/kernel_approximation/PolynomialCountSketch.ts:65 (opens in a new tab)