Displaying 20 results from an estimated 1000 matches similar to: "help with niave bayes"
2007 Jan 19
1
naive bayes help
Hello
I have a rather simple code and for some reason it produces an error
message. If someone can tell me why and how to fix it, I would be very
greatful. Thank you in advance.
##### create data
set.seed(10)
n <- 200 # number of training points
n.test <- 200 # number of test points
p<-2 # dimension of input space
z <-
2011 Feb 08
1
Naive Bayes Issue - Can't Predict - Error is "Error in log(sapply(attribs...)
Hey guys,
I can't get my Naive Bayes model to predict. Forgive me if its simple...
I've tried about everything and can't get it to work. Reproduceable code
below.
Thank you,
Mike
--
Michael Schumacher
Manager Data & Analytics - ValueClick
mike.schumacher@gmail.com
*
Functional Example Code from UCLA:
2012 May 04
1
weird predict function error when I use naive bayes
Hi,
I tried to use naivebayes in package 'e1071'.
when I use following parameter, only one predictor, there is an error.
> m<- naiveBayes(iris[,1], iris[,5])
> table(predict(m, iris[,1]), iris[,5])
Error in log(sapply(attribs, function(v) { :
Non-numeric argument to mathematical function
However, when I use two predictors, there is not error any more.
> m<-
2007 Oct 30
1
NAIVE BAYES with 10-fold cross validation
hi there!!
i am trying to implement the code of the e1071 package for naive bayes, but it doens't really work, any ideas??
i am very glad about any help!!
i need a naive bayes with 10-fold cross validation:
code:
library(e1071)
model <- naiveBayes(code ~ ., mydata)
tune.control <- tune.control(random = FALSE, nrepeat = 1, repeat.aggregate = min,
sampling = c("cross"),
2011 Feb 25
0
e1071's Naive Bayes with Weighted Data
Hello fellow R programmers,
I'm trying to use package e1071's naiveBayes function to create a model with
weighted data. See example below, variable "d" is a count variable that
provides the # of records for the given observation combination. Is anyone
aware of a "weight" argument to this method? I've been unsuccessful in my
research.
Thanks,
Mike
2012 Jul 05
1
Different level set when predicting with e1071's Naive Bayes classifier
Hi!
I'm using the Naive Bayes classifier provided by the e1071 package (
http://cran.r-project.org/web/packages/e1071) and I've noticed that the
predict function has a different behavior when the level set of the columns
used for prediction is different from the ones used for fitting. From
inspecting the predict.naiveBayes I came to the conclusion that this is due
to the conversion of
2007 Sep 25
1
10- fold cross validation for naive bayes(e1071)
Hallo!
I would need a code for 10-fold cross validation for the classifiers Naive Bayes and svm (e1071) package. Has there already been done something like that?
I tried to do it myself by applying the tune function first:
library(e1071)
tune.control <- tune.control(random =F, nrepeat=1, repeat.aggregate=min.,sampling=c("cross"),sampling.aggregate=mean, cross=10, best.model=T,
2006 Jul 24
2
RandomForest vs. bayes & svm classification performance
Hi
This is a question regarding classification performance using different methods.
So far I've tried NaiveBayes (klaR package), svm (e1071) package and
randomForest (randomForest). What has puzzled me is that randomForest seems to
perform far better (32% classification error) than svm and NaiveBayes, which
have similar classification errors (45%, 48% respectively). A similar
difference in
2012 Aug 02
1
Naive Bayes in R
I'm developing a naive bayes in R. I have the following data and am trying
to predict on returned (class).
dat = data.frame(home=c(0,1,1,0,0), gender=c("M","M","F","M","F"),
returned=c(0,0,1,1,0))
str(dat)
dat$home <- as.factor(dat$home)
dat$returned <- as.factor(dat$returned)
library(e1071)
m <- naiveBayes(returned ~ ., dat)
m
2012 Feb 09
1
Tr: Re: how to pass weka classifier options with a meta classifier in RWeka?
Le jeudi 09 f?vrier 2012 ? 15:31 +0200, Kari Ruohonen a ?crit :
> Hi,
> I am trying to replicate a training of AttributeSelectedClassifier with
> CFsSubsetEval, BestFirst and NaiveBayes that I have initially done with
> Weka. Now, I am trying to use RWeka in R.
>
> I have a problem of passing arguments to the CfsSubsetEval, BestFirst
> and NaiveBayes. I have first created an
2024 Sep 28
1
lattice xyplot with cumsum() function inside
This code gives unexpected result.
library(data.table)
library(lattice)
set.seed(123)
mydt <- data.table(date = seq.Date(as.IDate("2024-01-01"), by = 1,
length.out = 50), xgroup = "A", x = runif(50, 0, 1))
mydt <- rbindlist(list(mydt, data.table(date = mydt$date, xgroup = "B", x = runif(50, 0, 3))))
mydt[, `:=`(xcumsum = cumsum(x)), by = .(xgroup)]
mydt[,
2012 Feb 07
2
predict.naiveBayes() bug in e1071 package
Hi,
I'm currently using the R package e1071 to train naive bayes
classifiers and came across a bug: When the posterior probabilities of
all classes are small, the result from the predict.naiveBayes function
become NaNs. This is an issue with the treatment of the
log-transformed probabilities inside the predict.naiveBayes function.
Here is an example to demonstrate the problem (you might need
2009 May 06
1
How to do Naive Bayes in R?
I am wondering if anybody here have a simple example in R for Naive
Bayes.
For example, I can do k-means clustering on the "iris" data -
data(iris)
cl <- kmeans(iris[,1:4], 3)
cl$cluster
cbind(1:150,iris$Species)
===========
But how to do Naive Bayes classification in the same "iris" data?
Many thanks!
--
View this message in context:
2024 Sep 21
3
store list objects in data.table
I am trying to store regression objects in a data.table
df <- data.frame(x = rnorm(20))
df[, "y"] <- with(df, x + 0.1 * x^2 + 0.2 * rnorm(20))
mydt <- data.table(mypower = c(1, 2), myreg = list(lm(y ~ x, data = df),
lm(y ~ x + I(x^2), data = df)))
mydt
#?? mypower??? myreg
#???? <num>?? <list>
#1:?????? 1 <lm[12]>
#2:?????? 2 <lm[12]>
But mydt[1, 2]
2024 Sep 22
1
store list objects in data.table
Well, you may have good reasons to do things this way -- and you
certainly do not have to explain them here.
But you might wish to consider using R's poly() function and a basic
nested list structure to do something quite similar that seems much
simpler to me, anyway:
x <- rnorm(20)
df <- data.frame(x = x, y = x + .1*x^2 + rnorm(20, sd = .2))
result <-
with(df,
2010 Sep 06
1
calculating area between plot lines
Hi everyone. I have these data:
probClass<-seq(0,0.9,0.1)
prob1<-c(0.0070,0.0911,0.1973,0.2949,0.3936,0.5030,0.5985,0.6869,0.7820,0.8822)
prob2<-c(0.0066,0.0791,0.2358,0.3478,0.3714,0.3860,0.6667,0.6400,0.7000,1.0000)
# which I'm plotting as follows:
plot(probClass,prob1,xlim=c(0,1),ylim=c(0,1),xaxs='i',yaxs='i',type="n")
lines(probClass,prob1)
2024 Nov 05
0
lattice subscripts with both condition and group
How can I use subscripts to draw the last graph with one call to ? ? ? ? ? ? ? ? ? ? ? ??
function xyplot()? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
Thanks, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
Naresh ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
2007 Nov 01
1
RWeka and naiveBayes
Hi
I'm trying to use RWeka to use a NaiveBayes Classifier(the Weka
version). However it crashes whenever there is a NA in the class
Gender
Here is the.code I have with d2 as the data frame.
The first call to NB doesn't make R crash but the second call does.
NB <- make_Weka_classifier("weka/classifiers/bayes/NaiveBayesSimple")
d2[,64]<-d2$Gender=="M"
2007 Aug 22
1
"subscript out of bounds" Error in predict.naivebayes
I'm trying to fit a naive Bayes model and predict on a new data set using
the functions naivebayes and predict (package = e1071).
R version 2.5.1 on a Linux machine
My data set looks like this. "class" is the response and k1 - k3 are the
independent variables. All of them are factors. The response has 52 levels
and k1 - k3 have 2-6 levels. I have about 9,300 independent variables
2024 Sep 22
2
store list objects in data.table
Thanks everyone for their responses.
My data is organized in a data.table.? My goal is to perform analyses
according to some groups.? The results of analysis are objects.? If
these objects could be stored as elements of a data.table, this would
help downstream summarizing of results.
Let me try another example.
carsdt <- setDT(copy(mtcars))
carsdt[, unique(cyl) |> length()]
#[1] 3