Class: 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.
Constructors
new DummyClassifier()
new DummyClassifier(
opts
?):DummyClassifier
Parameters
Parameter | 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. |
Returns DummyClassifier
Defined in generated/dummy/DummyClassifier.ts:31
Properties
Property | Type | Default value | Defined in |
---|---|---|---|
_isDisposed | boolean | false | generated/dummy/DummyClassifier.ts:29 |
_isInitialized | boolean | false | generated/dummy/DummyClassifier.ts:28 |
_py | PythonBridge | undefined | generated/dummy/DummyClassifier.ts:27 |
id | string | undefined | generated/dummy/DummyClassifier.ts:24 |
opts | any | undefined | generated/dummy/DummyClassifier.ts:25 |
Accessors
class_prior_
Get Signature
get class_prior_():
Promise
<ArrayLike
>
Frequency of each class observed in y
. For multioutput classification problems, this is computed independently for each output.
Returns Promise
<ArrayLike
>
Defined in generated/dummy/DummyClassifier.ts:468
classes_
Get Signature
get classes_():
Promise
<ArrayLike
>
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.
Returns Promise
<ArrayLike
>
Defined in generated/dummy/DummyClassifier.ts:418
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/dummy/DummyClassifier.ts:518
n_classes_
Get Signature
get n_classes_():
Promise
<number
>
Number of label for each output.
Returns Promise
<number
>
Defined in generated/dummy/DummyClassifier.ts:443
n_features_in_
Get Signature
get n_features_in_():
Promise
<number
>
Number of features seen during fit.
Returns Promise
<number
>
Defined in generated/dummy/DummyClassifier.ts:493
n_outputs_
Get Signature
get n_outputs_():
Promise
<number
>
Number of outputs.
Returns Promise
<number
>
Defined in generated/dummy/DummyClassifier.ts:543
py
Get Signature
get py():
PythonBridge
Returns PythonBridge
Set Signature
set py(
pythonBridge
):void
Parameters
Parameter | Type |
---|---|
pythonBridge | PythonBridge |
Returns void
Defined in generated/dummy/DummyClassifier.ts:53
sparse_output_
Get Signature
get sparse_output_():
Promise
<boolean
>
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.
Returns Promise
<boolean
>
Defined in generated/dummy/DummyClassifier.ts:568
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/dummy/DummyClassifier.ts:105
fit()
fit(
opts
):Promise
<any
>
Fit the baseline classifier.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | ArrayLike | Sample weights. |
opts.X ? | ArrayLike [] | Training data. |
opts.y ? | ArrayLike | Target values. |
Returns Promise
<any
>
Defined in generated/dummy/DummyClassifier.ts:122
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/dummy/DummyClassifier.ts:166
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/dummy/DummyClassifier.ts:66
predict()
predict(
opts
):Promise
<ArrayLike
>
Perform classification on test vectors X.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike [] | Test data. |
Returns Promise
<ArrayLike
>
Defined in generated/dummy/DummyClassifier.ts:200
predict_log_proba()
predict_log_proba(
opts
):Promise
<ArrayLike
[]>
Return log probability estimates for the test vectors X.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | any | Training data. |
Returns Promise
<ArrayLike
[]>
Defined in generated/dummy/DummyClassifier.ts:232
predict_proba()
predict_proba(
opts
):Promise
<ArrayLike
[]>
Return probability estimates for the test vectors X.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike [] | Test data. |
Returns Promise
<ArrayLike
[]>
Defined in generated/dummy/DummyClassifier.ts:266
score()
score(
opts
):Promise
<number
>
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.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | ArrayLike | Sample weights. |
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.y ? | ArrayLike | True labels for X. |
Returns Promise
<number
>
Defined in generated/dummy/DummyClassifier.ts:300
set_fit_request()
set_fit_request(
opts
):Promise
<any
>
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:
Parameters
Parameter | 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:346
set_score_request()
set_score_request(
opts
):Promise
<any
>
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:
Parameters
Parameter | 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:384