2 Star 1 Fork 1

mayanhui/smoke_recognition

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
algo_AdaBoost.py 970 Bytes
一键复制 编辑 原始数据 按行查看 历史
lancezhange 提交于 2015-12-08 21:50 . first commit
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: lancezhange
# @Date: 2015-08-21 15:00:04
# @Last Modified by: lancezhange
# @Last Modified time: 2015-08-21 15:03:12
from sklearn.ensemble import AdaBoostClassifier
from sklearn import metrics
def getModel(x_train, x_test, y_train, y_test, print_metrics=True):
'''
Trains a classifier. Here we use AdaBoost.
Args:
x_train (array of array): feature arrays of training data.
x_test (array of array): feature arrays of testing data.
y_train (array ): label arrays of training data.
y_test (array ): label arrays of testing data.
Returns:
A classifier (sklearn.ensemble.AdaBoostClassifier).
'''
clf = AdaBoostClassifier(n_estimators=100)
classifier = clf.fit(x_train, y_train)
if print_metrics:
print('classifier score')
print(metrics.classification_report(y_test,
classifier.predict(x_test)))
return classifier
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/TimVerion/smoke_recognition.git
git@gitee.com:TimVerion/smoke_recognition.git
TimVerion
smoke_recognition
smoke_recognition
master

搜索帮助