You are passing floats to a classifier which expects categorical values as the target vector. If you convert it to int
it will be accepted as input (although it will be questionable if that’s the right way to do it).
It would be better to convert your training scores by using scikit’s labelEncoder
function.
The same is true for your DecisionTree and KNeighbors qualifier.
from sklearn import preprocessing from sklearn import utils lab_enc = preprocessing.LabelEncoder() encoded = lab_enc.fit_transform(trainingScores) >>> array([1, 3, 2, 0], dtype=int64) print(utils.multiclass.type_of_target(trainingScores)) >>> continuous print(utils.multiclass.type_of_target(trainingScores.astype('int'))) >>> multiclass print(utils.multiclass.type_of_target(encoded)) >>> multiclass
Related Posts:
- TypeError: only length-1 arrays can be converted to Python scalars while plot showing
- ValueError: Unknown label type: ‘continuous’
- Converting list to numpy array
- How to normalize a NumPy array to a unit vector?
- Syntax in Python (.T)
- How to normalize a NumPy array to a unit vector?
- Numpy/Python Array Value error
- Calculating Covariance with Python and Numpy
- Python reshape list to ndim array
- Python – TypeError: Object of type ‘int64’ is not JSON serializable
- How to implement the Softmax function in Python
- RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility
- Error: Microsoft Visual C++ 10.0 is required (Unable to find vcvarsall.bat) when running Python script
- Numpy float64 vs Python float
- Calculate the Cumulative Distribution Function (CDF) in Python
- Python can’t multiply sequence by non-int of type ‘float’
- ImportError in importing from sklearn: cannot import name check_build
- TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array
- TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array
- ImportError: DLL load failed: The specified module could not be found
- ImportError: DLL load failed: The specified module could not be found
- numpy array: IndexError: too many indices for array
- Import Error: No module named numpy
- Python3 – ModuleNotFoundError: No module named ‘numpy’
- ValueError: setting an array element with a sequence
- ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- Curve curvature in numpy
- numpy max vs amax vs maximum
- ImportError: No module named sklearn.cross_validation
- ImportError: No module named sklearn.cross_validation
- How can I prevent the TypeError: list indices must be integers, not tuple when copying a python list to a numpy array?
- What exactly does numpy.exp() do? [closed]
- Converting NumPy array into Python List structure?
- The difference between comparison to np.nan and isnull()
- Difference between import numpy and import numpy as np
- No module named ‘sklearn.cross_validation’
- What is the purpose of meshgrid in Python / NumPy?
- why numpy.ndarray is object is not callable in my simple for python loop
- numpy division with RuntimeWarning: invalid value encountered in double_scalars
- Numpy ValueError: setting an array element with a sequence. This message may appear without the existing of a sequence?
- numpy: Invalid value encountered in true_divide
- python numpy ValueError: operands could not be broadcast together with shapes
- How to fix ‘Object arrays cannot be loaded when allow_pickle=False’ for imdb.load_data() function?
- How do I create an empty array/matrix in NumPy?
- Most efficient way to find mode in numpy array
- TypeError: unhashable type: ‘numpy.ndarray’
- How to fix IndexError: invalid index to scalar variable
- Could not install packages due to a “Environment error :[error 13]: permission denied : ‘usr/local/bin/f2py'”
- numpy division with RuntimeWarning: invalid value encountered in double_scalars
- How does numpy.newaxis work and when to use it?
- numpy matrix vector multiplication
- XGBoost XGBClassifier Defaults in Python
- sklearn error ValueError: Input contains NaN, infinity or a value too large for dtype(‘float64’)
- How do I read CSV data into a record array in NumPy?
- sklearn error ValueError: Input contains NaN, infinity or a value too large for dtype(‘float64’)
- TypeError: cannot perform reduce with flexible type
- data type not understood
- How do you do natural logs (e.g. “ln()”) with numpy in Python?
- sklearn error ValueError: Input contains NaN, infinity or a value too large for dtype(‘float64’)
- How do I read CSV data into a record array in NumPy?
- Plotting a 2D heatmap with Matplotlib
- Should I use np.absolute or np.abs?
- What does numpy.random.seed(0) do?
- ModuleNotFoundError: No module named ‘sklearn’
- ImportError: numpy.core.multiarray failed to import
- Factorial in numpy and scipy
- What does the c underscore expression `c_` do exactly?
- Convert pandas dataframe to NumPy array
- Arrays used as indices must be of integer (or boolean) type
- ImportError: Missing required dependencies [‘numpy’]
- How can I plot a confusion matrix? [duplicate]
- Unable to plot Double Bar, Bar plot using pyplot for ndarray
- ModuleNotFoundError: No module named ‘sklearn’
- Error: all the input array dimensions except for the concatenation axis must match exactly
- ImportError: numpy.core.multiarray failed to import
- How to count the occurrence of certain item in an ndarray?
- size of NumPy array
- Singular matrix issue with Numpy
- Python Pandas – Missing required dependencies [‘numpy’] 1
- numpy array concatenate: “ValueError: all the input arrays must have same number of dimensions”
- How to find all occurrences of an element in a list
- TypeError: ‘numpy.float64’ object is not callable
- TypeError: ‘numpy.float64’ object is not callable
- ‘DataFrame’ object has no attribute ‘sort’
- Convert a tensor to numpy array in Tensorflow?
- ‘DataFrame’ object has no attribute ‘sort’
- Convert a tensor to numpy array in Tensorflow?
- ValueError: all the input arrays must have same number of dimensions
- TypeError: cannot unpack non-iterable int objec
- ValueError: setting an array element with a sequence
- filename.whl is not a supported wheel on this platform
- ImportError: No module named sklearn (Python)
- Using Numpy Vectorize on Functions that Return Vectors
- Use a.any() or a.all()
- TypeError: ‘numpy.float64’ object is not callable?
- ‘DataFrame’ object has no attribute ‘sort’
- Convert a tensor to numpy array in Tensorflow?
- How to raise a numpy array to a power? (corresponding to repeated matrix multiplications, not elementwise)
- convert nan value to zero
- What is dtype(‘O’), in pandas?