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
Name | Type | Description |
---|---|---|
opts? | object | - |
opts.constant? | string | number | ArrayLike | The explicit constant as predicted by the “constant” strategy. This parameter is useful only for the “constant” strategy. |
opts.random_state? | number | Controls 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
Defined in: generated/dummy/DummyClassifier.ts:31 (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
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike [] | Training data. |
opts.sample_weight? | ArrayLike | Sample weights. |
opts.y? | ArrayLike | Target values. |
Returns
Promise
<any
>
Defined in: generated/dummy/DummyClassifier.ts:127 (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
Name | Type | Description |
---|---|---|
opts | object | - |
opts.routing? | any | A MetadataRequest encapsulating routing information. |
Returns
Promise
<any
>
Defined in: generated/dummy/DummyClassifier.ts:176 (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
Name | Type |
---|---|
py | PythonBridge |
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
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike [] | Test data. |
Returns
Promise
<ArrayLike
>
Defined in: generated/dummy/DummyClassifier.ts:211 (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
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | any | Training data. |
Returns
Promise
<ArrayLike
[]>
Defined in: generated/dummy/DummyClassifier.ts:244 (opens in a new tab)
predict_proba()
Return probability estimates for the test vectors X.
Signature
predict_proba(opts: object): Promise<ArrayLike[]>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike [] | Test data. |
Returns
Promise
<ArrayLike
[]>
Defined in: generated/dummy/DummyClassifier.ts:279 (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
Name | Type | Description |
---|---|---|
opts | object | - |
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? | ArrayLike | Sample weights. |
opts.y? | ArrayLike | True labels for X. |
Returns
Promise
<number
>
Defined in: generated/dummy/DummyClassifier.ts:314 (opens in a new tab)
set_fit_request()
Request metadata passed to the fit
method.
Note that this method is only relevant if enable\_metadata\_routing=True
(see sklearn.set\_config
). Please see User Guide on how the routing mechanism works.
The options for each parameter are:
Signature
set_fit_request(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight? | string | boolean | Metadata routing for sample\_weight parameter in fit . |
Returns
Promise
<any
>
Defined in: generated/dummy/DummyClassifier.ts:365 (opens in a new tab)
set_score_request()
Request metadata passed to the score
method.
Note that this method is only relevant if enable\_metadata\_routing=True
(see sklearn.set\_config
). Please see User Guide on how the routing mechanism works.
The options for each parameter are:
Signature
set_score_request(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight? | string | boolean | Metadata routing for sample\_weight parameter in score . |
Returns
Promise
<any
>
Defined in: generated/dummy/DummyClassifier.ts:404 (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:490 (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:440 (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:465 (opens in a new tab)
n_outputs_
Number of outputs.
Signature
n_outputs_(): Promise<number>;
Returns
Promise
<number
>
Defined in: generated/dummy/DummyClassifier.ts:515 (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
Name | Type |
---|---|
pythonBridge | PythonBridge |
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:540 (opens in a new tab)