def ratios(x, y, z): predictions = list(df['Predictions'])[:-1] price = list(df['Price'])[:-1] corrects = [] for i in range(len(predictions)-y, len(predictions)-z): if (predictions[i] * (1.0 + (x/100.0))) > price[i] > (predictions[i] * (1.0 - (x/100.0))): corrects.append(1.0) else: corrects.append(0.0) return np.average(corrects) * 100 def mape(y_true, y_pred): y_true, y_pred = np.array(y_true), np.array(y_pred) return np.mean(np.abs((y_true - y_pred) / y_true)) * 100
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter