Professional Documents
Culture Documents
Ass2 PDF
Ass2 PDF
Ass2 PDF
In [20]:
import pandas as pd
import numpy as np
from sklearn import linear_model
import matplotlib.pyplot as plt
from word2number import w2n
In [21]:
d = pd.read_csv("hiring.csv")
d
Out[21]:
In [22]:
d.head(210)
Out[22]:
In [23]:
d.experience = d.experience.fillna("zero")
d
Out[23]:
In [24]:
d.experience = d.experience.apply(w2n.word_to_num)
d
Out[24]:
0 0 8.0 9 50000
1 0 8.0 6 45000
2 5 6.0 7 60000
3 2 10.0 10 65000
4 7 9.0 6 70000
5 3 7.0 10 62000
6 10 NaN 7 72000
7 11 7.0 8 80000
In [25]:
import math
median_test_score = math.floor(d['test_score(out of 10)'].mean())
median_test_score
Out[25]:
In [26]:
0 0 8.0 9 50000
1 0 8.0 6 45000
2 5 6.0 7 60000
3 2 10.0 10 65000
4 7 9.0 6 70000
5 3 7.0 10 62000
6 10 7.0 7 72000
7 11 7.0 8 80000
In [27]:
In [48]:
fig=plt.figure()
ax=fig.add_subplot(111,projection='3d')
n=100
ax.scatter(d["experience"],d["test_score(out of 10)"],d["salary($)"],color="red")
ax.set_xlabel("experience")
ax.set_ylabel("test_score(out of 10)")
ax.set_zlabel("salary($)")
Out[48]:
Text(0.5, 0, 'salary($)')
In [32]:
train = d[:(int((len(data)*0.8)))]
test = d[(int((len(data)*0.8))):]
In [38]:
reg = linear_model.LinearRegression()
reg.fit(d[['experience','test_score(out of 10)','interview_score(out of 10)']],d['salary
Out[38]:
LinearRegression()
In [40]:
Out[40]:
LinearRegression()
In [43]:
reg.coef_
Out[43]:
array([[-0.05150215]])
In [44]:
reg.intercept_
Out[44]:
array([8.14592275])
In [46]:
ax.scatter(data["experience"],data["test_score(out of 10)"],data["salary($)"],color="red
plt.plot(train_x, reg.coef_*train_x + reg.intercept_, '-r')
ax.set_xlabel("experience")
ax.set_ylabel("test_score(out of 10)")
ax.set_zlabel("salary($)")
Out[46]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]: