0% found this document useful (0 votes)
38 views1 page

Untitled15.ipynb - Colaboratory

Uploaded by

Linya C
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views1 page

Untitled15.ipynb - Colaboratory

Uploaded by

Linya C
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

from google.

colab import files


upload=files.upload()

Choose Files diabetes.csv


diabetes.csv(text/csv) - 23875 bytes, last modified: 11/24/2023 - 100% done
Saving diabetes.csv to diabetes.csv

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

data=pd.read_csv('diabetes.csv')

data.head()

output Pregnancies Glucose BloodPressure SkinThickness Insulin BMI DiabetesPedigreeFunction Age Outcome

0 6 148 72 35 0 33.6 0.627 50 1

1 1 85 66 29 0 26.6 0.351 31 0

2 8 183 64 0 0 23.3 0.672 32 1

3 1 89 66 23 94 28.1 0.167 21 0

4 0 137 40 35 168 43.1 2.288 33 1

from sklearn.model_selection import train_test_split


from sklearn.metrics import confusion_matrix
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score

X = data.drop('Outcome', axis=1)
y = data['Outcome']

X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.30,random_state=1)
model=LogisticRegression()
model.fit(X_train,y_train)
y_predict=model.predict(X_test)
print(y_predict)
print('accuracy=',accuracy_score(y_test, y_predict) * 100)

[0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 1 0
0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0 0 1 1 1 1 1 0
1 0 1 0 0 1 1 0 0 0 0 1 1 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 1 0 0 0
0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 1 0 0 1 0 0 1 1 0 0 0
0 0 0 1 0 0 1 1 0 0 0 0 1 1 0 0 0 0 0 1 1 1 1 1 0 0 1 0 1 0 0 0 0 1 0 1 0
0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 1 0 0 0 1 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 1 0]
accuracy= 78.35497835497836

from sklearn import metrics


print(metrics.confusion_matrix(y_test,y_predict))

[[132 14]
[ 36 49]]

You might also like