Project 10 Movie Recommendation - Ipynb - Colaboratory
Project 10 Movie Recommendation - Ipynb - Colaboratory
import numpy as np
df=pd.read_csv(r"https://github.com/YBI-Foundation/Dataset/raw/main/Diabetes.csv")
df.head()
1 1 85 66 29 0 26.6 0.351 31 0
3 1 89 66 23 94 28.1 0.167 21 0
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 768 entries, 0 to 767
Data columns (total 9 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 pregnancies 768 non-null int64
1 glucose 768 non-null int64
2 diastolic 768 non-null int64
3 triceps 768 non-null int64
4 insulin 768 non-null int64
5 bmi 768 non-null float64
6 dpf 768 non-null float64
7 age 768 non-null int64
8 diabetes 768 non-null int64
dtypes: float64(2), int64(7)
memory usage: 54.1 KB
df = df.dropna()
df.describe()
pregnancies glucose diastolic triceps insulin bmi
diabetes
0 500
1 268
dtype: int64
df.groupby('diabetes').mean()
diabetes
df.columns
df.shape
(768, 9)
y = df['diabetes']
y.shape
(768,)
y
0 1
1 0
2 1
3 0
4 1
..
763 0
764 0
765 0
766 1
767 0
Name: diabetes, Length: 768, dtype: int64
X = df.drop(['diabetes'],axis=1)
X.shape
(768, 8)
X
pregnancies glucose diastolic triceps insulin bmi dpf age
mm= MinMaxScaler()
X = mm.fit_transform(X)
X_train.shape,X_test.shape,y_train.shape,y_test.shape
lr = LogisticRegression()
lr.fit(X_train,y_train)
LogisticRegression()
lr.predict_proba
X_new =df.sample(1)
X_new
X_new.shape
(1, 9)
X_new = X_new.drop('diabetes',axis=1)
X_new
X_new.shape
(1, 8)
X_new = mm.fit_transform(X_new)
y_pred_new = lr.predict(X_new)
y_pred_new
array([0])
lr.predict_proba(X_new)
array([[0.9928188, 0.0071812]])