In my university I got an assignment: I need to predict the stock price using two of machine learning methods with imported data. (I've chosen Linear regression and Decision tree).
I tried to make a program myself but encountered errors and since I'm a rookie in machine learning I don't quite understand what I'm doing wrong.
I added a screenshot how the data in imported file looks like just in case.
So here's my code: a = Rest[Import["Test.xlsx", {"Data"}][[1]]][[;; - 2, {2, 3, 4, 5, 6, 7}]];
b = Rest[Import["Test.xlsx", {"Data"}][[1]]][[;; - 2, {8}]];
trainingset = {a -> b};
prediction1 = Predict[trainingset, Method -> "LinearRegression"];
prediction2 = Predict[trainingset, Method -> "DecisionTree"];
At lines where I use Predict[] I got this error:
"Predict: Incompatible variable type (Numerical) and variable value ({{243.73},{242.65},{240.82},{240.87},{239.1},{236.1},{234.5},{238.18},{237.6},{238.91},<<991>>})."
So can someone explain me what's going on here?
UPD: Solved.
$\begingroup$
$\endgroup$
6
Predict
is like {x},{x},{x},. andtrainingset = {a -> b}
is wrong too - it should be of the form{a[[1]]->b[[1]], a[[2]]->b[[2]], ...}
by doingThread[a->b]
$\endgroup$