[MACHINE LEARNING] Can we predict voting outcomes?
1. CART Tree
library(rpart)
library(rpart.plot)
CTree = rpart(Party ~ . -USER_ID, data = train, method = "class")
PredTest = predict(CTree, newdata = test, type = "class") # result is bad
2. Cross validation
library(e1071)
library(caret)
set.seed(100)
numFolds = trainControl(method = "cv", number = 10)
cpGrid = expand.grid(.cp = seq (0.01,0.50,0.01))
tr = train(Party ~.- USER_ID,method = "rpart",data = train,trControl = numFolds, tuneGrid = cpGrid,na.action = na.pass)
Tip: the red part is to deal with missing NA values #cp = 0.04
3. CART Tree
CTree = rpart(Party ~ . -USER_ID, data = train, method = "class", cp = 0.04)
PredTest = predict(CTree, newdata = test, type = "class")
#after upload, the accuracy is 0.61207. it is my first time, the score is higher than the default logistic regression 0.57902
p.s. I also tried random forest
library(randomForest)
RFTree = randomForest(Party ~.- USER_ID,method = "rpart",data = train, ntree = 500, cp = 0.04, na.action = na.omit)
#The score is not good.
2017/3/20 I am thinking i need to learn how to plot about the complex data structure. ggplot2. I think it's a good way for me.
[MACHINE LEARNING] Can we predict voting outcomes?的更多相关文章
- machine learning in action , part 1
We should think in below four questions: the decription of machine learning key tasks in machine lea ...
- 7 Exciting Uses of Machine Learning in FinTech
https://rubygarage.org/blog/machine-learning-in-fintech Machine learning (ML) has moved from the per ...
- Practical Machine Learning For The Uninitiated
Practical Machine Learning For The Uninitiated Last fall when I took on ShippingEasy's machine learn ...
- Targeted Learning R Packages for Causal Inference and Machine Learning(转)
Targeted learning methods build machine-learning-based estimators of parameters defined as features ...
- Introducing: Machine Learning in R(转)
Machine learning is a branch in computer science that studies the design of algorithms that can lear ...
- 学习笔记之Machine Learning Crash Course | Google Developers
Machine Learning Crash Course | Google Developers https://developers.google.com/machine-learning/c ...
- CheeseZH: Stanford University: Machine Learning Ex2:Logistic Regression
1. Sigmoid Function In Logisttic Regression, the hypothesis is defined as: where function g is the s ...
- Machine Learning and Data Mining(机器学习与数据挖掘)
Problems[show] Classification Clustering Regression Anomaly detection Association rules Reinforcemen ...
- [C5] Andrew Ng - Structuring Machine Learning Projects
About this Course You will learn how to build a successful machine learning project. If you aspire t ...
随机推荐
- Padavan老毛子固件:17CE插件集成
Padavan老毛子固件:17CE插件集成 1.老毛子路由设置:系统管理-服务-启动SSH服务器 以下链接下载 "winscp" http://down.orsoon.co ...
- Ubuntu 14.10 下DokuWiki安装
环境说明: Ubuntu 14.10 64位 1 下载DokuWiki:http://download.dokuwiki.org/ 2 解压到 /var/www/html下面 3 如果没有安装Apac ...
- alertjs Documentation
原文地址:https://github.com/PaulNieuwelaar/alertjs/wiki/Documentation#alertshow For version 3.0 document ...
- mysql 5.7 修改字符编码
在my.ini文件中添加 [mysqld]character-set-server = utf8 [client]default-character-set = utf8
- bootstrap-table初使用
<table id="table"></table> $('#table').bootstrapTable({ url: 'json/data1.json' ...
- mezzanine的page_menu tag(二)
dict的特性,key可以是None >>> def f(): a=[2,3] return a #函数返回local变量 >>> a=f() >>&g ...
- 转:java使用Filter过滤器对Response返回值进行修改
练习时只做了对request 的处理,这里记录一下,filter 对 response的处理. 原文地址:java使用Filter过滤器对Response返回值进行修改 有时候在开发过程中会有这样一个 ...
- 【原】The Linux Command Line - Redirection
● cat - Concatenate files● sort - Sort lines of text● uniq - Report or omit repeated lines● grep - P ...
- 关于https不支持http的解决方案
由于在写md的时候截图是用的微博的图床,上传到github才发现不让在其他网站使用,所有本文只有一张图片. 刚才进行网站测试的时候,微博秀这个插件不能显示出来,一直是空白, 然后我把本地域名改成了12 ...
- PowerScript语言基础
注释: 以 "//" 开头,其后书写注释内容,常用于单行注释. "/-/"中间的部分为注释,便于多行说明. //这是一个单行注释 INTEGER I I = I ...