Python scikit-learn 中的“fit”方法有什么作用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45704226/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does "fit" method in scikit-learn do?
提问by Pearapon Joe
Could you please explain what the "fit" method in scikit-learn does? Why is it useful?
你能解释一下 scikit-learn 中的“fit”方法是做什么的吗?为什么有用?
I am new in Machine Learning and scikit-learn.
我是机器学习和 scikit-learn 的新手。
回答by Kevin Glynn
In a nutshell: fittingis equal to training. Then, after it is trained, the model can be used to make predictions, usually with a .predict()
method call.
简而言之:拟合等于训练。然后,经过训练后,模型可以用于进行预测,通常是通过一个.predict()
方法调用。
To elaborate: Fitting your model to (i.e. using the .fit()
method on) the training data is essentially the training part of the modeling process. It finds the coefficients for the equation specified via the algorithm being used (take for example umutto'slinear regression example, above).
详细说明:将模型拟合(即使用该.fit()
方法)训练数据本质上是建模过程的训练部分。它通过正在使用的算法找到指定方程的系数(例如上面的 umutto 的线性回归示例)。
Then, for a classifier, you can classify incoming data points (from a test set, or otherwise) using the predict
method. Or, in the case of regression, your model will interpolate/extrapolate when predict
is used on incoming data points.
然后,对于分类器,您可以使用该predict
方法对传入数据点(来自测试集或其他)进行分类。或者,在回归的情况下,您的模型将在predict
用于传入数据点时进行插值/外推。
It also should be noted that sometimes the "fit" nomenclature is used for non-machine-learning methods, such as scalers and other preprocessing steps. In this case, you are merely "applying" the specified function to your data, as in the case with a min-max scaler, TF-IDF, or other transformation.
还应该注意的是,有时“拟合”命名法用于非机器学习方法,例如缩放器和其他预处理步骤。在这种情况下,您只是将指定的函数“应用”到您的数据,就像使用最小-最大缩放器、TF-IDF 或其他转换的情况一样。
Note: here are a couple of references...
注意:这里有几个参考...