-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
116 lines (95 loc) · 3.79 KB
/
main.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import pickle
from sklearn.ensemble import RandomForestRegressor
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error
from sklearn.neighbors import KNeighborsClassifier
from sklearn.model_selection import train_test_split
# from sklearnex.svm import SVC
from sklearn.svm import SVC
data1 = pd.read_csv("Admission_Predict.csv")
data1 = data1.rename(columns={'GRE Score': 'GRE', 'TOEFL Score': 'TOEFL', 'LOR ': 'LOR', 'Chance of Admit ': 'CoA'})
print("---------------------Description of the data sets---------------------\n")
print(data1.describe)
print(data1.isnull().sum())
plt.figure(figsize=(5, 5))
plt.bar(data1["Research"].apply(str), data1["CoA"])
plt.title("Impact of research activity on admission chances")
plt.xlabel('Research Work')
plt.ylabel('Admission chances')
plt.show()
plt.figure(figsize=(8, 8))
plt.scatter(x="CGPA", y="GRE", data=data1)
plt.title("Comparison between Cgpa and Gre Scores")
plt.xlabel('CGPA')
plt.ylabel('GRE')
plt.show()
plt.figure(figsize=(8, 8))
plt.scatter(x="CoA", y="GRE", data=data1)
plt.title("Comparison between Admit Chances and Gre Scores")
plt.xlabel('Admission Chances')
plt.ylabel('GRE')
plt.show()
plt.figure(figsize=(8, 8))
plt.scatter(x="CoA", y="TOEFL", data=data1)
plt.title("Comparison between Admit Chances and TOEFL Scores")
plt.xlabel('Admission Chances')
plt.ylabel('TOEFL')
plt.show()
print(data1.corr(method='kendall'))
print(data1.corr(method='pearson'))
corr_matrix = data1.corr()
print(corr_matrix["CGPA"])
print(corr_matrix["GRE"])
x = 0
j = 0
for i in data1["CoA"]:
if 0.8 <= i <= 0.99:
j = 1
elif 0.65 <= i <= 0.79:
j = 2
elif 0.5 <= i <= 0.64:
j = 3
elif 0.5 <= i <= 0.64:
j = 4
elif i <= 0.3:
j = 5
data1['CoA'][x] = j
x = x + 1
data1['CoA'] = data1['CoA'].astype(int)
data1['CoA'] = data1['CoA'].astype(str)
y1 = data1["CoA"]
x1 = data1.drop("CoA", axis="columns")
x1_train, x1_test, y1_train, y1_test = train_test_split(x1, y1, test_size=0.2)
linear_regression = LinearRegression()
linear_regression = linear_regression.fit(x1_train, y1_train)
model = LinearRegression(normalize=True)
model.fit(x1_test, y1_test)
linearScore = model.score(x1_test, y1_test)
# print("Accuracy of linear regression model : ",linearScore*100,"%")
SVM_classifier = SVC(kernel='linear')
SVM_classifier.fit(x1_train, y1_train)
SVM_Score = SVM_classifier.score(x1_test, y1_test)
# print("Accuracy of SVM model : ",SVM_Score*100,"%")
knn = KNeighborsClassifier(n_neighbors=20)
knn.fit(x1_train, y1_train)
print(SVM_classifier.predict([[331, 111, 3, 3, 8, 1]]))
random_forest = RandomForestRegressor(max_depth=1, n_estimators=100, random_state=1)
random_forest.fit(x1_train, y1_train)
root_mean_squared_error = np.sqrt(mean_squared_error(y1_train, random_forest.predict(x1_train)))
random_forest_score = random_forest.score(x1_test, y1_test)
print("Accuracy of Random Forest model : ",random_forest_score*100,"%")
print("RMSE of random forest model : ",root_mean_squared_error)
root_mean_squared_error_knn = np.sqrt(mean_squared_error(y1_train, knn.predict(x1_train)))
knn_score = knn.score(x1_test, y1_test)
print("Accuracy of KNN model : ",knn_score*100,"%")
print("RMSE value of KNN : ",root_mean_squared_error_knn)
root_mean_squared_error_svm = np.sqrt(mean_squared_error(y1_train, SVM_classifier.predict(x1_train)))
SVM_Score = SVM_classifier.score(x1_test, y1_test)
print("Accuracy of SVM model : ",SVM_Score*100,"%")
print("RMSE of SVM model : ",root_mean_squared_error_svm)
pickle.dump(SVM_classifier, open('GradSchool.pkl', 'wb'))
print("\nPrediction Model dumped successfully")