It looks like your ‘trainData’ is a list of strings:
['-214' '-153' '-58' ..., '36' '191' '-37']
Change your ‘trainData’ to a numeric type.
import numpy as np
np.array(['1','2','3']).astype(np.float)
More Related Contents:
- sklearn error ValueError: Input contains NaN, infinity or a value too large for dtype(‘float64’)
- Clustering text documents using scikit-learn kmeans in Python
- confused about random_state in decision tree of scikit learn
- What is wrong with my python code? [duplicate]
- how to count average sentence length (in words) from a text file contains 100 sentences using python [closed]
- What needs to be added
- Python 2.7 IndentationError [closed]
- How to detect key presses?
- List vs generator comprehension speed with join function [duplicate]
- Launch a completely independent process
- Why does str(float) return more digits in Python 3 than Python 2?
- Add pygame module in PyCharm IDE
- ReactorNotRestartable error in while loop with scrapy
- Save classifier to disk in scikit-learn
- How to pass an operator to a python function?
- How to read Unicode input and compare Unicode strings in Python?
- How to do n-D distance and nearest neighbor calculations on numpy arrays
- How to convert a Scikit-learn dataset to a Pandas dataset
- Absolute imports in python not working, relative imports work
- Python datetime.utcnow() returning incorrect datetime
- Networkx: Overlapping edges when visualizing MultiGraph
- Scikit-learn: How to obtain True Positive, True Negative, False Positive and False Negative
- Mixing files and loops
- Read Outlook Events via Python
- string encoding and decoding?
- Why does “%-d”, or “%-e” remove the leading space or zero?
- How to count top 10 most common values in a dict in python
- Decorator error: NoneType object is not callable
- How to measure download speed and progress using requests?
- Can Syntax Errors be handled?