The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here
R code works in the old extension and fails in the new one [Solved]
Using the old R extension the following code works perfectly using the old "Execute Scripts" component
library(unbalanced)
res<-ubSmoteExs(data, "Diagnosis",1500)
However, using the new "Execute R" component the same code returns an error (Invalid labels ,length zero should be 1 or 2)
The code used in the "Execute R" component is:
rm_main = function(data)
{
library(unbalanced)
res<-ubSmoteExs(data, "Diagnosis",1500)
return(res)
}
Would you please help me
library(unbalanced)
res<-ubSmoteExs(data, "Diagnosis",1500)
However, using the new "Execute R" component the same code returns an error (Invalid labels ,length zero should be 1 or 2)
The code used in the "Execute R" component is:
rm_main = function(data)
{
library(unbalanced)
res<-ubSmoteExs(data, "Diagnosis",1500)
return(res)
}
Would you please help me
Tagged:
0
Answers
unfortunately I cannot reproduce your error.
I tried it with the iris data set and it works fine (see example below)
I'm not familiar with the unbalanced package and the format of your data, but I suspect that your result somehow cannot be converted in a data.frame.
Best,
David
This is my code using sonar data. If you have the old R extension you can enable the R script component and see that it works.
unfortunately I still cannot reproduce your error.
On my system your example process runs fine with the new R extension and the sonar data set.
Best,
David
Do think it has something to do with the used R version?
I am using R 3.2.1
By the way I having the same problem in windows and mac machines
I also use 3.2.1, so this should not be the error.
Your error messages indicates, that somehow the labels and levels of result data set do not match.
So my guess is, that the result of the ubSmoteExs() function cannot be correctly transformed in a data.frame.
A solution might be to use factor() on your label to remove unused levels. See here http://stackoverflow.com/questions/6506239/r-warning-mistake-in-factor for an explanation.
Regards,
David
I don't think this is the reason because the same code works perfectly using the old R extension, and you have mentioned that the sonar data code I have sent is working at your machine so I think there is a different reason for this error.
It might be my R configuration, I will check it
Thanks again
Converting it into factor solved the problem
Thank you