AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
![]() Sgdc = SGDClassifier(max_iter=1000, tol=0. ![]() Now we expand the entries into columns and this works: X_expanded = pd.DataFrame(X.tolist()) If I run your code I get the same error: from sklearn.model_selection import train_test_splitĬheck that every entry has same length, you should get only 1 value: X.apply(len).value_counts() For example, this looks like your data frame: X = pd.DataFrame() So assuming the length of each array is the same, you can expand the columns into a dataframe with the correct number of columns. ValueError: setting an array element with a sequence.įrom the image, it looks like you have an array embedded for every value in 'pixel_grayscale'. > 83 return array(a, dtype, copy=False, order=order) usr/local/lib/python3.7/dist-packages/numpy/core/_asarray.py in asarray(a, dtype, order) ValueError Traceback (most recent call last) The above exception was the direct cause of the following exception: TypeError: only size-1 arrays can be converted to Python scalars TypeError Traceback (most recent call last) I have the following code import pandas from sklearn import svm from sklearn import preprocessing import ast import array import numpy as np ''' list for i in range(0, 10): fakeList i. Validation_fraction=0.1, verbose=0, warm_start=False) Power_t=0.5, random_state=None, shuffle=True, tol=0.01, Can someone please help, because I don't know what I'm doing wrong. I tried searching online, but I can't didn't find a good solution to my problem. Max_iter=1000, n_iter_no_change=5, n_jobs=None, penalty='l2', ValueError: setting an array element with a sequence. This is the error : SGDClassifier(alpha=0.0001, average=False, class_weight=None,Įarly_stopping=False, epsilon=0.1, eta0=0.0, fit_intercept=True, X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.30, random_state=42)įrom sklearn.linear_model import SGDClassifier Pixel_grayscale(row.file) if row.category = 0 else pixel_grayscale(row.file+" chi"), axis=1)įrom sklearn.model_selection import train_test_split Image = cv2.resize(image,(128,128), interpolation=cv2.INTER_CUBIC)Įxtract = extract.apply(lambda row: Image = imread("muf/"+file, as_gray=True) Image = imread("chi/"+file, as_gray=True) I did resize my images so that they were all the same shape. I think it's a problem with the shape of my arrays but I don't understand how to solve it. I am trying to use the SGCD model of Scikit Learn but I have an error.
0 Comments
Read More
Leave a Reply. |