Displaying 20 results from an estimated 800 matches similar to: "naive bayes help"
2007 Jan 18
0
help with niave bayes
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 <-
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 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,
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:
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:
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"),
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
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[,
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]
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
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 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,
2011 Oct 06
1
sum of functions
Dear all,
I would like to create a code for semiparametric Klein and Spady's
estimator. For that I created a function that provides the log-likelihood
function for each observation (so it is a function of betas and i, where i
denotes the observation). Now, in order to maximize the log-likelihood
function, I have to sum these log-likelihood functions for each i and so to
get another function
2010 Mar 06
1
Plotting Comparisons with Missing Data
Hi,
I'm new to R and I've run into a problem that I'm not really sure how to
express properly in the language. I've got a data table that I've read from
a file containing some simple information about the performance of 4
algorithms. The columns are the name of the algorithm, the problem instance
and the resulting score on that problem (if it wasn't solved I mark that
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
2008 Apr 22
2
Multidimensional contingency tables
How does one ideally handle and display multidimenstional contingency
tables in R v. 2.6.2?
E.g.:
> prob1<- data.frame(victim=c(rep('white',4),rep('black',4)),
+ perp=c(rep('white',2),rep('black',2),rep('white',2),rep('black',2)),
+ death=rep(c('yes','no'),4), count=c(19,132,11,52,0,9,6,97))
> prob1
victim perp
2011 Nov 29
2
aggregate syntax for grouped column means
I am calculating the mean of each column grouped by the variable 'id'.
I do this using aggregate, data.table, and plyr. My aggregate results
do not match the other two, and I am trying to figure out what is
incorrect with my syntax. Any suggestions? Thanks.
Here is the data.
myData <- structure(list(var1 = c(31.59, 32.21, 31.78, 31.34, 31.61, 31.61,
30.59, 30.84, 30.98, 30.79, 30.79,
2020 Oct 18
1
Resultado de la consola como un tibble
Hola,
Bueno, puedes hacer el cálculo de una forma mucho más compacta y rápida.
Esta forma es especialmente recomendable cuando tienes muchas columnas y
muchas filas.
> library(data.table)
> myDT <- as.data.table(mtcars)
> myDTlong <- melt(myDT, measure.vars=1:ncol(myDT))
> myDTlong[ , list(p_value = shapiro.test(value)$p.value, v_stat =
shapiro.test(value)$statistic) , by
2000 Apr 05
2
My first R-program
Sorry, I pasted the wrong file in earlier... this is the correct one:
pValCalculator(b, n=20, m=20)
{
ind <- 1:min(c(n,m))
prob <- (1-pnorm(b,sd=std*sqrt(ind)))
prob1 <- sum((n-ind+1)*(m-ind+1)*prob)
prob1
}
inputData <-
scan("/users/lvssso/projects/LAMA/output/pValLamaScore.tmp", list(block1
= "",block2 = "",width1 = 0,width2 = 0,alignment = 0,score
2010 Aug 30
2
Regarding naive baysian classifier in R
Hi,
I have a small doubt regarding naive Bayes. I am able to classify the
data's properly but i am just stuck up with how to get the probability
values for naive bayes. In the case of SVM we have "attr" function that
helps in displaying the probability values. Is there any function similar to
"attr" in naive Bayes that can be used for displaying the attribute values.
my