Extrapolate data from Predict function

I'm trying to predict the next Close value in the S&P500 index using the following code:

data = SemanticImport["http://real-chart.finance.yahoo.com/table.csv?s=SPY&a=00&b=29&c=\
2015&d=10&e=4&f=2016&g=d&ignore=.csv"]

training = data[[;; 350]];
test = data[[351 ;;]];

p = Predict[training -> "Close", PerformanceGoal -> "Quality", Method -> "NeuralNetwork"]


I now want to find the predicted value for the 5th of November, but I'm unsure how to format this. I have tried the following, but this returns an error saying that the data is not formatted correctly.

p[DateObject[{2016, 11, 05}]]


Any help would be appreciated.

• Examining the FullForm of data[[1]] and checking with the docs of Predict leads to p[<|"Date" -> DateObject[{2016, 11, 05}]|>], what yields 226.454. – corey979 Nov 22 '16 at 19:55
• @corey979 Thanks. Also, is there a way to plot the current data along with the predicted data on a graph? – aL_eX Nov 22 '16 at 20:16
• I'm getting nonsensical outputs, but I'm unfamiliar with Association and Dataset, so I'll restrain from causing confusion. – corey979 Nov 22 '16 at 20:54

Here is an example of comparing the predicted and true data:

Train the network using the "Date" and "Open" to predict "Close"

p = Predict[training[[All, {"Date", "Open", "Close"}]] -> "Close",
PerformanceGoal -> "Quality", Method -> "NeuralNetwork"]


This shows how well it performs on the training data

DateListPlot[{Normal@training[All, {"Date", "Close"}],
Normal@training[All, {"Date", "Open"}][All, {"Date", p}]}]


This shows the same for the testing data

DateListPlot[{Normal@test[All, {"Date", "Close"}],
Normal@test[All, {"Date", "Open"}][All, {"Date", p}]},
PlotLegends -> Placed[{"data", "predicted"}, Top]]