使用散点图时发生错误:TypeError:无法散列的类型:'numpy.ndarray

时间:2019-10-06 09:22:29

标签: python matplotlib

这是我的代码:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import os
os.chdir("/Users/Jeffin/Desktop")
data =pd.read_csv('ccc.csv')
print(data.shape)

data = data.drop(index=[0])
print(data)

x1 = data.drop(data.columns[0:5],axis=1)
x1= x1.drop(x1.columns[1:25],axis=1)
print(x1)

y1 = data.drop(data.columns[0:12],axis=1)
y1= y1.drop(y1.columns[1:25],axis=1)
print(y1)

from sklearn.model_selection import train_test_split
[x_t, x_r, y_t, y_r]=train_test_split(x1,y1,test_size= 0.3,random_state=0)

from sklearn.linear_model import LinearRegression
model = LinearRegression()
model.fit(x_t,y_t)
pre = model.predict(x_r)
print(pre.shape)
acc = model.score(x_t,y_t)
plt.scatter(x_t,y_t)

我在最后一行遇到错误

回溯(最近通话最近一次):

  File "C:
  File "Clot.py", line 2862, in scatter

...
...

 for val in OrderedDict.fromkeys(data)
TypeError: unhashable type: 'numpy.ndarray'

成为ML的新手可以帮助我解决这个问题。预先感谢。

0 个答案:

没有答案