ML assignment #1
ML assignment #1
Problem:
implement classification model to train the Iris dataset and make predictions.
Environment:
Navigator and Jupyter notebook
Language:
python 2.7
Module:
graphlab, matplotlib
Workflow:
1、decision tree using trainset and testset
首先使用graphlab.SFrame.read_csv(“Iris.csv”)導入數據集,然後將數據集,然後將其random split為trainset 和 testset,使用graphlab.decision_tree_classifier.create(train_data,target = target,features = features)
訓練model.該function會自動進行pruning 來防止overfitting.
訓練結果:

接著使用model.evaluate()分析預測準確率,準確率結果為:0.9629629629629629
使用model.predict()對testset做出prediction,檢驗訓練模型. 並用 matplotlib畫出confusion matrix.
confusion matrix:

2、decision tree using K-fold cross validation
首先使用 graphlab.cross_validation.KFold(iris,10)將iris數據集進行10-fold拆分. 然後loop進行模型訓練,計算平均誤差.
最後的平均正確率結果為: 0.926666666667, 更佳符合實際.
3、decision using boosting
graphlab.boosted_trees_classifier.create(train_data,target=target,features=features)
對 train_data用boosting進行訓練,從結果中可以發現,耗時優於上面其他decision tree 算法.

接著使用model.evaluate()分析預測準確率,準確率結果為:0.9629629629629629
使用model.predict()對testset做出prediction,檢驗訓練模型. 並用 matplotlib畫出confusion matrix.
4、using random forest graphlab.random_forest_classifier.create(train_data,target=target,features=features)
對 train_data進行random forest訓練.
結果如下:
會發現耗時較長,效率較差.

Conclusion:
總共使用了四種方法來對Iris 數據集進行模型訓練,其中1,3,4準確率相等,2略低但更符合test結果.所有的模型的confusion matrix均相同.
ML assignment #1的更多相关文章
- Programming Assignment 5: Kd-Trees
用2d-tree数据结构实现在2维矩形区域内的高效的range search 和 nearest neighbor search.2d-tree有许多的应用,在天体分类.计算机动画.神经网络加速.数据 ...
- Spark ML下实现的多分类adaboost+naivebayes算法在文本分类上的应用
1. Naive Bayes算法 朴素贝叶斯算法算是生成模型中一个最经典的分类算法之一了,常用的有Bernoulli和Multinomial两种.在文本分类上经常会用到这两种方法.在词袋模型中,对于一 ...
- Coursera Deep Learning 2 Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization - week1, Assignment(Initialization)
声明:所有内容来自coursera,作为个人学习笔记记录在这里. Initialization Welcome to the first assignment of "Improving D ...
- Coursera Deep Learning 2 Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization - week1, Assignment(Regularization)
声明:所有内容来自coursera,作为个人学习笔记记录在这里. Regularization Welcome to the second assignment of this week. Deep ...
- Spark2 ML 学习札记
摘要: 1.pipeline 模式 1.1相关概念 1.2代码示例 2.特征提取,转换以及特征选择 2.1特征提取 2.2特征转换 2.3特征选择 3.模型选择与参数选择 3.1 交叉验证 3.2 训 ...
- [Machine Learning & Algorithm]CAML机器学习系列2:深入浅出ML之Entropy-Based家族
声明:本博客整理自博友@zhouyong计算广告与机器学习-技术共享平台,尊重原创,欢迎感兴趣的博友查看原文. 写在前面 记得在<Pattern Recognition And Machine ...
- [Machine Learning & Algorithm]CAML机器学习系列1:深入浅出ML之Regression家族
声明:本博客整理自博友@zhouyong计算广告与机器学习-技术共享平台,尊重原创,欢迎感兴趣的博友查看原文. 符号定义 这里定义<深入浅出ML>系列中涉及到的公式符号,如无特殊说明,符号 ...
- Atitit GRASP(General Responsibility Assignment Software Patterns),中文名称为“通用职责分配软件模式”
Atitit GRASP(General Responsibility Assignment Software Patterns),中文名称为"通用职责分配软件模式" 1. GRA ...
- 机器学习 - ML
CNCC - 2016 | 机器学习(原文链接) Machine Learning - ML,机器学习起源于人工智能,是AI的一个分支. 机器学习的理论基础:计算学习理论 - Computationa ...
随机推荐
- SpringMVC中 Controller的 @ResponseBody注解分析
需求分析:需要 利用 out 对象返回给财付通是否接收成功 .那么将需要如下代码: /** * 返回处理结果给财付通服务器. * @param msg: Success or fail. * @ ...
- RNN推导
http://www.cnblogs.com/YiXiaoZhou/p/6058890.html RNN求解过程推导与实现 RNN LSTM BPTT matlab code opencv code ...
- 转:MapReduce原理与设计思想
转自:http://www.cnblogs.com/wuyudong/p/mapreduce-principle.html 简单解释 MapReduce 算法 一个有趣的例子 你想数出一摞牌中有多少张 ...
- C# 将链表存入二进制文件及读取二进制文件得到链表示例
// 将tasks保存到二进制文件中 public Boolean saveToFile(String file) { try { ) { // 没任务就不存 return false; } if ( ...
- angular - 使用es6等一些功能
app.module.ts var model = { user: 'Admin', items: [{ action: 'buy flowsers', done: false },{ action: ...
- POJ 3978(求素数)
知识点: 1.求素数的test,从2~sqrt(n): 2.假设数据非常多,能够用素数表记录,然后sum=prime[m]-prime[n]求得! ! !! !!! !! ...
- d3js 添加数据
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8&quo ...
- [Python-tools]defaultdict的使用场景
Python标准库中collections对集合类型的数据结构进行了非常多拓展操作.这些操作在我们使用集合的时候会带来非常多的便利.多看看非常有优点. defaultdict是当中一个方法,就是给字典 ...
- 合并SO为单独交货单
本场景为单步交货 为客户建立专用的route. 增加一个pull rule 在做订单的时候,为订单行选择 上面建立好的route, 连续建立了 2个 订单 SO ...
- Thunderbolt雷电接口
官网:https://thunderbolttechnology.net/tech/certification