-1

The image shows the error distribution of the data:

enter image description here

Following is the code for error distribution:

import matplotlib.ticker as ticker
err = (Y_pred - ori_from_bc(Y_test,0.3384))/ori_from_bc(Y_test,0.3384)*100

# Error distribution using histogram
plt.figure(figsize=(7, 4))
ax = sns.distplot(err, color='g', bins=100, hist_kws={'alpha': 0.4},hist=True)
ax.xaxis.set_major_locator(ticker.MultipleLocator(50))
plt.show()

I want to calculate the percentage of test data in the error range of -30% to +30%.

Thanks in advance!

MarianD
  • 13,096
  • 12
  • 42
  • 54
DD1308
  • 1

1 Answers1

0
len(err[(err > np.quantile(err, 0.35)) & (err < np.quantile(err, 0.65))])
vimuth
  • 5,064
  • 33
  • 79
  • 116
  • While this code may solve the question, [including an explanation](//meta.stackexchange.com/q/114762) of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. Please [edit] your answer to add explanations and give an indication of what limitations and assumptions apply. – Yunnosch Aug 15 '22 at 06:43
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 18 '22 at 09:28