with python please
We want to use logistic regression to predict if a person has
stroke or not (column 11) based on eight common diagnostic features
(columns 2 to 10). [5 marks]:
Data is available at “stroke_data.csv”.
Hint: use statsmodels to fit the data.
Remember to add constant for intercept.
https://www.statsmodels.org/dev/generat ... Logit.html
Hints: Use pandas.drop(feature_list,
axis=1)
Hint: Use utility functions in
scikit-learn. Please don’t add constant as scikit learn will add it
by default.
from sklearn.linear_model import
LinearRegression
from sklearn.model_selection import
cross_val_predict
clf =
LogisticRegression(max_iter=300)
y_pred_proba_cv =
cross_val_predict(clf, X, y, cv=5, method='predict_proba')
Hint: Use utility functions in
scikit-learn:
from sklearn.metrics import
roc_curve
Hint: check the output from the
roc_curve.
I really need help with this
course.......
id 0 0 lis_female age 24201 0 70031 1 17013 0 67890 0 38078 1 20256 0 39011 1 22013 1 26727 1 48118 1 36679 1 32183 1 63973 1 66159 1 8154 0 51486 1 6599 0 24832 1 44813 1 8646 1 1307 hypertensicheart_disea ever_marri Rural_resicavg_glucos bmi 33 0 0 1 1 93.8 71 1 0 1 1 195.25 78 1 0 0 0 113.01 77 0 1 1 0 102.96 82 1 1 1 0 73.19 34 0 0 1 0 80.97 14 0 0 0 0 69.82 17 0 0 0 1 105.91 79 0 0 0 1 88.92 82 0 0 1 0 113.45 22 1 0 0 0 71.22 67 0 0 1 1 66.08 77 0 0 1 1 190.32 80 0 1 1 1 66.72 57 1 0 1 0 78.92 61 0 0 1 1 106.65 64 1 0 1 1 85.66 65 0 0 1 0 77.46 34 0 0 0 1 69.06 54 0 0 1 1 97.47 61 0 170.05 smoking stroke 23.9 0 33.3 0 24 0 20.9 0 33.5 0 28.7 0 25.1 0 30.8 0 22.9 0 30.3 0 40 0 36.2 0 31.4 0 21.7 0 27.7 0 0 28.5 0 30.9 0 29 1 0 60.2 1 0 0 0 0 0 1 0 0 0 1 1 1 0 0 0 0 0 35.9 26.7 0
with python please We want to use logistic regression to predict if a person has stroke or not (column 11) based on eigh
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am