How avoid error "TypeError: invalid data type for einsum" in Python -
i try load csv file numpy-array , use array in logisticregression etc. now, struggling error shown below:
import numpy np import pandas pd sklearn import preprocessing sklearn.linear_model import logisticregression dataset = pd.read_csv('../bookie_test.csv').values x = dataset[1:, 32:34] y = dataset[1:, 14] # normalize data attributes normalized_x = preprocessing.normalize(x) # standardize data attributes standardized_x = preprocessing.scale(x) model = logisticregression() model.fit(x, y) print(model) # make predictions expected = y predicted = model.predict(x) # summarize fit of model print(metrics.classification_report(expected, predicted)) print(metrics.confusion_matrix(expected, predicted))
i got error:
> c:\anaconda32\lib\site-packages\sklearn\utils\validation.py:332: > userwarning: normalize function assumes floating point values > input, got object "got %s" % (estimator, x.dtype)) traceback (most > recent call last): file > "x:/test3.py", line 23, in > <module> > normalized_x = preprocessing.normalize(x) file "c:\anaconda32\lib\site-packages\sklearn\preprocessing\data.py", line > 553, in normalize > norms = row_norms(x) file "c:\anaconda32\lib\site-packages\sklearn\utils\extmath.py", line 65, > in row_norms > norms = np.einsum('ij,ij->i', x, x) typeerror: invalid data type einsum
i new in python , don't transformation:
- load csv pandas
- convert pandas numpy
- use numpy in logisticregression
are there simple approach, like:
- load pandas
- use pandas dataframes in ml methods?
regarding main question, evert
advises check.
regarding #2: found great tutorial http://www.markhneedham.com/blog/2013/11/09/python-making-scikit-learn-and-pandas-play-nice/
and achieved desired result pandas
+ sklearn
Comments
Post a Comment