What is the difference between training the model and fitting the model?

2.9k Views Asked by At

In this book - https://www.oreilly.com/library/view/machine-learning-with/9781491989371/ - I came to the differentiation of these to terms like this:

Train - Applying a learning algorithm to data using numerical approaches like gradient descent. Fit - Applying a learning algorithm to data using analytical approaches.

I don't quite understand the difference.

Can someone please elaborate and/or provide examples? Thank you.

2

There are 2 best solutions below

0
On

As an educated guess, consider a set $\,\{(x_i,y_i)\}\,$ of data points and try to find a good linear model $\,y=mx+b\,$ for the data. The least squares fit approach uses analytical formulas to determine the optimum parameters $\,m,b\,$ in one step.

A general approach is to start with an approximation to the parameters and then use numerical methods such as gradient descent to minimize the difference between the model and the data by adjusting the parameters iteratively.

0
On

In simple words, Train is referring to making a choice of algorithm which you want to train your ML model. Meaning, which algorithm you want to use to train your model to accomplish your task. Here you use your expertise and/or intuition which algorithm might work for you ML model. Example which Regression algorithm you want to use for forecasting sales.

Fit is referring to the step where you train your model using your training data. Here your data is applied to the ML algorithm you chose earlier. This is literally calling a function named Fit in most of the ML libraries where you pass your training data as first parameter and labels/target values as second parameter.

Example python code below is using Support Vector Classification algorithm and calling the fit function to do the actual training.

clf = svm.SVC(kernel=kernel, gamma=10)
clf.fit(X_train, y_train)

In a typical workflow these steps will be followed by evaluation of your model. Depending on results you may tweak parameters of SVC class or change the algorithm and repeat the steps until you get satisfactory results.