本文整理汇总了Python中sklearn.ensemble.AdaBoostClassifier.fitted方法的典型用法代码示例。如果您正苦于以下问题:Python AdaBoostClassifier.fitted方法的具体用法?Python AdaBoostClassifier.fitted怎么用?Python AdaBoostClassifier.fitted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.ensemble.AdaBoostClassifier
的用法示例。
在下文中一共展示了AdaBoostClassifier.fitted方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: train_test_split
# 需要导入模块: from sklearn.ensemble import AdaBoostClassifier [as 别名]
# 或者: from sklearn.ensemble.AdaBoostClassifier import fitted [as 别名]
import pandas as pd
from sklearn.ensemble import AdaBoostClassifier
from sklearn.metrics import confusion_matrix
from sklearn.metrics import accuracy_score
from sklearn.cross_validation import train_test_split
data = pd.read_csv("C:\\Users\\User\\Desktop\\iris_data.csv")
#print(data)
data.features = data[["SepalLength","SepalWidth","PetalLength","PetalWidth"]]
data.targets = data.Class
feature_train, feature_test, target_train, target_test = train_test_split(data.features, data.targets, test_size=.2)
model = AdaBoostClassifier(n_estimators=100,learning_rate=1,random_state=123)
model.fitted = model.fit(feature_train, target_train)
model.predictions = model.fitted.predict(feature_test)
print(confusion_matrix(target_test, model.predictions))
print(accuracy_score(target_test, model.predictions))