Documentation
Classes
DummyClassifier

DummyClassifier

DummyClassifier makes predictions that ignore the input features.

This classifier serves as a simple baseline to compare against other more complex classifiers.

The specific behavior of the baseline is selected with the strategy parameter.

All strategies make predictions that ignore the input feature values passed as the X argument to fit and predict. The predictions, however, typically depend on values observed in the y parameter passed to fit.

Note that the “stratified” and “uniform” strategies lead to non-deterministic predictions that can be rendered deterministic by setting the random\_state parameter if needed. The other strategies are naturally deterministic and, once fit, always return the same constant prediction for any value of X.

Read more in the User Guide.

Python Reference (opens in a new tab)

Constructors

constructor()

Signature

new DummyClassifier(opts?: object): DummyClassifier;

Parameters

NameTypeDescription
opts?object-
opts.constant?string | number | ArrayLikeThe explicit constant as predicted by the “constant” strategy. This parameter is useful only for the “constant” strategy.
opts.random_state?numberControls the randomness to generate the predictions when strategy='stratified' or strategy='uniform'. Pass an int for reproducible output across multiple function calls. See Glossary.
opts.strategy?"uniform" | "most_frequent" | "prior" | "stratified" | "constant"Strategy to use to generate predictions. Default Value 'prior'

Returns

DummyClassifier

Defined in: generated/dummy/DummyClassifier.ts:31 (opens in a new tab)

Properties

_isDisposed

boolean = false

Defined in: generated/dummy/DummyClassifier.ts:29 (opens in a new tab)

_isInitialized

boolean = false

Defined in: generated/dummy/DummyClassifier.ts:28 (opens in a new tab)

_py

PythonBridge

Defined in: generated/dummy/DummyClassifier.ts:27 (opens in a new tab)

id

string

Defined in: generated/dummy/DummyClassifier.ts:24 (opens in a new tab)

opts

any

Defined in: generated/dummy/DummyClassifier.ts:25 (opens in a new tab)

Accessors

class_prior_

Frequency of each class observed in y. For multioutput classification problems, this is computed independently for each output.

Signature

class_prior_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/dummy/DummyClassifier.ts:374 (opens in a new tab)

classes_

Unique class labels observed in y. For multi-output classification problems, this attribute is a list of arrays as each output has an independent set of possible classes.

Signature

classes_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/dummy/DummyClassifier.ts:324 (opens in a new tab)

n_classes_

Number of label for each output.

Signature

n_classes_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/dummy/DummyClassifier.ts:349 (opens in a new tab)

n_outputs_

Number of outputs.

Signature

n_outputs_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/dummy/DummyClassifier.ts:399 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/dummy/DummyClassifier.ts:53 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/dummy/DummyClassifier.ts:57 (opens in a new tab)

sparse_output_

True if the array returned from predict is to be in sparse CSC format. Is automatically set to true if the input y is passed in sparse format.

Signature

sparse_output_(): Promise<boolean>;

Returns

Promise<boolean>

Defined in: generated/dummy/DummyClassifier.ts:424 (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/dummy/DummyClassifier.ts:110 (opens in a new tab)

fit()

Fit the baseline classifier.

Signature

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

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]Training data.
opts.sample_weight?ArrayLikeSample weights.
opts.y?ArrayLikeTarget values.

Returns

Promise<any>

Defined in: generated/dummy/DummyClassifier.ts:127 (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/dummy/DummyClassifier.ts:66 (opens in a new tab)

predict()

Perform classification on test vectors X.

Signature

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

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]Test data.

Returns

Promise<ArrayLike>

Defined in: generated/dummy/DummyClassifier.ts:174 (opens in a new tab)

predict_log_proba()

Return log probability estimates for the test vectors X.

Signature

predict_log_proba(opts: object): Promise<ArrayLike[]>;

Parameters

NameTypeDescription
optsobject-
opts.X?anyTraining data.

Returns

Promise<ArrayLike[]>

Defined in: generated/dummy/DummyClassifier.ts:207 (opens in a new tab)

predict_proba()

Return probability estimates for the test vectors X.

Signature

predict_proba(opts: object): Promise<ArrayLike[]>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]Test data.

Returns

Promise<ArrayLike[]>

Defined in: generated/dummy/DummyClassifier.ts:242 (opens in a new tab)

score()

Return the mean accuracy on the given test data and labels.

In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.

Signature

score(opts: object): Promise<number>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]Test samples. Passing undefined as test samples gives the same result as passing real test samples, since DummyClassifier operates independently of the sampled observations.
opts.sample_weight?ArrayLikeSample weights.
opts.y?ArrayLikeTrue labels for X.

Returns

Promise<number>

Defined in: generated/dummy/DummyClassifier.ts:277 (opens in a new tab)