rm(list=ls()); gc()
library(dplyr)
library(C50)
library(caret)
library(randomForest)
library(funModeling)
setwd("C:/Users/Manav/Documents/FORE/Term 5/Big Data/End_Term_Project/")
train <- read.csv("train.csv")
test <- read.csv("test.csv")
test$TARGET <- 0
to <- rbind(train, test)
to$TARGET <- as.factor(to$TARGET)
df <- data.frame(to)
xyz <- df_status(df)
fun_1 = xyz%>%filter(p_zeros<100)
fun_2=subset(fun_1, select = c(variable))
fun_3=subset(to, select = c(fun_2$variable))
fun_4 = subset(fun_3, select = -c(ID,TARGET))
pre <- preProcess(fun_4, method = "pca")
inm <- predict(pre,fun_4)
inm$ID <- fun_3[,c("ID")]
inm$TARGET <- fun_3[,c("TARGET")]
inm[1:nrow(train),] -> tr
inm[-c(1:nrow(train)),] -> te
train_data <- tr[1:60000,]
valid_data <- tr[-c(1:60000),]
valid_data$TARGET <- NULL
te$TARGET <- NULL
model=randomForest(TARGET~.,data=train_data, ntree=100)
model
pred <- predict(model, valid_data)
confusionMatrix(pred, tr[-c(1:60000),c("TARGET")])
pred <- predict(model, te)

More Related Content

PPTX
PDF
Tt subtemplates-caching
PDF
Map Reduce 〜入門編:仕組みの理解とアルゴリズムデザイン〜
PDF
GHCソースコード読みのススメ
PDF
Damn Fine CoffeeScript
PDF
PDF
Debugging: Rules And Tools - PHPTek 11 Version
PDF
3分くらいで分かるassert()
Tt subtemplates-caching
Map Reduce 〜入門編:仕組みの理解とアルゴリズムデザイン〜
GHCソースコード読みのススメ
Damn Fine CoffeeScript
Debugging: Rules And Tools - PHPTek 11 Version
3分くらいで分かるassert()

What's hot (19)

PDF
MongoUK - PHP Development
PDF
Perl Bag of Tricks - Baltimore Perl mongers
PDF
Useful javascript
PDF
How to stand on the shoulders of giants
PDF
From Javascript To Haskell
TXT
Fcontratos
PPTX
Unit testing pig
PDF
Bag of tricks
PPTX
Introduzione a C#
PDF
Programming Lisp Clojure - 2장 : 클로저 둘러보기
PDF
PDF
The Magic Of Tie
PDF
Parsing JSON with a single regex
PDF
Advanced modulinos
PDF
Chainer-Compiler 動かしてみた
PPTX
Webinar: Replication and Replica Sets
PDF
Meet up symfony 16 juin 2017 - Les PSR
DOCX
Assignment no39
PDF
WordPressでIoTをはじめよう
MongoUK - PHP Development
Perl Bag of Tricks - Baltimore Perl mongers
Useful javascript
How to stand on the shoulders of giants
From Javascript To Haskell
Fcontratos
Unit testing pig
Bag of tricks
Introduzione a C#
Programming Lisp Clojure - 2장 : 클로저 둘러보기
The Magic Of Tie
Parsing JSON with a single regex
Advanced modulinos
Chainer-Compiler 動かしてみた
Webinar: Replication and Replica Sets
Meet up symfony 16 juin 2017 - Les PSR
Assignment no39
WordPressでIoTをはじめよう
Ad

Viewers also liked (7)

PDF
Timeseries Analysis with R
PDF
INTRODUCTION TO TIME SERIES ANALYSIS WITH “R” JUNE 2014
PDF
Time Series Analysis and Mining with R
PPTX
Lifebuoy
DOCX
Smartphone industry samsung market analysis
DOCX
Marketing strategy of samsung in India
PPTX
Smartphone industry analysis
Timeseries Analysis with R
INTRODUCTION TO TIME SERIES ANALYSIS WITH “R” JUNE 2014
Time Series Analysis and Mining with R
Lifebuoy
Smartphone industry samsung market analysis
Marketing strategy of samsung in India
Smartphone industry analysis
Ad

Similar to R code (20)

PPTX
Introduction to R
DOCX
R (Shiny Package) - Server Side Code for Decision Support System
PDF
R code for data manipulation
PDF
R code for data manipulation
PDF
DataMapper
DOCX
A Shiny Example-- R
PDF
Php tips-and-tricks4128
PDF
M12 random forest-part01
PPT
Jan 2012 HUG: RHadoop
PDF
Java VS Python
PDF
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
PDF
Session 02
PDF
Refactoring to Macros with Clojure
PPTX
Scott Anderson [InfluxData] | InfluxDB Tasks – Beyond Downsampling | InfluxDa...
PDF
Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn
PDF
Python Ireland Nov 2010 Talk: Unit Testing
PDF
PHP tips and tricks
PDF
R and data mining
PDF
From mysql to MongoDB(MongoDB2011北京交流会)
PDF
Introdução ao Perl 6
Introduction to R
R (Shiny Package) - Server Side Code for Decision Support System
R code for data manipulation
R code for data manipulation
DataMapper
A Shiny Example-- R
Php tips-and-tricks4128
M12 random forest-part01
Jan 2012 HUG: RHadoop
Java VS Python
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Session 02
Refactoring to Macros with Clojure
Scott Anderson [InfluxData] | InfluxDB Tasks – Beyond Downsampling | InfluxDa...
Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn
Python Ireland Nov 2010 Talk: Unit Testing
PHP tips and tricks
R and data mining
From mysql to MongoDB(MongoDB2011北京交流会)
Introdução ao Perl 6

Recently uploaded (20)

PPTX
sac 451hinhgsgshssjsjsjheegdggeegegdggddgeg.pptx
PDF
REAL ILLUMINATI AGENT IN KAMPALA UGANDA CALL ON+256765750853/0705037305
PPTX
SAP 2 completion done . PRESENTATION.pptx
PPTX
Copy of 16 Timeline & Flowchart Templates – HubSpot.pptx
PPTX
FMIS 108 and AISlaudon_mis17_ppt_ch11.pptx
PPTX
CYBER SECURITY the Next Warefare Tactics
PPTX
DS-40-Pre-Engagement and Kickoff deck - v8.0.pptx
PPTX
Leprosy and NLEP programme community medicine
PDF
Capcut Pro Crack For PC Latest Version {Fully Unlocked 2025}
PDF
Global Data and Analytics Market Outlook Report
PPT
Predictive modeling basics in data cleaning process
PPT
lectureusjsjdhdsjjshdshshddhdhddhhd1.ppt
PDF
Votre score augmente si vous choisissez une catégorie et que vous rédigez une...
PDF
Navigating the Thai Supplements Landscape.pdf
DOCX
Factor Analysis Word Document Presentation
PPTX
Pilar Kemerdekaan dan Identi Bangsa.pptx
PPT
statistic analysis for study - data collection
PPTX
(Ali Hamza) Roll No: (F24-BSCS-1103).pptx
PPTX
Introduction to Inferential Statistics.pptx
PDF
Optimise Shopper Experiences with a Strong Data Estate.pdf
sac 451hinhgsgshssjsjsjheegdggeegegdggddgeg.pptx
REAL ILLUMINATI AGENT IN KAMPALA UGANDA CALL ON+256765750853/0705037305
SAP 2 completion done . PRESENTATION.pptx
Copy of 16 Timeline & Flowchart Templates – HubSpot.pptx
FMIS 108 and AISlaudon_mis17_ppt_ch11.pptx
CYBER SECURITY the Next Warefare Tactics
DS-40-Pre-Engagement and Kickoff deck - v8.0.pptx
Leprosy and NLEP programme community medicine
Capcut Pro Crack For PC Latest Version {Fully Unlocked 2025}
Global Data and Analytics Market Outlook Report
Predictive modeling basics in data cleaning process
lectureusjsjdhdsjjshdshshddhdhddhhd1.ppt
Votre score augmente si vous choisissez une catégorie et que vous rédigez une...
Navigating the Thai Supplements Landscape.pdf
Factor Analysis Word Document Presentation
Pilar Kemerdekaan dan Identi Bangsa.pptx
statistic analysis for study - data collection
(Ali Hamza) Roll No: (F24-BSCS-1103).pptx
Introduction to Inferential Statistics.pptx
Optimise Shopper Experiences with a Strong Data Estate.pdf

R code

  • 1. rm(list=ls()); gc() library(dplyr) library(C50) library(caret) library(randomForest) library(funModeling) setwd("C:/Users/Manav/Documents/FORE/Term 5/Big Data/End_Term_Project/") train <- read.csv("train.csv") test <- read.csv("test.csv") test$TARGET <- 0 to <- rbind(train, test) to$TARGET <- as.factor(to$TARGET) df <- data.frame(to) xyz <- df_status(df) fun_1 = xyz%>%filter(p_zeros<100) fun_2=subset(fun_1, select = c(variable)) fun_3=subset(to, select = c(fun_2$variable)) fun_4 = subset(fun_3, select = -c(ID,TARGET)) pre <- preProcess(fun_4, method = "pca") inm <- predict(pre,fun_4) inm$ID <- fun_3[,c("ID")] inm$TARGET <- fun_3[,c("TARGET")] inm[1:nrow(train),] -> tr inm[-c(1:nrow(train)),] -> te train_data <- tr[1:60000,] valid_data <- tr[-c(1:60000),] valid_data$TARGET <- NULL te$TARGET <- NULL model=randomForest(TARGET~.,data=train_data, ntree=100) model pred <- predict(model, valid_data) confusionMatrix(pred, tr[-c(1:60000),c("TARGET")]) pred <- predict(model, te)