[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 ...
随机推荐
- Ubuntu 16.04 LTS 常用快捷键
在Linux下Win键就是Super键 启动器 Win(长按) 打开启动器,显示快捷键 Win + Tab 通过启动器切换应用程序 Win + 1到9 与点击启动器上的图标效果一样 Win + Shi ...
- PAT 甲级 1083 List Grades (25 分)
1083 List Grades (25 分) Given a list of N student records with name, ID and grade. You are supposed ...
- 廖雪峰Java7处理日期和时间-3java.time的API-1LocalDateTime
1.java.time提供了新的日期和时间API: LocalDate/LocalTime/LocalDateTime ZoneDateTime/ZoneId Instant Formatter 新A ...
- FreeBsd网络性能优化方案sysctl
以下是阿盛的配置 sysctl net.inet.tcp.msl= sysctl net.inet.tcp.mssdflt= sysctl net.inet.tcp.minmss= sysctl ne ...
- Ext.NET Grid Group分组使用
- 需要注意的是, 涉及到分页排序, 最好定义GroupDir 方向与分组方式相同. - 譬如工资表按照最新最前分页输出. 如果分组按照默认排序的话, 最就最前. - 界面呈现出2015年, 2016 ...
- VS调试提示“无法启动程序,“...exe”。系统找不到指定文件
当VS调试提示上图所示的警告时,常用的方法是检查“项目”-“属性”-“配置属性”-“常规”-“输出目录”里的路径 项目”-“属性”-“配置属性”-“链接器”-“常规”-“输出文件”里的路径,是否一致, ...
- Java内存列表
当jvm运行起来的时候,它会向系统申请一片内存区,并将这块内存分出一部分存储程序创建的对象,传递给方法的参数,返回值,局部变量等等,我们将这块内存称之为“运行时数据区”. 初学的时候把Java内存分为 ...
- java多线程中最佳的实践方案是什么?
java多线程中最佳的实践方案是什么? 给你的线程起个有意义的名字.这样可以方便找bug或追踪.OrderProcessor, QuoteProcessor or TradeProcessor 这种名 ...
- sweetalert弹窗的使用
之前接触到layer弹出层,今天又发现了一个非常实用的弹出层插件,它的名字叫做sweetalert. 官网地址:http://t4t5.github.io/sweetalert/ npm下载方式:np ...
- leetcode139
class Solution { public: bool wordBreak(string s, vector<string> wordDict) { vector<, false ...