Python - Dimension Reduction – Hebbian Learning

Data: 

Employees when they sent job applicant (40 rows)

 

Mission: 

How to predict the probability of someone will accepted from given gpa, gmat & work_experience

 

Library used: 

Numpy

Pandas

Scikit

Neupy

 

Code:

import numpy as np

import pandas as pd

 

from sklearn.model_selection import train_test_split

from sklearn.preprocessing import StandardScaler

from sklearn.metrics import accuracy_score

 

!pip install neupy

from neupy import algorithms

 

url = 'https://raw.githubusercontent.com/kokocamp/vlog119/main/vlog119.csv'

vlog136 = pd.read_csv(url)

vlog136.describe()

 

X = vlog136[['gpa','gmat','work_experience']]

y = vlog136['admitted']

X_train, X_test, y_train, y_test = train_test_split(X,y,test_size=0.25,random_state=0)

 

sc = StandardScaler()

X_train = sc.fit_transform(X_train)

X_test = sc.transform(X_test)

 

hebbnet = algorithms.HebbRule(

    n_inputs=3,

    n_outputs=1,

    n_unconditioned=1,

    step=0.1,

    decay_rate=0.2,

    verbose=True

)

hebbnet.train(X_train, epochs=10)

y_pred = hebbnet.predict(X_test)

 

print(y_pred)

 

print('Accuracy : '+str(accuracy_score(y_test, y_pred)))

 

new_candidates = {'gpa': [2,3.7,3.3,2.3,3],

                  'gmat': [590,740,680,610,710],

                  'work_experience': [3,4,6,1,5]

                  }

 

df2 = pd.DataFrame(new_candidates,columns= ['gpa','gmat','work_experience'])

df2 = sc.transform(df2)

y_pred=hebbnet.predict(df2)

 

print (df2)

print (y_pred)

I wrapped the scenario in a Youtube video below.


 

Click this link (http://paparadit.blogspot.com/2020/11/the-algorithms-of-machine-learning.html), if you want to check out for other algorithms. Thank you for for visiting this blog & subs my channel.

Labels: ,


PS: If you've benefit from this blog,
you can support it by making a small contribution.

Enter your email address to receive feed update from this blog:

Post a Comment

 

Post a Comment

Leave comments here...