Error: object 'h2o.targetencoder' not found

I want to use: h2o.targetencoder function, then I do:

> install.packages("h2o")
> library("h2o")
> h2o.targetencoder

but I get the following error:

Error: object 'h2o.targetencoder' not found

At the same time, I see that function is defined here:

Any idea on how can I use function: h2o.targetencoder?

Thanks!

That is a new function only included in the development version of h2o you can install it from this repo.

install.packages("h2o", type="source", repos="http://h2o-release.s3.amazonaws.com/h2o/master/4799/R")

thank you @andresrcs!

Just taking a note here...

My goal was to do Target Encoding when the target variable is continuous.

I installed the latest package (as of now) from GitHub repository, but got the following error:

java.lang.IllegalStateException: `target` must be a binary categorical vector. We do not support multi-class and continuos target case for now

java.lang.IllegalStateException: `target` must be a binary categorical vector. We do not support multi-class and continuos target case for now
	at ai.h2o.targetencoding.TargetEncoder.ensureTargetColumnIsBinaryCategorical(TargetEncoder.java:188)
	at ai.h2o.targetencoding.TargetEncoder.prepareEncodingMap(TargetEncoder.java:137)
	at ai.h2o.targetencoding.TargetEncoder.prepareEncodingMap(TargetEncoder.java:198)
	at ai.h2o.targetencoding.TargetEncoderBuilder$TargetEncoderDriver.computeImpl(TargetEncoderBuilder.java:45)
	at hex.ModelBuilder$Driver.compute2(ModelBuilder.java:222)
	at water.H2O$H2OCountedCompleter.compute(H2O.java:1417)
	at jsr166y.CountedCompleter.exec(CountedCompleter.java:468)
	at jsr166y.ForkJoinTask.doExec(ForkJoinTask.java:263)
	at jsr166y.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:974)
	at jsr166y.ForkJoinPool.runWorker(ForkJoinPool.java:1477)
	at jsr166y.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:104)

Error: java.lang.IllegalStateException: `target` must be a binary categorical vector. We do not support multi-class and continuos target case for now

It seems that the this is not an option for me right now for Target Encoding when target continuous variable.

Thanks!

Hi @tlg265,

I am wondering what you are trying to achieve by trying to encode a continuous variable. For a categorical variable like c('cat', 'dog') one can encode this as c(1,2) with the category cat encoded as 1 and dog - as 2. But for a continuous numeric variable I am not sure if/what encoding can be used (for).

Hi @valeri, I was not trying to target encode a predictor continuous variable. What I said above is:
"this is not an option for me right now for Target Encoding when target continuous variable"

what it is continue is the target variable, but variable: animal (which will be encoded) is categorical.

Thanks!

Thanks @tlg265, I think I understand but I am not sure - if the operation is called targetencoding and the target is continuous, then isn't that what it is trying to encode? In my comment, I actually meant it in general, regardless if the continuous variable is a target or predictor - I still don't see sense in encoding it, unless by encoding we mean binning it somehow.

Sometimes this procedure is called "target-based encoding", which is perhaps a clearer name. What's being encoded is not the continuous "target" — instead, a continuous (or categorical) "target" variable is being used to encode a categorical variable. See:

1 Like

Oh ... thanks @jcblum - now I get it :slight_smile:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.