, or present both and highlight the difference in outcome. A
> third option is to gather more data.
>
> Tim
>
> -Original Message-
> From: R-help On Behalf Of Bert Gunter
> Sent: Sunday, November 20, 2022 1:06 PM
> To: Mitchell Maltenfort
> Cc: R-help
> Subject: R
-
From: R-help On Behalf Of Bert Gunter
Sent: Sunday, November 20, 2022 1:06 PM
To: Mitchell Maltenfort
Cc: R-help
Subject: Re: [R] test logistic regression model
[External Email]
I think (2) might be a bad idea if one of the "sparse"categories has high
predictive power. You'll l
I think (2) might be a bad idea if one of the "sparse"categories has
high predictive power. You'll lose it when you pool, will you not?
Also, there is the problem of subjectively defining "sparse."
However, 1) seems quite sensible to me. But IANAE.
-- Bert
On Sun, Nov 20, 2022 at 9:49 AM Mitchel
Two possible fixes occur to me
1) Redo the test/training split but within levels of factor - so you have
the same split within each level and each level accounted for in training
and testing
2) if you have a lot of levels, and perhaps sparse representation in a few,
consider recoding levels to po
small reprex:
set.seed(5)
dat <- data.frame(f = rep(c('r','g'),4), y = runif(8))
newdat <- data.frame(f =rep(c('r','g','b'),2))
## convert values in newdat not seen in dat to NA
is.na(newdat$f) <-!( newdat$f %in% dat$f)
lmfit <- lm(y~f, data = dat)
##Result:
> predict(lmfit,newdat)
1
Às 15:29 de 20/11/2022, Gábor Malomsoki escreveu:
Dear Bert,
Yes, was trying to fill the not existing categories with NAs, but the
suggested solutions in stackoverflow.com unfortunately did not work.
Best regards
Gabor
Bert Gunter schrieb am So., 20. Nov. 2022, 16:20:
You can't predict res
Dear Bert,
Yes, was trying to fill the not existing categories with NAs, but the
suggested solutions in stackoverflow.com unfortunately did not work.
Best regards
Gabor
Bert Gunter schrieb am So., 20. Nov. 2022, 16:20:
> You can't predict results for categories that you've not seen before
> (
You can't predict results for categories that you've not seen before (think
about it). You will need to remove those cases from your test set (or
convert them to NA and predict them as NA).
-- Bert
On Sun, Nov 20, 2022 at 7:02 AM Gábor Malomsoki
wrote:
> Dear all,
>
> i have created a logistic
Dear all,
i have created a logistic regression model,
on the train df:
mymodel1 <- glm(book_state ~ TG_KraftF5, data = train, family = "binomial")
then i try to predict with the test df
Predict<- predict(mymodel1, newdata = test, type = "response")
then iget this error message:
Error in model.fr
9 matches
Mail list logo