0

Here is my code:

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)

I am getting error in the last line as

Traceback (most recent call last):

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

...
...

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

Being new to ML help me to solve this. Thanks in advance.

3
  • the line causing the error for val in OrderedDict.fromkeys(data) isn't in the code you posted, please edit the question to show the actual code, or post the full error traceback Commented Oct 6, 2019 at 9:25
  • It is probably because shape of x_t and y_t doesn't match. What are their shapes? Commented Oct 6, 2019 at 9:44
  • From the docs: matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.scatter.html. This requires an array type, but you have ndarray, which is a multidimensional represenation of array. So, try to convert your ndarray to array like type. See for example this: stackoverflow.com/questions/18200052/… Commented Oct 6, 2019 at 9:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.