本文整理汇总了Python中sklearn.ensemble.AdaBoostRegressor.predict_proba方法的典型用法代码示例。如果您正苦于以下问题:Python AdaBoostRegressor.predict_proba方法的具体用法?Python AdaBoostRegressor.predict_proba怎么用?Python AdaBoostRegressor.predict_proba使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.ensemble.AdaBoostRegressor
的用法示例。
在下文中一共展示了AdaBoostRegressor.predict_proba方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: return
# 需要导入模块: from sklearn.ensemble import AdaBoostRegressor [as 别名]
# 或者: from sklearn.ensemble.AdaBoostRegressor import predict_proba [as 别名]
clf.fit(subTrainFeature, subTrainLabel)
predictedTrainProb = clf.predict(trainFeature)
predictedTestProb = clf.predict(testFeature)
for item in predictedTrainProb:
newTrainFeature_temp.append(item)
for item in predictedTestProb:
newTestFeature_temp.append(item)
newTrainFeature.append(newTrainFeature_temp)
newTestFeature.append(newTestFeature_temp)
newTrainFeature = np.array(newTrainFeature).T
newTestFeature = np.array(newTestFeature).T
clf = linear_model.LogisticRegression(penalty='l2', dual=False, class_weight='auto')
clf.fit(newTrainFeature, trainLabel)
predictedLabel = clf.predict_proba(newTestFeature)
return(predictedLabel[:, 0])
if(__name__ == "__main__"):
trainFeature, trainLabel, testFeature, testPlatform = readFeature(5, 0.5, 10, 0.6, 15, 0.6, 5, 0.6, 1)
'''
selectFeature = SelectKBest(chi2, k = 55)
selectFeature.fit(trainFeature, trainLabel)
trainFeature_new = selectFeature.transform(trainFeature)
testFeature_new = selectFeature.transform(testFeature)
'''
trainFeature_new = trainFeature[:, :]
testFeature_new = testFeature[:, :]
'''
trainFeature_new = trainFeature[:, :26]
testFeature_new = testFeature[:, :26]
示例2: GradientBoostingClassifier
# 需要导入模块: from sklearn.ensemble import AdaBoostRegressor [as 别名]
# 或者: from sklearn.ensemble.AdaBoostRegressor import predict_proba [as 别名]
pred = calibrated_clf.predict_proba(dtest)
sample = pd.read_csv('/Users/IkkiTanaka/Documents/KDDCup/sampleSubmission.csv',header=None)
preds = pd.concat([sample[0],pd.DataFrame(pred[:,1])],axis=1)
preds.to_csv('/Users/IkkiTanaka/Documents/KDDCup/pred/xgb/sk_GBM2.csv' ,header=None,index=False)
new_label = a.sort(0).iloc[(a.sort(0)[0]>0.01).values][1].values
clf = GradientBoostingClassifier(n_estimators=400,learning_rate=0.05,subsample=.96,max_depth=4,verbose=1,max_features=.96, random_state=None)
new_dtrain_sp = dtrain_sp[new_label]
new_dval = dval[new_label]
clf.fit(dtrain_sp, label_dtrain[0].values)
pred = clf.predict_proba(dval)
print("ROC score", metrics.roc_auc_score(label_dval[0].values, pred[:,1]))
#GaussianNB
from sklearn.naive_bayes import GaussianNB
clf = GaussianNB()
clf.fit(dtrain_sp, label_dtrain[0].values)
pred = clf.predict_proba(dval)
print("ROC score", metrics.roc_auc_score(label_dval[0].values, pred[:,1]))
scaler = StandardScaler()
dtrain_sp = scaler.fit_transform(dtrain_sp)
dval = scaler.transform(dval)