Week 1 Graded Quiz On Solution PDF
Week 1 Graded Quiz On Solution PDF
Week 1 Graded Quiz On Solution PDF
[1]:
import warnings
warnings.filterwarnings("ignore")
In [2]:
#Import Libraries
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
In [3]:
df = pd.read_csv("default_2k.csv")
Check Head
In [4]:
df.head()
Out[4]:
0 No No 412.071615 48347.296982
2 No No 694.398583 36570.425441
3 No No 0.000000 41933.095770
Shape
In [5]:
df.shape
Out[5]:
(1994, 4)
In [6]:
x= pd.get_dummies(df.drop("default",axis=1),drop_first=True)
y = df['default']
In [7]:
Question-8 What is the accuracy/Model Score of the model(Naive Bayes) on the Train set?
In [8]:
from sklearn.naive_bayes import GaussianNB # using Gaussian algorithm from Naive Bayes
model.fit(x_train, y_train)
Out[8]:
GaussianNB()
This study source was downloaded by 100000834959320 from CourseHero.com on 02-27-2022 01:37:52 GMT -06:00
https://www.coursehero.com/file/105014895/Week-1-Graded-Quiz-on-Solutionpdf/
In [9]:
train_predict = model.predict(x_train)
Or
In [10]:
model.score(x_train, y_train)
Out[10]:
0.9698924731182795
Question-9 What is the accuracy/Model Score of the model(Naive Bayes) on the Test set?
In [11]:
test_predict = model.predict(x_test)
Or
In [12]:
model.score(x_test, y_test)
Out[12]:
0.9749582637729549
Question-10 What is the recall for target classes-No and Yes for the test data?
In [13]:
print("Classification Report")
print(metrics.classification_report(y_test, test_predict))
Classification Report
precision recall f1-score support
This study source was downloaded by 100000834959320 from CourseHero.com on 02-27-2022 01:37:52 GMT -06:00
https://www.coursehero.com/file/105014895/Week-1-Graded-Quiz-on-Solutionpdf/
Powered by TCPDF (www.tcpdf.org)