Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 How to do matrix subtraction
#1
Hi,
I have below two arrays
1. my test data
2. my prediction data

print(y_pred2)
[0 2 0 2 0 0]
print(y_test)
 y
30  0
31  0
32  0
33  0
34  0
35  0

y_test.shape, y_pred2.shape,type(y_test), type(y_pred2)

((6, 1), (6,), pandas.core.frame.DataFrame, numpy.ndarray)

Now I want to calculate the delta between my test data & predict data

error=y_test-y_pred2

it give below error:
ValueError                                Traceback (most recent call last)
<ipython-input-118-3919f3823c1c> in <module>()
----> 1 error=y_test-y_pred2

C:\Users\user\Anaconda3\lib\site-packages\pandas\core\ops.py in f(self, other, axis, level, fill_value)
   1223     def f(self, other, axis=default_axis, level=None, fill_value=None):
   1224 
-> 1225         other = _align_method_FRAME(self, other, axis)
   1226 
   1227         if isinstance(other, pd.DataFrame):  # Another DataFrame

C:\Users\user\Anaconda3\lib\site-packages\pandas\core\ops.py in _align_method_FRAME(left, right, axis)
   1146 
   1147         if right.ndim == 1:
-> 1148             right = to_series(right)
   1149 
   1150         elif right.ndim == 2:

C:\Users\user\Anaconda3\lib\site-packages\pandas\core\ops.py in to_series(right)
   1136         else:
   1137             if len(left.columns) != len(right):
-> 1138                 raise ValueError(msg.format(len(left.columns), len(right)))
   1139             right = left._constructor_sliced(right, index=left.columns)
   1140         return right

ValueError: Unable to coerce to Series, length must be 1: given 6
kindly some help, many thanks in advance
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  numpy subtraction of two arrays devenuro 1 7,288 Sep-24-2018, 12:55 AM
Last Post: Mekire

Forum Jump:


Users browsing this thread: 1 Guest(s)