“Got 1 columns instead of …” error in numpy

后端 未结 8 699
傲寒
傲寒 2021-01-17 13:00

I\'m working on the following code for performing Random Forest Classification on train and test sets;

from sklearn.ensemble import RandomForestClassifier
fr         


        
8条回答
  •  北荒
    北荒 (楼主)
    2021-01-17 13:39

    You have too many columns in one of your rows. For example

    >>> import numpy as np
    >>> from StringIO import StringIO
    >>> s = """
    ... 1 2 3 4
    ... 1 2 3 4 5
    ... """
    >>> np.genfromtxt(StringIO(s),delimiter=" ")
    Traceback (most recent call last):
      File "", line 1, in 
      File "/usr/lib64/python2.6/site-packages/numpy/lib/npyio.py", line 1654, in genfromtxt
        raise ValueError(errmsg)
    ValueError: Some errors were detected !
        Line #2 (got 5 columns instead of 4)
    

提交回复
热议问题