How to use preProcess in Caret?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to use preProcess in Caret?

Burak Kaymakci
Hello there,

I am using caret and neuralnet to train a neural network to predict times
table. I am using 'backprop' algorithm for neuralnet to experiment and
learn.

Before using caret, I've trained a neuralnet without using caret, I've
normalized my input & outputs using preProcess with 'range' method. Then I
predicted my test set, did the multiplication and addition on predictions
to get the real values. It gave me good results.

What I want to ask is, when I try to train my network using caret, I get an
error saying algorithm did not converge. I am thinking that I might be
doing something wrong with my pre-processing,

How would I go about using preProcess in train?
Do I pass my not-normalized data set to the train function and train
function handles normalization internally?

You can find my R gist here
<https://gist.github.com/andreyuhai/f299282f5a827e2a27c586afc9eb4eb5>

Thank you,
Burak
______________________________________________
[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: How to use preProcess in Caret?

R help mailing list-2
Hello,

Have you tried alternative methods of pre-processing your data, such
as simply calling scale()? What is the effect on convergence, for both
the caret package and and the neuralnet package? There's an example
using scale() with the neuralnet package at the link below:

https://datascienceplus.com/fitting-neural-network-in-r/

HTH, Bill.

W. Michels, Ph.D.



On Sun, Dec 1, 2019 at 10:04 AM Burak Kaymakci <[hidden email]> wrote:

>
> Hello there,
>
> I am using caret and neuralnet to train a neural network to predict times
> table. I am using 'backprop' algorithm for neuralnet to experiment and
> learn.
>
> Before using caret, I've trained a neuralnet without using caret, I've
> normalized my input & outputs using preProcess with 'range' method. Then I
> predicted my test set, did the multiplication and addition on predictions
> to get the real values. It gave me good results.
>
> What I want to ask is, when I try to train my network using caret, I get an
> error saying algorithm did not converge. I am thinking that I might be
> doing something wrong with my pre-processing,
>
> How would I go about using preProcess in train?
> Do I pass my not-normalized data set to the train function and train
> function handles normalization internally?
>
> You can find my R gist here
> <https://gist.github.com/andreyuhai/f299282f5a827e2a27c586afc9eb4eb5>
>
> Thank you,
> Burak
> ______________________________________________
> [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: How to use preProcess in Caret?

Burak Kaymakci
Hello there,

Yes, I'd tried scale as well. I mean, I could do my preprocessing
separately and it was working fine.
I was just wondering how preProcess argument in train function works. As
far as I know, when preProcess argument is set, it normalizes inputs but
not outputs.

Then I've figured we could also use recipes and that normalizes both
predictors and outcomes as you wish.

Here
<https://stackoverflow.com/questions/59126400/how-does-setting-preprocess-argument-in-train-function-in-caret-work?noredirect=1#comment104528951_59126400>
you can take a look at the question I've asked on SO.
You can see the use of recipe in comments below by "missuse".

I will read the link you've shared as well.

Thank you,
Burak


William Michels <[hidden email]>, 4 Ara 2019 Çar, 21:04 tarihinde
şunu yazdı:

> Hello,
>
> Have you tried alternative methods of pre-processing your data, such
> as simply calling scale()? What is the effect on convergence, for both
> the caret package and and the neuralnet package? There's an example
> using scale() with the neuralnet package at the link below:
>
> https://datascienceplus.com/fitting-neural-network-in-r/
>
> HTH, Bill.
>
> W. Michels, Ph.D.
>
>
>
> On Sun, Dec 1, 2019 at 10:04 AM Burak Kaymakci <[hidden email]>
> wrote:
> >
> > Hello there,
> >
> > I am using caret and neuralnet to train a neural network to predict times
> > table. I am using 'backprop' algorithm for neuralnet to experiment and
> > learn.
> >
> > Before using caret, I've trained a neuralnet without using caret, I've
> > normalized my input & outputs using preProcess with 'range' method. Then
> I
> > predicted my test set, did the multiplication and addition on predictions
> > to get the real values. It gave me good results.
> >
> > What I want to ask is, when I try to train my network using caret, I get
> an
> > error saying algorithm did not converge. I am thinking that I might be
> > doing something wrong with my pre-processing,
> >
> > How would I go about using preProcess in train?
> > Do I pass my not-normalized data set to the train function and train
> > function handles normalization internally?
> >
> > You can find my R gist here
> > <https://gist.github.com/andreyuhai/f299282f5a827e2a27c586afc9eb4eb5>
> >
> > Thank you,
> > Burak
> > ______________________________________________
> > [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.
>

        [[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.