Rotation Forest Error Message

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Rotation Forest Error Message

Sparks, John James
Hi R Helpers,

I wanted to try the rotationForest package.

I pointed it at my data set and got the error message "Error in if (K >= ncol(x)) stop("K should not be greater than or equal to the number of columns in x") :
  argument is of length zero'.

My dataset has 3688 obs. of  111 variables.

Would a quick adjustment to the default value of K resolve this?

If anybody with more experience with the package than me has a general suggestion I would appreciate it.

--John Spaarks


        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Rotation Forest Error Message

Abby Spurdle
Note that I'm not familiar with this package or the method.
Also note that you haven't told anyone what function you're using, or
what your call was.

I'm assuming that you're using the rotationForest() function.
According to its help page, the default is:

    K = round(ncol(x)/3, 0)

There's no reason why the default K value should be higher than the
number of columns, unless:
(1) There's a bug with the package; or
(2) There's a problem with your input.

I note that the package is only version 0.1.3, so a bug is not out of
the question.
Also, I'm a little surprised the author didn't use integer division:

    K = ncol (x) %/% 3

You could just set K to the above value, and see what happens...


On Fri, Aug 21, 2020 at 1:06 PM Sparks, John <[hidden email]> wrote:

>
> Hi R Helpers,
>
> I wanted to try the rotationForest package.
>
> I pointed it at my data set and got the error message "Error in if (K >= ncol(x)) stop("K should not be greater than or equal to the number of columns in x") :
>   argument is of length zero'.
>
> My dataset has 3688 obs. of  111 variables.
>
> Would a quick adjustment to the default value of K resolve this?
>
> If anybody with more experience with the package than me has a general suggestion I would appreciate it.
>
> --John Spaarks
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Rotation Forest Error Message

Abby Spurdle
Just re-read your question and realized I misread the error message.
The argument is of zero length.

But the conclusion is the same, either a bug in the package, or a
problem with your input.


On Fri, Aug 21, 2020 at 4:16 PM Abby Spurdle <[hidden email]> wrote:

>
> Note that I'm not familiar with this package or the method.
> Also note that you haven't told anyone what function you're using, or
> what your call was.
>
> I'm assuming that you're using the rotationForest() function.
> According to its help page, the default is:
>
>     K = round(ncol(x)/3, 0)
>
> There's no reason why the default K value should be higher than the
> number of columns, unless:
> (1) There's a bug with the package; or
> (2) There's a problem with your input.
>
> I note that the package is only version 0.1.3, so a bug is not out of
> the question.
> Also, I'm a little surprised the author didn't use integer division:
>
>     K = ncol (x) %/% 3
>
> You could just set K to the above value, and see what happens...
>
>
> On Fri, Aug 21, 2020 at 1:06 PM Sparks, John <[hidden email]> wrote:
> >
> > Hi R Helpers,
> >
> > I wanted to try the rotationForest package.
> >
> > I pointed it at my data set and got the error message "Error in if (K >= ncol(x)) stop("K should not be greater than or equal to the number of columns in x") :
> >   argument is of length zero'.
> >
> > My dataset has 3688 obs. of  111 variables.
> >
> > Would a quick adjustment to the default value of K resolve this?
> >
> > If anybody with more experience with the package than me has a general suggestion I would appreciate it.
> >
> > --John Spaarks
> >
> >
> >         [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Rotation Forest Error Message

Rasmus Liland-3
On 2020-08-21 16:22 +1200, Abby Spurdle wrote:
| On Fri, Aug 21, 2020 at 4:16 PM Abby Spurdle <[hidden email]> wrote:
| | On Fri, Aug 21, 2020 at 1:06 PM Sparks, John <[hidden email]> wrote:
| | |
| | | Hi R Helpers,
| | |
| | | I wanted to try the rotationForest
| | | package.
| | |
| | | I pointed it at my data set and
| | | got the error message "Error in if
| | | (K >= ncol(x)) stop("K should not
| | | be greater than or equal to the
| | | number of columns in x") :
| | |   argument is of length zero'.
| | |
| | | My dataset has 3688 obs. of  111 variables.
| | |
| | | Would a quick adjustment to the
| | | default value of K resolve this?
| | |
| | | If anybody with more experience
| | | with the package than me has a
| | | general suggestion I would
| | | appreciate it.
| |
| | Note that I'm not familiar with this
| | package or the method.  Also note
| | that you haven't told anyone what
| | function you're using, or what your
| | call was.
| |
| | I'm assuming that you're using the
| | rotationForest() function.  
| | According to its help page, the
| | default is:
| |
| |     K = round(ncol(x)/3, 0)
| |
| | There's no reason why the default K
| | value should be higher than the
| | number of columns, unless:
| | (1) There's a bug with the package; or
| | (2) There's a problem with your input.
| |
| | I note that the package is only
| | version 0.1.3, so a bug is not out
| | of the question.  Also, I'm a little
| | surprised the author didn't use
| | integer division:
| |
| |     K = ncol(x) %/% 3
| |
| | You could just set K to the above
| | value, and see what happens...
|
| Just re-read your question and
| realized I misread the error message.  
| The argument is of zero length.
|
| But the conclusion is the same, either
| a bug in the package, or a problem
| with your input.

Dear John,

check to see if your columns only has
numbers in them like the *de jure* iris
dataset used in the example in
?rotationForest::rotationForest.

        idx <- 1:100
        idx.new <- which(!(1:nrow(iris) %in% idx))
        y <- as.factor(ifelse(iris$Species[idx]=="setosa", 0, 1))
        x <- iris[idx, -5]
        newdata <- iris[idx.new, -5]
        K <- ncol(x) %/% 3
        L <- 100
        rF <-
          rotationForest::rotationForest(
            x=x,
            y=y,
            K=K,
            L=L)
        predict(object=rF, newdata=newdata)

Best,
Rasmus

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Rotation Forest Error Message

Sparks, John James
Thanks Abby and Rasumus.

I like to leave the solution on this list for the next potential person.

I had failed to realize that this package doesn't use one of the formula forms.  So my call of


RotFor2000<-rotationForest(up~.,data=modeldata)

is what caused the error.

After converting to the appropriate form


x<-subset(modeldata,select=-c(up))
y<-modeldata$up
tic()
RotFor2000<-rotationForest(x,y)
toc()

It ran just fine.

Thanks again.
--John Sparks







________________________________
From: Rasmus Liland <[hidden email]>
Sent: Friday, August 21, 2020 3:18 AM
To: Abby Spurdle <[hidden email]>
Cc: Sparks, John <[hidden email]>; R-help <[hidden email]>
Subject: Re: [R] Rotation Forest Error Message

On 2020-08-21 16:22 +1200, Abby Spurdle wrote:
| On Fri, Aug 21, 2020 at 4:16 PM Abby Spurdle <[hidden email]> wrote:
| | On Fri, Aug 21, 2020 at 1:06 PM Sparks, John <[hidden email]> wrote:
| | |
| | | Hi R Helpers,
| | |
| | | I wanted to try the rotationForest
| | | package.
| | |
| | | I pointed it at my data set and
| | | got the error message "Error in if
| | | (K >= ncol(x)) stop("K should not
| | | be greater than or equal to the
| | | number of columns in x") :
| | |   argument is of length zero'.
| | |
| | | My dataset has 3688 obs. of  111 variables.
| | |
| | | Would a quick adjustment to the
| | | default value of K resolve this?
| | |
| | | If anybody with more experience
| | | with the package than me has a
| | | general suggestion I would
| | | appreciate it.
| |
| | Note that I'm not familiar with this
| | package or the method.  Also note
| | that you haven't told anyone what
| | function you're using, or what your
| | call was.
| |
| | I'm assuming that you're using the
| | rotationForest() function.
| | According to its help page, the
| | default is:
| |
| |     K = round(ncol(x)/3, 0)
| |
| | There's no reason why the default K
| | value should be higher than the
| | number of columns, unless:
| | (1) There's a bug with the package; or
| | (2) There's a problem with your input.
| |
| | I note that the package is only
| | version 0.1.3, so a bug is not out
| | of the question.  Also, I'm a little
| | surprised the author didn't use
| | integer division:
| |
| |     K = ncol(x) %/% 3
| |
| | You could just set K to the above
| | value, and see what happens...
|
| Just re-read your question and
| realized I misread the error message.
| The argument is of zero length.
|
| But the conclusion is the same, either
| a bug in the package, or a problem
| with your input.

Dear John,

check to see if your columns only has
numbers in them like the *de jure* iris
dataset used in the example in
?rotationForest::rotationForest.

        idx <- 1:100
        idx.new <- which(!(1:nrow(iris) %in% idx))
        y <- as.factor(ifelse(iris$Species[idx]=="setosa", 0, 1))
        x <- iris[idx, -5]
        newdata <- iris[idx.new, -5]
        K <- ncol(x) %/% 3
        L <- 100
        rF <-
          rotationForest::rotationForest(
            x=x,
            y=y,
            K=K,
            L=L)
        predict(object=rF, newdata=newdata)

Best,
Rasmus

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.