Covid-19 Prediction - Jupyter Notebook
Covid-19 Prediction - Jupyter Notebook
Covid-19 Prediction - Jupyter Notebook
[45]:
#we are importing the all required libraries which are useful for yhe model
In [46]:
import numpy as np
import pandas as pd
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score
In [47]:
In [48]:
In [49]:
In [50]:
df.head()
Out[50]:
Dry Cough High Fever Sore Throat Difficulty in breathing Infected with Covid19
0 0 2 3 0 No
1 15 15 20 16 Yes
2 4 5 0 0 No
3 4 7 9 10 No
4 0 0 1 0 No
In [51]:
#Declaring the x and y values and dividing them what to scan and assigning yes:1 and no:0
In [52]:
x=df.iloc[:,:-1]
y=df.iloc[:,-1]
y = y.map({'Yes':1,'No':0})
print(x.head())
print(y.head())
0 0 2 3 0
1 15 15 20 16
2 4 5 0 0
3 4 7 9 10
4 0 0 1 0
0 0
1 1
2 0
3 0
4 0
In [53]:
#importing split function and dividing the data for tarining and printing
In [54]:
54 0 0 0 0
79 11 15 18 20
2 4 5 0 0
53 8 0 1 0
56 17 13 0 0
39 14 20 16 0
0 0 2 3 0
96 9 10 11 12
6 16 17 18 16
19 7 18 12 17
79 0
2 0
53 0
56 1
..
39 1
0 0
96 1
6 1
19 1
In [55]:
#declaration of model
In [56]:
Out[56]:
LinearRegression()
In [57]:
In [58]:
y_pred = regressor.predict(x_train)
from IPython.display import display_html
y_pred=regressor.predict(x_train)
df1_styler = pd.DataFrame(y_train).style.set_table_attributes("style='display:inline'")
df2_styler = pd.DataFrame(y_pred,columns=['Predicted Outcome']).style.set_table_attributes(
display_html(df1_styler._repr_html_()+" "+df2_styler._re
25 1 12 0.511324
14 0 13 0.183770
78 1 14 1.154846
1 1 15 0.886637
35 0 16 0.289346
52 0 17 0.259418
13 1 18 0.958570
48 0 19 0.404296
92 0 20 0.915762
77 1 21 0.993649
44 1 22 1.154846
75 1 23 0.598243
63 0 24 0.184106
In [59]:
y_pred_test=regressor.predict(x_test)
df1_styler = pd.DataFrame(y_test).style.set_table_attributes("style='display:inline'")
df2_styler = pd.DataFrame(y_pred_test,columns=['Predicted Outcome']).style.set_table_attrib
display_html(df1_styler._repr_html_()+" "+df2_styler._re
81 1 0 0.294705
51 0 1 0.196855
3 0 2 0.404988
70 1 3 0.864655
87 0 4 0.859742
46 0 5 0.138162
30 1 6 0.513538
33 0 7 0.252217
65 1 8 0.603228
73 0 9 0.146350
29 1 10 0.401604
9 1 11 0.958509
47 1 12 0.637389
83 0 13 0.594645
17 1 14 0.886341
37 1 15 0.648458
40 0 16 0.219208
34 1 17 0.806891
68 0 18 0.226930
67 1 19 0.606536
94 0 20 0.146350
31 0 21 0.381979
91 1 22 0.864655
95 1 23 0.372296
61 0 24 0.353026
In [61]:
In [63]:
model = LogisticRegression()
In [64]:
model.fit(x_train, y_train)
Out[64]:
LogisticRegression()
In [65]:
In [66]:
x_train_prediction = model.predict(x_train)
training_data_accuracy = accuracy_score(x_train_prediction, y_train)
In [67]:
In [68]:
In [69]:
In [70]:
x_test_prediction = model.predict(x_test)
test_data_accuracy = accuracy_score(x_test_prediction, y_test)
In [71]:
In [72]: