Hello, good morning.
I’m having troubles to separate and use my data for training and tests with glm. Once I have tests and training data, I had fit my model with train data, but can’t understand how to predic with my test data. Below an example:
model = fit(LinearModel, @formula(y ~ x), train)
predict(LinearModel, [xtest ytest]) # ???
I works using an AbstractTable, but, Is there a way to use only the x test values? I can do this by hand, but I think glm can do it also.
ypredicted = predict(model, xtest)
# see how you did
norm(ytest - ypredicted) # from LinearAlgebra
How I cant convert xdata from a vector to data type in xtest?
Edit - Got it here. Needs to be a DataFrame
There’s a method for predicting from a matrix, so just convert xtest to a matrix, even it’s a matrix with just a single column.
reshape(xtest, :, 1) # all rows, 1 column
Nice… it needs a table format.