我的代码如下。我比较了两组学校,一组是系统,另一组是系统的同学。 这是在找到here指示后建模的。
plt.figure(figsize=(10,8))
plt.scatter(sys_peers_sat_earning['MD_EARN_WNE_P6'][sys_peers_sat_earning['SystemorPeer'] == 'USM'],
sys_peers_sat_earning['SAT_AVG'][sys_peers_sat_earning['SystemorPeer'] == 'USM'],
marker='x',
color='b',
alpha=0.7,
s = 124,
label='USM Schools')
plt.scatter(sys_peers_sat_earning['MD_EARN_WNE_P6'][sys_peers_sat_earning['SystemorPeer'] == 'Peer'],
sys_peers_sat_earning['SAT_AVG'][sys_peers_sat_earning['SystemorPeer'] == 'Peer'],
marker='x',
color='b',
alpha=0.7,
d = 124,
label='USM Peers')
plt.title('SATs and Earnings of Students Not Enrolled 6 Yrs. After Entry')
plt.ylabel('Median earnings of students working and not enrolled 6 years after entry')
plt.xlabel('Average SAT equivalent score of students admitted')
X_train[:,0]
plt.legend(loc='upper right')
提及X_train[:,0]
ValueError: x and y must be the same size
行的错误如下:>>> col1 = ['Hello', 'Hello', 'Hello', 'Hi', 'Hi']
>>> col2 = ['World', 'Earth', 'Planet', 'Mars', 'Moon']
有人可以跟我说话,就像我有两个关于如何编辑这个的步骤一样吗?
答案 0 :(得分:1)
错误表明
sys_peers_sat_earning['MD_EARN_WNE_P6'][sys_peers_sat_earning['SystemorPeer'] == 'USM']
(你的x值)
的大小与
不同sys_peers_sat_earning['SAT_AVG'][sys_peers_sat_earning['SystemorPeer'] == 'USM']
(你的y值)
通过将它们分别重命名为x和y来确认这一点,并检查它们的长度:
len(x) == len(y)
这将告诉你x和y是否确实是相同的大小。