Data Science Asked on June 3, 2021
There are several possibilites to evaluate a model:
hist = model.fit(x_train, y_train,
(...)
validation_data=(x_test, y_test))
or to use .evaluate()
resp. .predict()
. As far as I know I would use X_test
and y_test
for validation and prediction.
My question: How are they different? When I .fit()
and .evaluate()
afterwards, which information do I gain by .fit(validation_data(...))
?
.fit
--> You can give Train data and Validation data as well so Train data is used for Training and Validation data is used for validating the Trained model at the end of each epoch.
.predict
--> It takes the only X and gives the output of the model.
.evaluate
--> It will take X, Y and will evaluate similar to an above evaluation in .fit
but after training total model we will use this.
You can write
.evaluate = loss_function(.predict, y_true)
score(.predict, y_true)
Answered by Uday on June 3, 2021
As a practice data is divided into 2 parts first, train and test. Now test is kept completely separate and from train further 80 20 split is done as train and validation data.
Now when you fit model, for example say neural network model. For each epoch model will be trained using only and only train data. Test and validation are untouched. But at each epoch you want to know if the model trained is a better than previous or not (based on loss or any other metric you define), for that we evaluate performance on validation data (for this purpose only we give validation data in .fit)
Now as we are using validation data for checking best model, validation data is kind of used in training the model and hence to report final accuracy number of your model you use .predict on test data. Here also you can use .evaluate which returns predicted probability as well as loss contrary to .predict which just returns predicted probability.
Sometimes checking loss is also helpful as it gives sort of idea on how confident the model is in making predictions.
Answered by shivam shah on June 3, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP