Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the "fit" method in scikit-learn do? [closed]

Could you please explain what the "fit" method in scikit-learn does? Why is it useful?

like image 616
Pearapon Joe Avatar asked Aug 16 '17 02:08

Pearapon Joe


People also ask

How does fit () work in Python?

fit() is implemented by every estimator and it accepts an input for the sample data ( X ) and for supervised models it also accepts an argument for labels (i.e. target data y ). Optionally, it can also accept additional sample properties such as weights etc.

What does model fit () do?

Model fitting is the measure of how well a machine learning model generalizes data similar to that with which it was trained. A good model fit refers to a model that accurately approximates the output when it is provided with unseen inputs. Fitting refers to adjusting the parameters in the model to improve accuracy.

What does fit () do in regression?

Use Fit Regression Model to describe the relationship between a set of predictors and a continuous response using the ordinary least squares method. You can include interaction and polynomial terms, perform stepwise regression, and transform skewed data.

What is model fit () in Python?

model. fit() : fit training data. For supervised learning applications, this accepts two arguments: the data X and the labels y (e.g. model. fit(X, y) ). For unsupervised learning applications, this accepts only a single argument, the data X (e.g. model.


1 Answers

In a nutshell: fitting is equal to training. Then, after it is trained, the model can be used to make predictions, usually with a .predict() method call.

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's linear regression example, above).

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.

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.

Note: here are a couple of references...

  • fit method in python sklearn
  • http://scikit-learn.org/stable/tutorial/basic/tutorial.html
like image 110
Kevin Glynn Avatar answered Oct 01 '22 11:10

Kevin Glynn