How to plot a histogram for each sample from a 2D-array

Viewed 52

On a dataset, I fitted one machine learning model multiples time and I collected the predictions in a NumPy array. The shape of the NumPy array is (400, 250) where 250 is the number of times I fitted the model and 400 is the number of the test samples.

Now, I wanted to see the histogram for each sample's prediction. In a more elegant way, I want to see the histogram of how the prediction differs one from another.

I am trying the below code

plt.hist(rep_predictions.T, orientation='horizontal', bins=10)
plt.xlabel("Samples")
plt.ylabel(f"Predicted Value of the LinReg model")
plt.title(f"All Predicted vs Samples")

I am getting the below figure (though it does not fulfill my expectation)

histogram fig

Is it feasible to see the histogram of each sample's multiple predictions? My expectation is, there will be samples on the x-axis, and the prediction value will be on the y-axis.

0 Answers
Related