我正在使用下面的代码在seaborn中生成一个图表。我已经包含了score_train
、score_test
和alphas
的值,以便在尝试运行我的代码时可以进行复制。
alphas = [0.00000000e+00, 3.12213617e-05, 3.41931065e-05, 9.09382510e-05,
1.42111604e-04, 1.50323881e-04, 2.89300778e-04, 3.20398837e-04,
3.26079390e-04, 3.67602501e-04, 4.24184679e-04, 4.34481263e-04,
4.90132981e-04, 5.62078948e-04, 5.85072664e-04, 6.78360178e-04,
7.93980204e-04, 8.07864745e-04, 9.61382275e-04, 1.29066450e-03,
1.40562637e-03, 1.46742025e-03, 1.66062768e-03, 1.72203321e-03]
score_train = [0.0104715802718085,
0.010458280337911519,
0.010443714475584676,
0.010443714475584676,
0.010344437970874143,
0.010280401760789704,
0.010280401760789704,
0.010157163022360027,
0.009881770880034169,
0.00988177088003428,
0.0097251765261126,
0.009544478827850478,
0.008756729180697365,
0.008038412062383204,
0.008038412062383316,
0.007789177969584338,
0.007211231010840424,
0.006528863850344235,
0.006528863850344235,
0.0055695183357952205,
0.0055695183357952205,
0.0043456341750442995,
0.0043456341750444105,
0.0014375284078337325]
score_test = [-0.013180580298218336,
-0.013160472761265751,
-0.013151821204646863,
-0.013151821204646863,
-0.013165861122794942,
-0.013197005960391195,
-0.013197005960391195,
-0.013046889005794426,
-0.013122528043505444,
-0.013122528043505444,
-0.013673242248775308,
-0.013585443618303605,
-0.01417799133998554,
-0.014195521870022931,
-0.01419552187002271,
-0.009323258408655777,
-0.0023269067131193033,
-0.00362963279693429,
-0.003629632796934512,
-0.0045420007912404525,
-0.0045420007912404525,
-0.0018079981576566428,
-0.0018079981576566428,
-0.00034014856624420275]
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
sns.set()
plt.figure(figsize=(14,7))
sns.lineplot(y=score_train,x=alphas,label="Training Score")
sns.lineplot(y=score_test,x=alphas,label="Testing Score")
plt.xticks(ticks=np.arange(0.000000,0.0001,0.001000))
plt.show()
字符串
以下是我得到的图片:
的数据
正如你所看到的,我看不到x轴上的值。我做错什么了?
1条答案
按热度按时间jdgnovmf1#
np.arange(0.000000,0.0001,0.001000)
是array([0.])
,因为您的步骤(0.001
)大于开始(0.0
)和停止(0.0001
)之间的差值。您可能需要使用
np.arange(0., 0.001, 0.0001)
。