spotplex.blogg.se

Setting an array element with a sequence sklearn
Setting an array element with a sequence sklearn





  1. #SETTING AN ARRAY ELEMENT WITH A SEQUENCE SKLEARN HOW TO#
  2. #SETTING AN ARRAY ELEMENT WITH A SEQUENCE SKLEARN CODE#

Pl.ylim((0, bdt_discrete.estimator_weights_.max() * 1. 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))

setting an array element with a sequence sklearn

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')

setting an array element with a sequence sklearn

ValueError: setting an array element with a sequence. 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 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#

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 How to Solve ValueError: setting an array element with a sequence Step 1: Check the Shape of the Input Features (X). tfvectorizer CountVectorizer () tf tfvectorizer.fittransform (tokenslist) svd TruncatedSVD (100) lsa makepipeline (svd, Normalizer (copyFalse)) lsatf lsa.fittransform (tf. Im trying to compute the cosine similarity on the result of a K-Means algorithm. 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 setting an array element with a sequence Scikit learn cosinesimilarity. 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.

setting an array element with a sequence sklearn

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. 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).







Setting an array element with a sequence sklearn