having problem in making matrix in python

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • linguist
    New Member
    • Jun 2016
    • 1

    having problem in making matrix in python

    I want to make a matrix with 5 rows and 4 columns. The problem is when I run it there appears an error that "Traceback (most recent call last): File "C:\Users\yasin i\Desktop\30.py ", line 21, in ['ART|Ф',0.71], ['N|Ф',0.29], ['V|Ф',0.0001], ['P|Ф',0]]).reshape(5,4) ValueError: total size of new array must be unchanged".

    How can I solve it?

    import numpy as np
    A = np.array([['ART|ART',0], ['N|ART',1], ['V|ART',0], ['P|ART',0],
    ['ART|N',0.0001], ['N|N',0.13], ['V|N',0.43], ['P|N',0.44],
    ['ART|V',0.65], ['N|V',0.35], ['V|V',0.0001], ['P|V',0.0001],
    ['ART|P',0.74], ['N|P',0.26], ['V|P',0.0001], ['P|P',0.0001],
    ['ART|Ф',0.71], ['N|Ф',0.29], ['V|Ф',0.0001], ['P|Ф',0]]).reshape(5,4)
    print (A)



    When I omit the zero from the last cell (['P|Ф',0]), it works right and a 5*4 matrix is produced but when I add zero again this error occurs.
Working...