Python 第三个参数(kwargs)sklearn fit()函数
我对scikit很陌生,我对fit()函数有一个问题。我试图在互联网上寻找信息,但找不到太多。 在赋值中,我必须创建一个传递给分类器fit函数的参数dict,这意味着该函数将接受3个参数(X、y、kwargs)。这本词典应该有哪些参数?显然,这些都是fit函数的超参数。在网上,我只找到xgbooster的信息,但我不应该使用这些信息,只使用sklearn的分类器 我在网上还发现fit可以使用一个名为**fit_params的字典,但函数可能使用的参数没有任何内容Python 第三个参数(kwargs)sklearn fit()函数,python,scikit-learn,Python,Scikit Learn,我对scikit很陌生,我对fit()函数有一个问题。我试图在互联网上寻找信息,但找不到太多。 在赋值中,我必须创建一个传递给分类器fit函数的参数dict,这意味着该函数将接受3个参数(X、y、kwargs)。这本词典应该有哪些参数?显然,这些都是fit函数的超参数。在网上,我只找到xgbooster的信息,但我不应该使用这些信息,只使用sklearn的分类器 我在网上还发现fit可以使用一个名为**fit_params的字典,但函数可能使用的参数没有任何内容 我希望我的问题是清楚的,谢谢大家
我希望我的问题是清楚的,谢谢大家 我以前没有使用过scikit learn,但是您可以使用
\uuuuu doc\uuu
方法获取您不确定的函数的文档。估计器的fit()
方法为其\uuuu doc\uuuu
方法返回此值:
Fit the SVM model according to the given training data.
Parameters
----------
X : {array-like, sparse matrix} of shape (n_samples, n_features) or (n_samples, n_samples)
Training vectors, where n_samples is the number of samples
and n_features is the number of features.
For kernel="precomputed", the expected shape of X is
(n_samples, n_samples).
y : array-like of shape (n_samples,)
Target values (class labels in classification, real numbers in
regression)
sample_weight : array-like of shape (n_samples,), default=None
Per-sample weights. Rescale C per sample. Higher weights
force the classifier to put more emphasis on these points.
Returns
-------
self : object
Notes
-----
If X and y are not C-ordered and contiguous arrays of np.float64 and
X is not a scipy.sparse.csr_matrix, X and/or y may be copied.
If X is a dense array, then the other methods will not support sparse
matrices as input.
我运行此命令以获得该输出:
从sklearn导入svm
clf=svm.SVC(伽马=0.001,C=100。)
打印(clf.fit.\uuuuu文件\uuuuuuuu)
模型超参数不是fit
函数的参数,而是需要事先创建的模型类对象的参数
如果您有一个包含要传递给模型的参数的字典,则需要这样做(这里使用逻辑回归):
现在,您已经创建了指定超参数的模型,您可以继续并使用您的数据对其进行拟合
LR.fit(X, y)
谢谢你提供的信息。我想没有第三个输入,我会尝试使用不同的分类器!谢谢,显然字典是为了传递一些需要为fit函数的分类器指定的参数(主要是sample\u weight,或check\u input…)
LR.fit(X, y)