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

Ameeruddin Mohammed

ETL (Abintio) developer at IBM
linkedin profile url

I come from a background in Marketing and Analytics and when I developed an interest in Machine Learning algorithms, I did multiple in-class courses from reputed institutions though I got good... Read More

Relevant Projects

Time Series Python Project using Greykite and Neural Prophet
In this time series project, you will forecast Walmart sales over time using the powerful, fast, and flexible time series forecasting library Greykite that helps automate time series problems.

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

OpenCV Project for Beginners to Learn Computer Vision Basics
In this OpenCV project, you will learn computer vision basics and the fundamentals of OpenCV library using Python.

Linear Regression Model Project in Python for Beginners Part 1
Machine Learning Linear Regression Project in Python to build a simple linear regression model and master the fundamentals of regression for beginners.

Build a Speech-Text Transcriptor with Nvidia Quartznet Model
In this Deep Learning Project, you will leverage transfer learning from Nvidia QuartzNet pre-trained models to develop a speech-to-text transcriptor.

BERT Text Classification using DistilBERT and ALBERT Models
This Project Explains how to perform Text Classification using ALBERT and DistilBERT

Machine Learning project for Retail Price Optimization
In this machine learning pricing project, we implement a retail price optimization algorithm using regression trees. This is one of the first steps to building a dynamic pricing model.

Loan Eligibility Prediction using Gradient Boosting Classifier
This data science in python project predicts if a loan should be given to an applicant or not. We predict if the customer is eligible for loan based on several factors like credit score and past history.

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 .

Customer Churn Prediction Analysis using Ensemble Techniques
In this machine learning churn project, we implement a churn prediction model in python using ensemble techniques.