zoukankan      html  css  js  c++  java
  • 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均相同.

  • 相关阅读:
    ubuntu samba 服务器设置
    Unable to find the ncurses libraries
    ubuntu 11.04 tftp 设置
    Ubuntu 11.04 NFS 配置
    Ubuntu server 网络设置
    ubuntu 11.04 tslib1.4 编译
    HGE DirectX9.0C版本修改已经完成,发图祝贺一下。
    HGE继续修改绘图底层
    D3D中的AGP内存、系统内存、显存的理解
    For循环和递归的一些区别。
  • 原文地址:https://www.cnblogs.com/kinsomy/p/6574231.html
Copyright © 2011-2022 走看看