Issue
I'm learning deep learning and I would like to print this histogram with matplotlib:
from this code who print the data :
lr = LogisticRegression()
lr.fit(X, y)
print(lr.coef_)
who prints :
[[-0.150896 0.23357229 0.00669907 0.3730938 0.100852 -0.85258357]]
edit: I tried the basic hist but I don't understand the output :
plt.hist(lr.coef_)
plt.show()
Solution
As mentioned in the documentation (".. Compute and draw the histogram of .."), pl.hist
bot calculates and plots a histogram from the raw data. For example:
import matplotlib.pylab as pl
import numpy as np
# Dummy data
data = np.random.normal(size=1000)
pl.figure()
pl.subplot(121)
pl.hist(data)
What you want is the pl.bar
function:
# Your data
data = np.array([-0.150896, 0.23357229, 0.00669907, 0.3730938, 0.100852, -0.85258357])
labels = ['as','df','as','df','as','df']
ax=pl.subplot(122)
pl.bar(np.arange(data.size), data)
ax.set_xticks(np.arange(data.size))
ax.set_xticklabels(labels)
Combined this produces:
Answered By - Bart
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.