Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sklearn
- from sklearn.utils import shuffle
- from sklearn.neighbors import KNeighborsClassifier
- import pandas as pd
- import numpy as np
- from sklearn import linear_model, preprocessing
- import matplotlib.pyplot as plt
- from matplotlib import style
- from mpl_toolkits.mplot3d import Axes3D
- import matplotlib.pyplot as plt
- def GetAccuracity(Accuracity):
- Accuracity = str(round(Accuracity*100,2)) + str("%")
- print("- Accuracity:",Accuracity)
- def Get_2D_Plot(XLabel, YLabel, Prediction, Data, Style):
- style.use(Style)
- plt.scatter(Data[XLabel], Data[Prediction])
- plt.xlabel(XLabel)
- plt.ylabel(YLabel)
- plt.show()
- def Get_3D_Plot(XLabel, YLabel, ZLabel, Data, Style):
- style.use(Style)
- Graph = plt.figure()
- ax = Graph.add_subplot(111, projection='3d')
- x = Data[XLabel]
- y = Data[YLabel]
- z = Data[ZLabel]
- ax.scatter(x, y, z, c='r', marker='o')
- ax.set_xlabel("")
- ax.set_ylabel("")
- ax.set_zlabel("")
- plt.show()
- Data = pd.read_csv("Students.csv", sep=",")
- Data = Data[["GRE Score", "TOEFL Score", "University Rating", "SOP", "LOR", "CGPA", "Research", "Chance of Admit"]]
- MyPrediction = "Chance of Admit"
- Features = np.array(Data.drop([MyPrediction], 1))
- CA = np.array(Data[MyPrediction])
- # Linear Model.
- x_train, x_test, y_train, y_test = sklearn.model_selection.train_test_split(Features, CA, test_size = 0.1)
- LinearModel = linear_model.LinearRegression()
- LinearModel.fit(x_train, y_train)
- Accuracity = LinearModel.score(x_test, y_test)
- XLabel = "GRE Score"
- YLabel = "TOEFL Score"
- ZLabel = "Chance of Admit"
- Get_3D_Plot(XLabel, YLabel, ZLabel, Data, "ggplot")
- Get_2D_Plot(XLabel, YLabel, MyPrediction, Data, "ggplot")
- GetAccuracity(Accuracity)
Add Comment
Please, Sign In to add comment