# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
import pandas as pd
from sklearn import cross_validation
from sklearn.linear_model import LogisticRegression

url = 'https://archive.ics.uci.edu/ml/machine-learning-databases/pima-indians-diabetes/pima-indians-diabetes.data'
names =  ['preg', 'plas', 'pres', 'skin', 'test', 'mass', 'pedi', 'age', 'class']
df = pd.read_csv(url, names=names)

X = df.values[:, 0:8]
y = df.values[:, 8]

num_folds = 10
num_instances = len(X)
seed = 7

model = LogisticRegression()
kfold = cross_validation.KFold(n=num_instances, n_folds=num_folds, random_state=seed)
# -

results = cross_validation.cross_val_score(model, X, y, cv=kfold)

accuracy = [results.mean()*100.0, results.std()*100.0]
print("Accuracy:\n\tMean {:5.2f}%\n\tStd.{:5.2f}%".format(accuracy[0], accuracy[1]))

StarcoderdataJupyterScriptsDedupFiltered