Machine Learning
some vanilla classics:
- Neural Network
- Decision Tree
- Gaussian Process
- Nearest Neighbors
Borrowing the formatting from @kglr 's answer above:
gasprices = {{{"Year", "EUR05/GJ"}, {2000., 14.4041}, {2005.,
22.8756}, {2010., 29.1499}, {2015., 29.4374}, {2020.,
30.3778}, {2025., 33.2288}, {2030., 35.099}, {2040.,
36.8245}, {2050., 38.2697}}};
priceseries = gasprices[[1, 2 ;;]];
priceseries[[All, 1]] = Rationalize /@ priceseries[[All, 1]];
gp = priceseries /. {a_, b_} :> {{a}, b};
trainingData = Rule @@@ priceseries;
neuralNet = Predict[trainingData, Method -> "NeuralNetwork"];
decisionTree = Predict[trainingData, Method -> "DecisionTree"];
gaussianProcess = Predict[trainingData, Method -> "GaussianProcess"];
nearestNeighbors = Predict[trainingData, Method -> "NearestNeighbors"];
nNet = Table[{{year}, neuralNet[year]}, {year, 2000, 2050, 1}];
dTree = Table[{{year}, decisionTree[year]}, {year, 2000, 2050, 1}];
gProcess = Table[{{year}, gaussianProcess[year]}, {year, 2000, 2050, 1}];
nNeighbors = Table[{{year}, nearestNeighbors[year]}, {year, 2000, 2050, 1}];
DateListPlot[{gp, nNet, dTree, gProcess, nNeighbors},
Joined -> {False, True, True, True, True},
PlotStyle -> {Directive[PointSize[.03], Opacity[.5], Magenta],
Green, Blue, Red, Black}, Frame -> True, ImageSize -> 500,
PlotLegends -> {"original", "NeuralNetwork", "DecisionTree",
"GaussianProcess", "NearestNeighbors"},
FrameTicks -> {{Automatic, Automatic}, {gp[[All, 1]], Automatic}},
GridLines -> {gp[[All, 1]], None}]
