How to make an Averaged Perceptron using Shogun?

This recipe helps you to make an Averaged Perceptron using Shogun.

Recipe Objective

This recipe explains how to make an Averaged Perceptron using Shogun.
For more related projects-
Project 1
Project 2

Learn to Implement Customer Churn Prediction Using Machine Learning in Python

Averaged Perceptron

The averaged Perceptron uses the averaged weight and bias. It is an online binary classifier which is an extension of the standard Perceptron algorithm. Given a vector, a predicted class is given by:
f(weight. a + bias)
Here, weight is the average weight vector, bias is the average bias and f() is a step function where step function is equal to 1 for 'a' greater than 0, equal to -1 for 'a' less than 0, and equal to zero for 'a' equal to zero.

x_train = RealFeatures(feats_train)
x_test = RealFeatures(feats_test)
y_train = BinaryLabels(labels_train)
y_test = BinaryLabels(labels_test)

lr = 1.0
maxx = 1000
perceptron = AveragedPerceptron(x_train, y_train)
perceptron.set_learn_rate(y_rate)
perceptron.set_max_iter(maxx)

perceptron.train()
perceptron.set_features(x_test)
predict = perceptron.apply()

eval = AccuracyMeasure()
accuracy = eval.evaluate(predict, y_test)

What Users are saying..

profile image

Savvy Sahai

Data Science Intern, Capgemini
linkedin profile url

As a student looking to break into the field of data engineering and data science, one can get really confused as to which path to take. Very few ways to do it are Google, YouTube, etc. I was one of... Read More

Relevant Projects

Recommender System Machine Learning Project for Beginners-4
Collaborative Filtering Recommender System Project - Comparison of different model based and memory based methods to build recommendation system using collaborative filtering.

MLOps Project on GCP using Kubeflow for Model Deployment
MLOps using Kubeflow on GCP - Build and deploy a deep learning model on Google Cloud Platform using Kubeflow pipelines in Python

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 a Graph Based Recommendation System in Python -Part 1
Python Recommender Systems Project - Learn to build a graph based recommendation system in eCommerce to recommend products.

ML Model Deployment on AWS for Customer Churn Prediction
MLOps Project-Deploy Machine Learning Model to Production Python on AWS for Customer Churn Prediction

Learn to Build a Neural network from Scratch using NumPy
In this deep learning project, you will learn to build a neural network from scratch using NumPy

MLOps Project to Deploy Resume Parser Model on Paperspace
In this MLOps project, you will learn how to deploy a Resume Parser Streamlit Application on Paperspace Private Cloud.

PyTorch Project to Build a LSTM Text Classification Model
In this PyTorch Project you will learn how to build an LSTM Text Classification model for Classifying the Reviews of an App .

Build a Multi ClassText Classification Model using Naive Bayes
Implement the Naive Bayes Algorithm to build a multi class text classification model in Python.

Build a Credit Default Risk Prediction Model with LightGBM
In this Machine Learning Project, you will build a classification model for default prediction with LightGBM.