Created
October 6, 2020 18:13
-
-
Save rodrigols89/82b8fe268f53defce7692fe2aa2f18b7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import pandas as pd | |
from sklearn.model_selection import cross_val_score # Cross Validation Function. | |
from sklearn.model_selection import KFold # KFold Class. | |
from sklearn.linear_model import LinearRegression # Linear Regression class. | |
df = pd.read_csv("../datasets/Admission_Predict.csv") | |
df.drop('Serial No.', axis = 1, inplace = True) | |
x = df.drop('Chance of Admit ', axis = 1) | |
y = df['Chance of Admit '] | |
model = LinearRegression() | |
kfold = KFold(n_splits=5, shuffle=True) # shuffle=True, Shuffle (embaralhar) the data. | |
result = cross_val_score(model, x, y, cv = kfold) | |
print("K-Fold (R^2) Scores: {0}".format(result)) | |
print("Mean R^2 for Cross-Validation K-Fold: {0}".format(result.mean())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment