predict

Using an already created model for scoring a new data set in R

早过忘川 提交于 2020-02-29 00:53:37
问题 I have built a linear regression i R. Now I wanna store the model and use it for scoring a new data set once a week. Someone that can help me with how to? How to save the model and how to import it and use it on an new dataset. 回答1: You can save the model in a file and load it when you need it. For example, you might have a line like this to train your model: the_model <- glm(my_formula, family=binomial(link='logit'),data=training_set) This model can be saved with: save(file="modelfile",the

How to compute standard error for predicted data in R using predict

烈酒焚心 提交于 2020-02-23 05:43:28
问题 Here is my data: a <- c(60, 65, 70, 75, 80, 85, 90, 95, 100, 105) b <- c(26, 24.7, 20, 16.1, 12.6, 10.6, 9.2, 7.6, 6.9, 6.9) a_b <- cbind(a,b) plot(a,b, col = "purple") abline(lm(b ~ a),col="red") reg <- lm(b ~ a) I would like to use the predict function in order to compute the standard error for the predicted b value at 110. z <- predict(reg, newdata=data.frame(year=110), se.fit=TRUE) This is the output I get, but I think this is just giving me the standard errors for my 10 time points, but

Plotting results of logistic regression with binomial data from mixed effects model (lme4) with model averaging (MuMIn)

 ̄綄美尐妖づ 提交于 2020-02-02 16:11:43
问题 I'm trying to display the results of a logistic regression. My model was fit using glmer() from the lme4 package, I then used MuMIn for model averaging. Simplified version of my model using the mtcars dataset: glmer(vs ~ wt + am + (1|carb), database, family = binomial, na.action = "na.fail") My desired output is two plots that show the predicted probability that vs =1, one for wt , which is continuous, one for am , which is binomial. UPDATED: I got this much working after comments from

Converting point process model intensity predictions to probabilities at specific points spatstat

∥☆過路亽.° 提交于 2020-01-25 10:12:25
问题 I am working on a similar dataset as the chorley dataset in the spatstat package and am following a similar analysis as presented in the sample book chapter, Spatial Point Patterns: Methodology and Applications with R. https://book.spatstat.org/sample-chapters/chapter09.pdf library(spatstat) data("chorley") X <- split(chorley)$larynx D <- split(chorley)$lung Q <- quadscheme.logi(X,D) fit <- ppm(Q ~ x + y) locations = data.frame(x=chorley$x, y=chorley$y) pred <- predict(fit, locations =

Converting point process model intensity predictions to probabilities at specific points spatstat

旧街凉风 提交于 2020-01-25 10:12:07
问题 I am working on a similar dataset as the chorley dataset in the spatstat package and am following a similar analysis as presented in the sample book chapter, Spatial Point Patterns: Methodology and Applications with R. https://book.spatstat.org/sample-chapters/chapter09.pdf library(spatstat) data("chorley") X <- split(chorley)$larynx D <- split(chorley)$lung Q <- quadscheme.logi(X,D) fit <- ppm(Q ~ x + y) locations = data.frame(x=chorley$x, y=chorley$y) pred <- predict(fit, locations =

Convert R read.csv to a readLines batch?

ぐ巨炮叔叔 提交于 2020-01-24 17:26:06
问题 I have a fitted model that I'd like to apply to score a new dataset stored as a CSV. Unfortunately, the new data set is kind of large, and the predict procedure runs out of memory on it if I do it all at once. So, I'd like to convert the procedure that worked fine for small sets below, into a batch mode that processes 500 lines at a time, then outputs a file for each scored 500. I understand from this answer (What is a good way to read line-by-line in R?) that I can use readLines for this. So

StatsModel logit.predict error: Number of rows mismatch between data argument and new values

余生长醉 提交于 2020-01-24 01:34:27
问题 I have a train dataframe(227845 lines) and a test dataframe (56962 lines). What I want to do is to run a statsmodel logit regression on the train data and then predict the values for the test data. But after I train my model when I try to predict the test values I get the error : PatsyError: Number of rows mismatch between data argument and train.loc[:, train.columns != 'Class'] (56962 versus 227845) train['Class'] ~ train.loc[:, train.columns != 'Class'] My steps for the analysis are: import

Is it possible to obtain class probabilities using GradientBoostedTrees with spark mllib?

十年热恋 提交于 2020-01-16 01:10:55
问题 I am currently working with spark mllib. I have created a text classifier using the Gradient Boosting algorithm with the class GradientBoostedTrees: Gradient Boosted Trees Currently I obtain the predictions to know the class of new elements but I would like to obtain the class probabilities (the value of the output before the hard decision). In other mllib algorithms like logistic regression you can remove the threshold from the classifier to obtain the class probabilities but I can not find

Only predict a single time-series-sample within a batch using predict() or predict_on_batch()

烂漫一生 提交于 2020-01-15 15:26:03
问题 In stackoverflow-questions like this one here I read about the batch_size -parameter in Keras' predict() -method or in questions like this one about the difference of predict() and predict_on_batch() . Anyhow, my question was not answered in them. I understand the concept of the batch_size and that I can predict a single batch with predict_on_batch() . But what I want to achieve is predicting a single sample from a batch with multiple samples. The prediction in this case is a time-series

Prediction using saved model object

南笙酒味 提交于 2020-01-13 17:58:53
问题 I am trying to use predict function in R using a model saved earlier. The model was created and saved using the following code: lrModel1 <- glm(response ~ .,data = modelData,family = binomial,model = TRUE) save(lrModel1,file = "lrModel100.rda") When I load the model for later use as follows and try to use the predict function on it as follows: bar <- load("lrModel100.rda") predicted <- predict(bar,validationData,type = "response") I get the following error: Error in UseMethod("predict") : no