Created
April 28, 2020 07:55
-
-
Save nageshsinghc4/d310e8ed5450d5976452ffe3b9d65e5e to your computer and use it in GitHub Desktop.
This file contains 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
#Classification LogLoss | |
import warnings | |
import pandas | |
from sklearn import model_selection | |
from sklearn.linear_model import LogisticRegression | |
from sklearn.metrics import log_loss | |
warnings.filterwarnings('ignore') | |
url = "https://raw.githubusercontent.com/jbrownlee/Datasets/master/pima-indians-diabetes.data.csv" | |
dataframe = pandas.read_csv(url) | |
dat = dataframe.values | |
X = dat[:,:-1] | |
y = dat[:,-1] | |
seed = 7 | |
#split data | |
X_train, X_test, y_train, y_test = model_selection.train_test_split(X, y, test_size=test_size, random_state=seed) | |
model.fit(X_train, y_train) | |
#predict and compute logloss | |
pred = model.predict(X_test) | |
accuracy = log_loss(y_test, pred) | |
print("Logloss: %.2f" % (accuracy)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment