

- #SETTING AN ARRAY ELEMENT WITH A SEQUENCE SKLEARN HOW TO#
- #SETTING AN ARRAY ELEMENT WITH A SEQUENCE SKLEARN CODE#
Pl.plot(n_trees, bdt_discrete.estimator_weights_, "b", label='SAMME') Pl.plot(n_trees, bdt_real.estimator_errors_, "r", label='SAMME.R', alpha=.5)īdt_discrete.estimator_errors_.max()) * 1.2)) Pl.plot(n_trees, bdt_discrete.estimator_errors_, "b", label='SAMME', alpha=.5) Pl.plot(n_trees, real_test_errors, c='black', Pl.plot(n_trees, discrete_test_errors, c='black', label='SAMME') N_trees = xrange(1, len(bdt_discrete) + 1) accuracy_score(discrete_train_predict, y_test)) accuracy_score(real_test_predict, y_test))ġ.
#SETTING AN ARRAY ELEMENT WITH A SEQUENCE SKLEARN CODE#
#now all the code below is straight off the example on scikit-learn's websiteįor real_test_predict, discrete_train_predict in zip(īdt_real.staged_predict(X_test), bdt_discrete.staged_predict(X_test)):ġ. Y_train, y_test = labels, labels # 3 images with vehicles, 4 without X_train, X_test = img_hogs, X # all first ten images with vehicles Labels = įilepath = "C:\PATH_TO_SAMPLE_IMAGES\\" + fileĬurr_img = color.rgb2gray(io.imread(filepath))įd, hog_image = hog(curr_img, orientations=8, pixels_per_cell=(16, 16), # 13 of the images are with vehicles, 4 are without

The following is my code, adapted from the example on the scikit-learn website: f = open("PATH_TO_SAMPLES\\samples.txt",'r') If the shape of X is not (nsamples, nfeatures), you need to reshape X. The first step is to check the shape of the input features (X).
#SETTING AN ARRAY ELEMENT WITH A SEQUENCE SKLEARN HOW TO#
ValueError: setting an array element with a sequence. How to Solve ValueError: setting an array element with a sequence Step 1: Check the Shape of the Input Features (X). Return array(a, dtype, copy=False, order='C', ndmin=1) X = np.ascontiguousarray(array2d(X), dtype=DTYPE)įile "C:\Users\app\Anaconda\lib\site-packages\numpy\core\numeric.py", line 408, in ascontiguousarray Return super(AdaBoostClassifier, self).fit(X, y, sample_weight)įile "C:\Users\app\Anaconda\lib\site-packages\sklearn\ensemble\weight_boosting.py", line 99, in fit Traceback (most recent call last):įile "C:\Users\app\Documents\Python Scripts\carclassify.py", line 66, in įile "C:\Users\app\Anaconda\lib\site-packages\sklearn\ensemble\weight_boosting.py", line 389, in fit I've edited the provided example only a bit, to include my own image files, but I'm getting an error. I used integer labels because according to the example in the link above, the training data consists of integer-based labels. My current test is quite small, only 17 images in all, 10 for training, 7 for testing.įor now I have two classes: 0: no vehicle, 1: vehicle present Then I'm going to extend my samples to include other classes. fit() and finish the data using PCA or scaler. and next If my data was ok, what i must do before, to make it possible to do some. must I need change the data format or type or something if yes, tell me must be like that, and how to be like that if possible. Using the tutorial on multiclass adaboost, I'm trying to classify some images that have two classes (but I don't suppose the algorithm shouldn't work if the problem is binary). ValueError: setting an array element with a sequence.
