Naive Bayes is a popular (baseline) method for text-classification.
Questions tagged [naivebayes]
1035 questions
-1
votes
1 answer
How to save a Naive Bayes model using sklearn to be imported into an android application?
I'm using sklearn in python to build a classifier eventually to be used in an android application. How to transfer it from python to a way Android Studio can work with?
I've seen tflite implementations but nothing for sklearn. Alongside that there…

KhalidAlsantali
- 9
- 1
-1
votes
1 answer
How do I calculate the naive accuracy an a confusion matrix?
confusion matrix
I have an issue where I'm trying to compute the test accuracy for a naive classifier that always predicts ^y=−1.
I have already calculated the test accuracy of the classifier based on the confusion matrix attached above by using (TN…

filmol
- 1
- 1
-1
votes
1 answer
Bilingual Latent Dirichlet Allocation into [a Modified] K-Means Clustering Algorithm
I have a thesis paper that focuses on using Bilingual LDA and a modified version (modified for runtime) of K-Means for Sentiment Analysis (using Multinomial NB) on Filipino and English COVID-19 Tweets.
I have the files that came from my Bi-LDA from…
-1
votes
1 answer
Getting an index error while training machine learning model for spam detection
I am creating a spam detection ML model using Naive Bayes from scratch and for that i need the likelihood of all classes(or P(feature|not spam)). For that, I've created a function:
import numpy as np
def get_likelihood(term_document_matrix,…

Sukhman
- 11
- 2
-1
votes
1 answer
KeyError on a certain word
I am trying to use Naive Bayes for spam-ham classification.
training_set['E_Mail'] = training_set['E_Mail'].str.split()
vocabulary = []
for email in training_set['E_Mail']:
for word in email:
vocabulary.append(tuple(word))
vocabulary =…

Aksoy
- 3
- 2
-1
votes
1 answer
Naive Bayes Probabilities in R
So here is my situation: I have the following dataset and I try for example to find the conditional probability that a person x is Sex=f, Weight=l, Height=t and Long Hair=y.
When I calculate this by hand, the probability is 0.0333. But when I try…

Ma Ov
- 1
- 2
-1
votes
1 answer
Py4JJavaError: An error occurred while calling o735.fit
I tried to fit a Naive Bayes classifier in Pyspark but I'm getting the following error whenever I try to run my code:
Py4JJavaError: An error occurred while calling o735.fit.
: org.apache.spark.SparkException: Job aborted due to stage failure: Task…

AWDn0n
- 65
- 1
- 9
-1
votes
1 answer
Can I set a random state for the Complement Naive Bayes?
I note I can set the random state in random forest classifier, but not in Complement Naive Bayes. I get error
TypeError: __init__() got an unexpected keyword argument 'random_state'
I assume this is because naive_bayes is computing the probability…

123456
- 393
- 3
- 12
-1
votes
1 answer
Errors on every single classifier with my data in Python (Naives Bayes, Neural Network etc)
I seem to get errors on every single classifier I use. I am using the Enron data (Enron 1 - 5) and trying to create a spam filter.
Lets take the Naïve Bayes as a example.
How I get the data:
# Collecting the ham/spam emails from the training set…

DaleJV
- 370
- 1
- 3
- 15
-1
votes
1 answer
Getting "ValueError: Expected 2D array, got 1D array instead" error in python-sklearn
Please help me. I am unable to resolve one error that I am getting. I am new to machine learning in python. Would be grateful for any advice on this.
Below is my code, that I wrote to predict the type of transportation an employee of a company may…

Ankita
- 79
- 3
- 6
-1
votes
1 answer
Is 0.7 - 0.75 an acceptable accuracy for Naive Bayes sentiment analysis?
I apologise in advance for posting so much code.
I am trying to classify YouTube comments into ones that contain opinion (be it positive or negative) and ones that don't using NLTK's Naive Bayes classifier, but no matter what I do during the…

Charlie Armstead
- 73
- 1
- 8
-1
votes
1 answer
Sklearn Naive Bayes print Probability Results
The output of the classifier is basically 1 and 0 depending on the transformed label, right?
But how do I print out its calculation result?
Rather than,
Predicted: 1
1 means High, 0 means Low
I wanted to have the output
Predicted: 86.4% Low
How to…

Messy Maze
- 3
- 1
- 2
-1
votes
2 answers
D separation python implementation
I am completely new to the field of Bayesian Networks. For my project, I need to check All the possible d separation conditions existing in a 7 node dag and for that I am looking for some good python code.
My knowledge in programming is limited ( a…

Shashaank
- 99
- 3
-1
votes
3 answers
I have wrote this code .what the wrong?? error is (invalid syntax)
my code is naive bayes classifier and I want count positive & negative sentences
pos_count=0
neg_count=0
file = open("a-samples.txt","r")
for line in file:
custom_tokens = remove_noise(word_tokenize(line))
…
-1
votes
1 answer
working on sentimental analyzer using naive bayes on imdb dataset and following is get reviews function taking reviews from ds. but giving error
When i was trying to use get_reviews fn it is giving me error at f.read.decode() saying str has no function decode and when I removed .decode() it again giving me error which I specify down the 1st error.
def…