[R] Regression Tree Questions
bgunter.4567 at gmail.com
Sat Feb 24 20:33:43 CET 2018
But note that converting it e.g. via as.numeric() would be disastrous:
 1 2 3
The OP may need to do some homework with R tutorials to learn about basic R
data structures; or if he has already done this, he may need to be more
explicit about how the data were created/entered.
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Sat, Feb 24, 2018 at 11:21 AM, José María Mateos <chema at rinzewind.org>
> On Sat, Feb 24, 2018 at 01:16:27PM -0600, Gary Black wrote:
> > Hi All,
> > I'm a newbie and have two questions. Please pardon me if they are very
> > 1. I'm using a regression tree to predict the selling prices of 10 new
> records (homes). The following code is resulting in an error message:
> pred <- predict(model, newdata = outOfSample[, -6])
> > The error message is:
> > Error in model.frame.default(Terms, newdata, na.action = na.action, xlev
> = attr(object, :
> > factor Sq. Feet has new levels 1375, 1421, 1547, 1621, 1868, 2211, 2265,
> 2530, 2672, 3365
> Seems to me that variable 'Sq. Feet' is being encoded as a factor
> instead of having numerical values. When you train, the model sees a
> series of values that understands as categorical, and when you try to
> predict it is encountering some different categories and it doesn't know
> what to do with them.
> As that variable is most probably numeric, it should be read as such.
> You can try converting it on both your train and test datasets.
> -- José María Mateos
> https://rinzewind.org/blog-es || https://rinzewind.org/blog-en
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/
> and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
More information about the R-help