python - weight issues in scikit-learn's adaboost -


i'm trying use adaboostclassifier decision tree stump base classifier. noticed weight adjustment done adaboostclassifier has been giving me errors both samme.r , samme options.

here's brief overview of i'm doing

def train_adaboost(features, labels):     uniqlabels = np.unique(labels)     alllearners = []     targetlab in uniqlabels:         runs=[]         rrr in xrange(10):             feats,labs = get_binary_sets(features, labels, targetlab)             baseclf = decisiontreeclassifier(max_depth=1, min_samples_leaf=1)             baseclf.fit(feats, labs)              ada_real = adaboostclassifier( base_estimator=baseclf,                                             learning_rate=1,                                             n_estimators=20,                                             algorithm="samme")             runs.append(ada_real.fit(feats, labs))         alllearners.append(runs)      return alllearners 

i looked @ fit every single decision tree classifier , able predict labels. when @ adaboostclassifier using base classifier, however, errors weight boosting algorithm.

def compute_confidence(alllearners, dada, labbo):     ii,thislab in enumerate(alllearners):         jj, thislearner in enumerate(thislab):             #accessing thislearner's methods here  

the methods give errors these:

ipdb> thislearner.predict_proba(mydata)

pathtopackage/lib/python2.7/site-packages/sklearn/ensemble/weight_boosting.py:727: runtimewarning: invalid value encountered in double_scalars proba /= self.estimator_weights_.sum() *** valueerror: 'axis' entry out of bounds

ipdb> thislearner.predict(mydata)

pathtopackage/lib/python2.7/site-packages/sklearn/ensemble/weight_boosting.py:639: runtimewarning: invalid value encountered in double_scalars pred /= self.estimator_weights_.sum() *** indexerror: 0-d arrays can use single () or list of newaxes (and single ...) index

i tried samme.r algorithm adaboost can't fit adaboost in case because of error [...]

file "path/sklearn/ensemble/weight_boosting.py", line 388, in fit return super(adaboostclassifier, self).fit(x, y, sample_weight)

file "path/sklearn/ensemble/weight_boosting.py", line 124, in fit x_argsorted=x_argsorted)

file "path/sklearn/ensemble/weight_boosting.py", line 435, in _boost x_argsorted=x_argsorted)

file "path/sklearn/ensemble/weight_boosting.py", line 498, in _boost_real (estimator_weight < 0)))

valueerror: non-broadcastable output operand shape (1000) doesn't match broadcast shape (1000,1000)

the data's dimensions compatible format classifier expecting, both before using adaboost , when try test trained classifiers. can these errors indicate?

well little counterintuitive, coming coding in matlab.

apparently labs' dimensions issue, (1000,1). needed (1000,)

adding line solved it:

labs = labs[:,0]


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -