-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.py
28 lines (20 loc) · 848 Bytes
/
model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import pickle
dataset = pd.read_csv('hiring.csv')
dataset['experience'].fillna(0, inplace = True)
dataset['test_score'].fillna(dataset['test_score'].mean(), inplace = True)
X = dataset.iloc[:,:3]
def convert_To_Int(word):
word_dict = {'one':'1', 'two':'2', 'three':'3', 'four':'4', 'five':'5', 'six':'6', 'seven':'7',
'eight':'8','nine':'9', 'ten':'10','eleven':'11', 'twelve':'12', 'zero':'0', 0:0}
return word_dict[word]
X['experience'] = X['experience'].apply(lambda x: convert_To_Int(x))
y = dataset.iloc[:, -1]
from sklearn.linear_model import LinearRegression
regressor = LinearRegression()
regressor.fit(X,y)
pickle.dump(regressor, open('model.pkl', 'wb'))
model = pickle.load(open('model.pkl', 'rb'))
print(model.predict([[2,9,6]]))