Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Naive Bayes Review --> #66

Open
github-actions bot opened this issue Oct 18, 2020 · 0 comments
Open

Naive Bayes Review --> #66

github-actions bot opened this issue Oct 18, 2020 · 0 comments
Labels

Comments

@github-actions
Copy link

Naive Bayes Review -->

Naive Bayes Review

<!-- annotate: Naive Bayes Review -->

jupytext:
  text_representation:
    extension: .md
    format_name: myst
    format_version: 0.12
    jupytext_version: 1.6.0
kernelspec:
  display_name: Python 3
  language: python
  name: python3
---

# Class 17: Evaluating Classification and Midsemester Feedback

1. share your favorite rainy day activity (or just say hi) in the zoom chat for attendance
1. log onto prismia

+++

<!-- annotate: Naive Bayes Review --> 
## Naive Bayes Review


Main assumptions: 
- classification assumes that features will separate the gorups
- NB:  conditionally independent 

```{code-cell} ipython3
# %load http://drsmb.co/310
import pandas as pd
import seaborn as sns
from sklearn.model_selection import train_test_split
from sklearn.naive_bayes import GaussianNB
iris = sns.load_dataset("iris")
iris.head()
X_train, X_test, y_train, y_test = train_test_split(iris.values[:,:4],
                                                    iris.species.values, 
                                                    test_size=0.5, random_state=0)
gnb = GaussianNB()
y_pred = gnb.fit(X_train, y_train).predict(X_test)
y_pred
y_test
sum(y_pred == y_test)
len(y_pred)
gnb.score(X_test, y_test)
71/75
from sklearn.metrics import confusion_matrix, classification_report
confusion_matrix(y_test,y_pred,)
sns.pairplot(data =iris, hue='species')
print(classification_report(y_test,y_pred))
gnb.__dict__
import numpy as np
# %load http://drsmb.co/310
df = pd.DataFrame(np.concatenate([np.random.multivariate_normal(mu, sig*np.eye(4),20)
                                  for mu, sig in zip(gnb.theta_,gnb.sigma_)]))
df['species'] = [ci for cl in [[c]*20 for c in gnb.classes_] for ci in cl]
sns.pairplot(data =df, hue='species')

Reminder to Stop Early for feedback survey



8e29632d844cecb4d94553bbccf1ecf2fa49151d
@github-actions github-actions bot added the todo label Oct 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

0 participants