Gaussian Naive Bayes (GaussianNB).
Can perform online updates to model parameters via partial\_fit
. For details on algorithm used to update feature means and variance online, see Stanford CS tech report STAN-CS-79-773 by Chan, Golub, and LeVeque:
new GaussianNB(opts?: object): GaussianNB;
Name | Type | Description |
---|---|---|
opts? |
object |
- |
opts.priors? |
ArrayLike |
Prior probabilities of the classes. If specified, the priors are not adjusted according to the data. |
opts.var_smoothing? |
number |
Portion of the largest variance of all features that is added to variances for calculation stability. Default Value 1e-9 |
Defined in: generated/naive_bayes/GaussianNB.ts:23
Disposes of the underlying Python resources.
Once dispose()
is called, the instance is no longer usable.
dispose(): Promise<void>;
Promise
<void
>
Defined in: generated/naive_bayes/GaussianNB.ts:95
Fit Gaussian Naive Bayes according to X, y.
fit(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.X? |
ArrayLike [] |
Training vectors, where n\_samples is the number of samples and n\_features is the number of features. |
opts.sample_weight? |
ArrayLike |
Weights applied to individual samples (1. for unweighted). |
opts.y? |
ArrayLike |
Target values. |
Promise
<any
>
Defined in: generated/naive_bayes/GaussianNB.ts:112
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
get_metadata_routing(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.routing? |
any |
A MetadataRequest encapsulating routing information. |
Promise
<any
>
Defined in: generated/naive_bayes/GaussianNB.ts:161
Initializes the underlying Python resources.
This instance is not usable until the Promise
returned by init()
resolves.
init(py: PythonBridge): Promise<void>;
Name | Type |
---|---|
py |
PythonBridge |
Promise
<void
>
Defined in: generated/naive_bayes/GaussianNB.ts:53
Incremental fit on a batch of samples.
This method is expected to be called several times consecutively on different chunks of a dataset so as to implement out-of-core or online learning.
This is especially useful when the whole dataset is too big to fit in memory at once.
This method has some performance and numerical stability overhead, hence it is better to call partial_fit on chunks of data that are as large as possible (as long as fitting in the memory budget) to hide the overhead.
partial_fit(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.X? |
ArrayLike [] |
Training vectors, where n\_samples is the number of samples and n\_features is the number of features. |
opts.classes? |
ArrayLike |
List of all the classes that can possibly appear in the y vector. Must be provided at the first call to partial_fit, can be omitted in subsequent calls. |
opts.sample_weight? |
ArrayLike |
Weights applied to individual samples (1. for unweighted). |
opts.y? |
ArrayLike |
Target values. |
Promise
<any
>
Defined in: generated/naive_bayes/GaussianNB.ts:202
Perform classification on an array of test vectors X.
predict(opts: object): Promise<ArrayLike>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.X? |
ArrayLike [] |
The input samples. |
Promise
<ArrayLike
>
Defined in: generated/naive_bayes/GaussianNB.ts:260
Return joint log probability estimates for the test vector X.
For each row x of X and class y, the joint log probability is given by log P(x, y) \= log P(y) + log P(x|y),
where log P(y)
is the class prior probability and log P(x|y)
is the class-conditional probability.
predict_joint_log_proba(opts: object): Promise<ArrayLike[]>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.X? |
ArrayLike [] |
The input samples. |
Promise
<ArrayLike
[]>
Defined in: generated/naive_bayes/GaussianNB.ts:295
Return log-probability estimates for the test vector X.
predict_log_proba(opts: object): Promise<ArrayLike[]>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.X? |
ArrayLike [] |
The input samples. |
Promise
<ArrayLike
[]>
Defined in: generated/naive_bayes/GaussianNB.ts:330
Return probability estimates for the test vector X.
predict_proba(opts: object): Promise<ArrayLike[]>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.X? |
ArrayLike [] |
The input samples. |
Promise
<ArrayLike
[]>
Defined in: generated/naive_bayes/GaussianNB.ts:363
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.
score(opts: object): Promise<number>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.X? |
ArrayLike [] |
Test samples. |
opts.sample_weight? |
ArrayLike |
Sample weights. |
opts.y? |
ArrayLike |
True labels for X . |
Promise
<number
>
Defined in: generated/naive_bayes/GaussianNB.ts:398
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:
set_fit_request(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.sample_weight? |
string | boolean |
Metadata routing for sample\_weight parameter in fit . |
Promise
<any
>
Defined in: generated/naive_bayes/GaussianNB.ts:449
Request metadata passed to the partial\_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:
set_partial_fit_request(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.classes? |
string | boolean |
Metadata routing for classes parameter in partial\_fit . |
opts.sample_weight? |
string | boolean |
Metadata routing for sample\_weight parameter in partial\_fit . |
Promise
<any
>
Defined in: generated/naive_bayes/GaussianNB.ts:486
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:
set_score_request(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.sample_weight? |
string | boolean |
Metadata routing for sample\_weight parameter in score . |
Promise
<any
>
Defined in: generated/naive_bayes/GaussianNB.ts:530
boolean
=false
Defined in: generated/naive_bayes/GaussianNB.ts:21
boolean
=false
Defined in: generated/naive_bayes/GaussianNB.ts:20
PythonBridge
Defined in: generated/naive_bayes/GaussianNB.ts:19
string
Defined in: generated/naive_bayes/GaussianNB.ts:16
any
Defined in: generated/naive_bayes/GaussianNB.ts:17
number of training samples observed in each class.
class_count_(): Promise<ArrayLike>;
Promise
<ArrayLike
>
Defined in: generated/naive_bayes/GaussianNB.ts:563
probability of each class.
class_prior_(): Promise<ArrayLike>;
Promise
<ArrayLike
>
Defined in: generated/naive_bayes/GaussianNB.ts:588
class labels known to the classifier.
classes_(): Promise<ArrayLike>;
Promise
<ArrayLike
>
Defined in: generated/naive_bayes/GaussianNB.ts:613
absolute additive value to variances.
epsilon_(): Promise<number>;
Promise
<number
>
Defined in: generated/naive_bayes/GaussianNB.ts:636
Names of features seen during fit. Defined only when X
has feature names that are all strings.
feature_names_in_(): Promise<ArrayLike>;
Promise
<ArrayLike
>
Defined in: generated/naive_bayes/GaussianNB.ts:684
Number of features seen during fit.
n_features_in_(): Promise<number>;
Promise
<number
>
Defined in: generated/naive_bayes/GaussianNB.ts:659
py(): PythonBridge;
PythonBridge
Defined in: generated/naive_bayes/GaussianNB.ts:40
py(pythonBridge: PythonBridge): void;
Name | Type |
---|---|
pythonBridge |
PythonBridge |
void
Defined in: generated/naive_bayes/GaussianNB.ts:44
mean of each feature per class.
theta_(): Promise<ArrayLike[]>;
Promise
<ArrayLike
[]>
Defined in: generated/naive_bayes/GaussianNB.ts:732
Variance of each feature per class.
var_(): Promise<ArrayLike[]>;
Promise
<ArrayLike
[]>
Defined in: generated/naive_bayes/GaussianNB.ts:709