python - having OneHotEncoder to manage unseen values at transform step -
i using sklearn.preprocessing.onehotencoder encode categorical data of form
a=array([[1,4,1],[0,3,2]]) b=array([[1,4,7],[0,3,2]])
suppose use a
@ .fit(a)
step , b
@ point new data .transform(b)
. if b
contains unseen values in respect a
, doing produces feature out of bounds error
. possible have b
containing new unseen values such transform step sets binaries 0 concerned value?
valueerror: feature out of bounds. try setting n_values.
i understand can change feature bounds @ .fit
time. if using a
training data, each time got new set b predict, have mess initial encoding.
thanks.
is possible have b containing new unseen values such transform step sets binaries 0 concerned value?
no, nice if onehotencoder
did that, i've opened issue this. now, you'll have set n_values
bit higher.
Comments
Post a Comment