Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel(). y = column_or_1d(y, warn=True)

model = forest.fit(train_fold, train_y.values.ravel())
Comment

DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel(). y = column_or_1d(y, warn=True)

model = forest.fit(train_fold, train_y.values.ravel())

Explanation:

.values will give the values in a numpy array (shape: (n,1))

.ravel will convert that array shape to (n, ) (i.e. flatten it)
Comment

PREVIOUS NEXT
Code Example
Python :: read emails from gmail python 
Python :: clone website 
Python :: seaborn correlation heatmap 
Python :: str to tuple of float 
Python :: flask migrate 
Python :: python lambda function map 
Python :: how to import from parent directory 
Python :: Python list of dictionaries search 
Python :: how to make a random variable in python 
Python :: dataframe KeyError: 
Python :: strip first occurence of substring python 
Python :: python recursively print directory 
Python :: Pandas categorical dtypes 
Python :: Adding function to a varieble in python 
Python :: python how to make notepad 
Python :: change value in excel using python 
Python :: python string: iterate string 
Python :: what does .shape do in python 
Python :: how to merge two dictionaries in python 
Python :: pandas read csv skip rows 
Python :: python flatten list 
Python :: replace none with empty string python 
Python :: python foreach list 
Python :: Accessing elements from a Python Dictionary 
Python :: first and last digit codechef solution 
Python :: matplotlib savefig size 
Python :: random split train test in python 
Python :: uninstall python linux 
Python :: simple graph in matplotlib categorical variables 
Python :: How to wait a page is loaded in Python Selenium 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =