Iris inverse formula in rxNeuralNet
I'm trying to understand a little of the mechanics behind how "R" treats factors as predictor variables. None of what I write below is probably good practice, but out of sheer curiosity, any thoughts would be appreciated. The standard Iris dataset in R has columns: Sepal.Length, Sepal.Width, Petal.Length, Petal.Width, Species, the last of which is a factor. The standard relation to this dataset is to demonstrate classification algorithms, for example using a neural network or tree, where
rnn1 <- rxNeuralNet(Species~Sepal.Length+Sepal.Width+...,data = iris, numHiddenNodes = 100, numIterations = 1000,type = "classification")
I decided to see what happens if you change this to:
rnn2 <- rnn1 <- rxNeuralNet(Petal.Width~Sepal.Length+Sepal.Width+Species,data = iris, numHiddenNodes = 100, numIterations = 1000,type = "regression")
Then I created my test dataframe:
df1 <- data.frame(Petal.Width=5,Sepal.Length=12,Sepal.Width=3,Species="setosa",Petal.Length=3)
rxPredict () then gives me a score of 0.6058862 for the "setosa" species. But oddly enough, and this is my question, I can put any "string" I want for the species, and I still get a prediction. I put Species="Jack"
, and rxPredict now gives an estimate of 1.545223. This is weird because in standard-R it will generate a factor error if you try to predict any factors that were not in the original dataset.
Any ideas?
Thank.
source to share
No one has answered this question yet
Check out similar questions: