xrf icon indicating copy to clipboard operation
xrf copied to clipboard

Error in storage.mode(y) <- "double"

Open Naviden opened this issue 4 years ago • 3 comments

Having this data:

'data.frame':	100 obs. of  10 variables:
 $ lines          : num  0.234 0.155 0.275 0.198 0.116 ...
 $ organization   : num  0.251 0.166 0.295 0.213 0.124 ...
 $ would          : num  0 0.657 0 0 0 ...
 $ one            : num  0 0 0.544 0.785 0.229 ...
 $ writes         : num  0 0.568 0.504 0.363 0.637 ...
 $ university     : num  0.939 0 0 0 0 ...
 $ dont           : num  0 0 0 0 0 ...
 $ article        : num  0 0.319 0 0.409 0.716 ...
 $ nntppostinghost: num  0 0.303 0.537 0 0 ...
 $ label          : Factor w/ 20 levels "alt.atheism",..: 3 12 14 6 11 5 7 15 6 8 ...

I was getting this error:

Error in storage.mode(y) <- "double" : 
  invalid to change the storage mode of a factor

I found out that the problem was having '.' in the target values!

doing.

data$label <- gsub("\\.", "_", data$label)

Resolved the problem!

Naviden avatar Dec 21 '20 14:12 Naviden

Could you include the code you were running? If you include a reproducible example I'd like to fix this up.

holub008 avatar Dec 21 '20 16:12 holub008

data <- https://docs.google.com/spreadsheets/d/1otML1uekMpC-335OtYRrOL-KFoluqZvJ_GN_T8aOS-U/edit?usp=sharing

m_xrf <- xrf(label ~ ., data, family='gaussian',
             xgb_control = list(nrounds = 20, max_depth = 3))

Naviden avatar Dec 22 '20 07:12 Naviden

Thank you! I will take a crack at this in the coming days.

holub008 avatar Dec 22 '20 17:12 holub008