seems to be quite linear and so should be relatively easy to predictapart from some bumps we will make forecast for the years after using the historical data up to that pointwith the date as our only feature we will compare two simple modelsa decisiontreeregressor and linearregression we rescale the prices using logarithmso that the relationship is relatively linear this doesn' make difference for the decisiontreeregressorbut it makes big difference for linearregression (we will discuss this in more depth in after training the models and making predictionswe apply the exponential map to undo the logarithm transform we make predictions on the whole dataset for visualization purposes herebut for quantitative evaluation we would only consider the test datasetin[ ]from sklearn tree import decisiontreeregressor use historical data to forecast prices after the year data_train ram_prices[ram_prices date data_test ram_prices[ram_prices date > predict prices based on date x_train data_train date[:np newaxiswe use log-transform to get simpler relationship of data to target y_train np log(data_train pricetree decisiontreeregressor(fit(x_trainy_trainlinear_reg linearregression(fit(x_trainy_trainpredict on all data x_all ram_prices date[:np newaxispred_tree tree predict(x_allpred_lr linear_reg predict(x_allundo log-transform price_tree np exp(pred_treeprice_lr np exp(pred_lrfigure - created herecompares the predictions of the decision tree and the linear regression model with the ground truthin[ ]plt semilogy(data_train datedata_train pricelabel="training data"plt semilogy(data_test datedata_test pricelabel="test data"plt semilogy(ram_prices dateprice_treelabel="tree prediction"plt semilogy(ram_prices dateprice_lrlabel="linear prediction"plt legend(supervised machine learning algorithms