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

Updated naive bayers classifier #4971

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions examples/descriptions/modular/classifier_gaussiannaivebayes.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,33 @@
In this example the Gaussian Naive Bayes algorithm is used to classify
toy data
#data preprocessing

import pandas as pd
data=read.csv('\..\filename.csv')

X=data.iloc[:,:-1].values
Y=data.iloc[:,4].values #the last cloumn of the data

#splitting the data into training and test set

from sklearn.cross_validation import train_test_split
X_train,X_test,Y_train,Y_test=train_test_split(X,Y,test_size=0.25,random_state=0)

#feature scaling

from sklearn.preprocessing import StandardScaler
sc=StandardScaler()
X_train=sc.fit_transform(X_train)
X_test=sc.transform(X_test)

#importing and using the classifier
from sklearn.naive_bayes import GaussianNB
classifier = GaussianNB()
classifier.fit(X_train,Y_train)

#predicting the dataset
Y_pred=classifier.predict(X_test)

#making the confusion matrix to check the accuracy of the data
from sklearn.metrics import confusion_matrix
cm=confusion_matrix(Y_test,Y_pred)