import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn import tree
import pickle

dataset = pd.read_csv('Covid Dataset.csv')

#Changing pandas dataframe to numpy array
X = dataset.iloc[:,:20].values
y = dataset.iloc[:,-1].values

#Normalizing the data
# from sklearn.preprocessing import LabelEncoder
# le = LabelEncoder()
# y = le.fit_transform(y)

#Normalizing the data
# from sklearn.preprocessing import StandardScaler
# sc = StandardScaler()
# X = sc.fit_transform(X)

#Train test split of model
y_train = dataset['COVID-19']
X_train = dataset[['Breathing Problem','Fever','Dry Cough','Sore throat','Running Nose','Asthma','Chronic Lung Disease','Headache','Heart Disease','Diabetes','Hyper Tension','Fatigue','Gastrointestinal','Abroad travel','Contact with COVID Patient','Attended Large Gathering','Visited Public Exposed Places','Family working in Public Exposed Places','Wearing Masks','Sanitization from Market']]


X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.20, random_state = 0)


t = tree.DecisionTreeClassifier()
t.fit(X_train,y_train)
y_pred = t.predict(X_test)

#Score/Accuracy
acc_decisiontree=t.score(X_test, y_test)*100
print(acc_decisiontree)

# Saving model to disk
pickle.dump(t, open('covid.pkl','wb'))

# Loading model to compare the results
model = pickle.load(open('covid.pkl','rb'))
print(model.predict([[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]))
