What are the metrics through which we can evaluate a regression model in keras?
MACHINE LEARNING RECIPES DATA CLEANING PYTHON DATA MUNGING PANDAS CHEATSHEET     ALL TAGS

What are the metrics through which we can evaluate a regression model in keras?

What are the metrics through which we can evaluate a regression model in keras?

This recipe explains what are the metrics through which we can evaluate a regression model in keras

0

Recipe Objective

The metrics through which we can evaluate a regression model in keras Keras Have provided us many ways to evaluate the Regression and Classification model when we train a deep Learning Model. But our focus is to evaluate a Regression Model

Certain types of Metrics can be used for regression Models: Mean Squared Error Mean Absolute Error Mean Absolute Percentage Error Cosine Proximity We will show you the implementation of all Metrics and visualize the Mean Squared Error and Mean Absolute Error.

Step 1- Importing Libraries

from numpy import array from keras.models import Sequential from keras.layers import Dense from matplotlib import pyplot

Step 2- Creating arrays

We will Define two Arrays Let's consider y_pred is our predicted array and y_actual is our actual array.

# prepare sequence y_pred = array([0.4, 0.6, 0.8, 1.0, 0.5, 0.4, 0.3, 0.2, 0.1, 0.8]) y_actual = array([-0.4, -0.3, 0.8, 0.9, 0, 1.2, 0.3, 2.4, 0.3, 0.3])

Step 3- We will add layers and other parameters to create our model.

We will define all the Metrics while compiling the model as you can see below.

# create model model = Sequential() model.add(Dense(2, input_dim=1)) model.add(Dense(1, activation='sigmoid')) model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['mse', 'mae','mape', 'cosine_proximity'])

Step 4- Training our model

We will train our model with the defined parameters

# train model history = model.fit(y_pred, y_actual, epochs=50, batch_size=len(y_pred), verbose=2)

Step 5- We will plot our models (MSE and MAE)

# plot metrics pyplot.plot(history.history['mse']) pyplot.plot(history.history['mae']) pyplot.show()

Relevant Projects

Zillow’s Home Value Prediction (Zestimate)
Data Science Project in R -Build a machine learning algorithm to predict the future sale prices of homes.

Predict Employee Computer Access Needs in Python
Data Science Project in Python- Given his or her job role, predict employee access needs using amazon employee database.

Data Science Project in Python on BigMart Sales Prediction
The goal of this data science project is to build a predictive model and find out the sales of each product at a given Big Mart store.

PySpark Tutorial - Learn to use Apache Spark with Python
PySpark Project-Get a handle on using Python with Spark through this hands-on data processing spark python tutorial.

Machine Learning or Predictive Models in IoT - Energy Prediction Use Case
In this machine learning and IoT project, we are going to test out the experimental data using various predictive models and train the models and break the energy usage.

Credit Card Fraud Detection as a Classification Problem
In this data science project, we will predict the credit card fraud in the transactional dataset using some of the predictive models.

Natural language processing Chatbot application using NLTK for text classification
In this NLP AI application, we build the core conversational engine for a chatbot. We use the popular NLTK text classification library to achieve this.

Ensemble Machine Learning Project - All State Insurance Claims Severity Prediction
In this ensemble machine learning project, we will predict what kind of claims an insurance company will get. This is implemented in python using ensemble machine learning algorithms.

Solving Multiple Classification use cases Using H2O
In this project, we are going to talk about H2O and functionality in terms of building Machine Learning models.

Walmart Sales Forecasting Data Science Project
Data Science Project in R-Predict the sales for each department using historical markdown data from the Walmart dataset containing data of 45 Walmart stores.