Python(高斯朴素贝叶斯)中的分类器是什么?

What is a classifier in Python (Gaussian Naive Bayes)?

好的,所以当我使用以下代码时,"clf" 部分到底是什么意思?那是一个变量吗?我知道这是一个分类器,但分类器是 python 中的一个函数,还是只是一个以这种方式命名的变量,或者究竟是什么?我是 python 的新手并且编程很好。 已经谢谢了!


from sklearn.naive_bayes import GaussianNB
clf = GaussianNB()

来自docs

[GNB] can perform online updates to model parameters via partial_fit method

示例:

>>> import numpy as np
>>> X = np.array([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]])
>>> Y = np.array([1, 1, 1, 2, 2, 2])
>>> from sklearn.naive_bayes import GaussianNB
>>> clf = GaussianNB()
>>> clf.fit(X, Y)
GaussianNB(priors=None, var_smoothing=1e-09)
>>> print(clf.predict([[-0.8, -1]]))
[1]
>>> clf_pf = GaussianNB()
>>> clf_pf.partial_fit(X, Y, np.unique(Y))
GaussianNB(priors=None, var_smoothing=1e-09)
>>> print(clf_pf.predict([[-0.8, -1]]))
[1]

有人可能会问什么是分类器?根据Wikipedia,一个分类器是

an algorithm that implements classification, especially in a concrete implementation, is known as a classifier. The term "classifier" sometimes also refers to the mathematical function, implemented by a classification algorithm, that maps input data to a category.