Question



submitting LR

Professor,

I am trying to submit my LR predictions but my PredictionsRound2 is coming up as empty.

predLRstep <- predict(LRstep, newdata=BasetableTEST, type="response")
predLRstep <- as.data.frame(predLRstep)

symbols_to_predict <- c('CIB',...,'IR')
PredictionsRound2 <- data.frame(symbols=as.character(c("c","b","a","e","g")),
predictions=c(0.1,0.4,0.4,1,0.05),
stringsAsFactors=FALSE)
PredictionsRound2 <- predLRstep[predLRstep %in% symbols_to_predict,]

> str(PredictionsRound2)
num(0)

additional information on predLRstep if you need it
> str(predLRstep)
'data.frame': 116057 obs. of 1 variable:
$ predLRstep: num 1 1 1 1 1 ...

-----------------------------------------------------------------------------------------------------------------------------------------

I converted predLRstep to a dataframe because when it was a large numeric or factor I received the following error

#numeric
> predLRstep <- predict(LRstep, newdata=BasetableTEST, type="response")
> str(predLRstep)
Named num [1:116057] 1 1 1 1 1 ...
- attr(*, "names")= chr [1:116057] "232115" "232116" "232117" "232118" ...

> PredictionsRound2 <- predLRstep[predLRstep %in% symbols_to_predict,]
Error in predLRstep[predLRstep %in% symbols_to_predict, ] :
> PredictionsRound2 <- predLRstep[predLRstep %in% symbols_to_predict,]
Error in predLRstep[predLRstep %in% symbols_to_predict, ] :
incorrect number of dimensions

#factor
> predLRstep <- predict(LRstep, newdata=BasetableTEST, type="response")
> predLRstep <- as.factor(predLRstep)
> str(predLRstep)
Factor w/ 14158 levels "0.999977111573698",..: 4165 3947 3558 3972 1849 2415 2736 3143 4392 4537 ...
- attr(*, "names")= chr [1:116057] "232115" "232116" "232117" "232118" ...

> PredictionsRound2 <- predLRstep[predLRstep$Symbols %in% symbols_to_predict,]
Error in predLRstep$Symbols : $ operator is invalid for atomic vectors
incorrect number of dimensions
> PredictionsRound2 <- predLRstep[predLRstep %in% symbols_to_predict,]
Error in `[.default`(predLRstep, predLRstep %in% symbols_to_predict, ) :
incorrect number of dimensions





Answers and follow-up questions





Answer or follow-up question 1

Dear student,

Looks like a couple of things are wrong here.

I just elaborated the Section 'Selecting and ordering your predictions' on
http://ballings.co/cup/import.php

Does that help?

Michel Ballings





Sign in to be able to add an answer or mark this question as resolved.