What is Mean Square Loss Hinge Loss ROC AUC Score in TF learn explain with example

This recipe explains what is Mean Square Loss Hinge Loss ROC AUC Score in TF learn with example

Recipe Objective

This recipe explains Hinge Loss, ROC AUC Score and ROC AUC Score.

Importing Libraries

We'll import tflearn, tensorflow as tf and tflearn.datasets.mnist as mnist.

import tflearn
import tensorflow as tf
import tflearn.datasets.mnist as mnist
from __future__ import division, print_function, absolute_import

Building Model

We have combined TFLearn built-in ops with Tensorflow graph. We have built this using MNIST Dataset.
To create a multilayer perceptron we have used TFLearn PReLU activations ops.

with tf.Graph().as_default():

    x = tf.placeholder("float", [None, 392])
    y = tf.placeholder("float", [None, 5])

    u = tf.Variable(tf.random_normal([392, 128]))
    v = tf.Variable(tf.random_normal([128, 128]))
    w = tf.Variable(tf.random_normal([128, 5]))
    a = tf.Variable(tf.random_normal([128]))
    b = tf.Variable(tf.random_normal([128]))
    c = tf.Variable(tf.random_normal([5]))

    def net(X):
       X = tflearn.prelu(tf.add(tf.matmul(X, u), a))
       tflearn.summaries.monitor_activation(x)
       X = tflearn.prelu(tf.add(tf.matmul(X, v), b))
       tflearn.summaries.monitor_activation(x)
       X = tf.nn.softmax(tf.add(tf.matmul(X, w), c))
       return X

    my_net = net(x)

Mean Square Loss

Its syntax is: tflearn.objectives.mean_square (y_pred, y_true). Its arguments are y_pred which is prediction and y_true which is targets.

msl = tflearn.mean_square (my_net, Y)

Hinge Loss

Its syntax is: tflearn.objectives.hinge_loss (y_pred, y_true). Its arguments are y_pred which is prediction and y_true which is targets.

hl = tflearn.hinge_loss (my_net, Y)

ROC AUC Score

To evaluate complete performance for a full range of threshold levels we use it.
Its syntax is: tflearn.objectives.roc_auc_score (y_pred, y_true). Its arguments are y_pred which is prediction and y_true which is targets.

score = tflearn.roc_auc_score (my_net, Y)

What Users are saying..

profile image

Anand Kumpatla

Sr Data Scientist @ Doubleslash Software Solutions Pvt Ltd
linkedin profile url

ProjectPro is a unique platform and helps many people in the industry to solve real-life problems with a step-by-step walkthrough of projects. A platform with some fantastic resources to gain... Read More

Relevant Projects

Text Classification with Transformers-RoBERTa and XLNet Model
In this machine learning project, you will learn how to load, fine tune and evaluate various transformer models for text classification tasks.

Build Portfolio Optimization Machine Learning Models in R
Machine Learning Project for Financial Risk Modelling and Portfolio Optimization with R- Build a machine learning model in R to develop a strategy for building a portfolio for maximized returns.

Build a Collaborative Filtering Recommender System in Python
Use the Amazon Reviews/Ratings dataset of 2 Million records to build a recommender system using memory-based collaborative filtering in Python.

Classification Projects on Machine Learning for Beginners - 2
Learn to implement various ensemble techniques to predict license status for a given business.

Deep Learning Project for Beginners with Source Code Part 1
Learn to implement deep neural networks in Python .

Hands-On Approach to Master PyTorch Tensors with Examples
In this deep learning project, you will learn how to perform various operations on the building block of PyTorch : Tensors.

NLP Project to Build a Resume Parser in Python using Spacy
Use the popular Spacy NLP python library for OCR and text classification to build a Resume Parser in Python.

Build CNN for Image Colorization using Deep Transfer Learning
Image Processing Project -Train a model for colorization to make grayscale images colorful using convolutional autoencoders.

Build a Review Classification Model using Gated Recurrent Unit
In this Machine Learning project, you will build a classification model in python to classify the reviews of an app on a scale of 1 to 5 using Gated Recurrent Unit.

Credit Card Default Prediction using Machine learning techniques
In this data science project, you will predict borrowers chance of defaulting on credit loans by building a credit score prediction model.