Question: Convert data into word. Like into paragraphs. Also give conclusion and recommendations for it . ] ##Naive bayes classifier on filtered original dataset from sklearn
Convert data into word. Like into paragraphs. Also give conclusion and recommendations for it .

![for it . ] ##Naive bayes classifier on filtered original dataset from](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/11/673bf171aa988_681673bf17195928.jpg)






] ##Naive bayes classifier on filtered original dataset from sklearn . naive_bayes import MultinomialNB #Create a MultiNomial NB Classifier nb = MultinomialNB( ) #Train the model using the training sets nb. fit (X_train, y_train) #Predict the response for test dataset y_prednew = nb. predict (X_test) print ("Total Columns (including class) " , len (newdata. columns ) ) Total Columns (including class) 16 D print ( "Number of features used " , nb.n_features_) print ( "Classes " , nb. classes_) print ( "Number of records for classes ", nb. class_count_) print( "Log prior probability for classes ", nb. class_log_prior_) print ( "Log conditional probability for each feature given a class\ " , nb. feature_log_prob_) Number of features used 15 Classes ['0' '1'] Number of records for classes [209. 491. ] Log prior probability lity for classes [-1.20874608 -0.35463621] Log conditional probability for each feature given a class [[-7. 65867709 -5. 09103231 -7.52734108 -7.24241004 -0.0219951 -7. 76990272 -7. 16606137 -7. 18149378 -7.34136322 -7.35977994 -4. 77095434 -7.37287648 -7. 65867709 -7.98467802 -7.22927357] [-6.96134583 -5. 08771382 -7.03018865 -7.02345965 -0.02847854 -7. 19275171 -6. 79466889 -6. 95645584 -7. 02197045 -7.21416198 -4. 44078457 -7. 02569762 -7.36366463 -7. 65729806 -6.96204635]] from sklearn.metrics import classification_report from sklearn import metrics print (classification_report (y_test, y_newpred) ) precision recall f1-score support 0. 78 0. 32 0. 45 91 0. 76 0. 96 0. 85 209 accuracy 0. 77 300 macro avg 0. 77 0. 64 0 . 65 300 weighted avg 0 . 77 0. 77 0.73 300class = 1 class = 1 class = 1 class = 1 class = 0 class = 0 [ ] y_newpred = newclf . predict (X_test) from sklearn. metrics import confusion_matrix cf=confusion_matrix(y_test, y_newpred) print ( "Confusion Matrix") print (cf) tn, fp, fn, tp=cf. ravel( ) print ( "TP: ", tp, ", FP: ", fp, ", TN: ", tn, ", FN:", fn) [ Confusion Matrix [[ 29 62] [ 8 201] ] TP: 201 , FP: 62 , TN: 29 , FN: 8 [ ] #print precision, recall, and accuracy from the perspective of each of the class (0 and 1 for German dataset) from sklearn. metrics import classification_report from sklearn import metrics print (classification_report(y_test, y_newpred) ) precision recall f1-score support 0. 78 0. 32 0. 45 91 HO 0. 76 0. 96 0 . 85 209 accuracy 0. 77 300 macro avg 0. 77 0. 64 0. 65 300 weighted avg 0. 77 0. 77 0. 73 300 [ ]class Names [ '1' '0' ] Account Balance
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
