SlideShare a Scribd company logo
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 (11)

PPTX
knn classification
PPTX
Data Science Project: Advancements in Fetal Health Classification
PDF
Datamining R 4th
PPTX
logistic regression with python and R
PPTX
Introduction to Fundamentals of Data Science
PPTX
wk5ppt1_Titanic
PPTX
Employee Salary Presentation.l based on data science collection of data
PDF
Kaggle KDD Cup Report
PDF
Lab 2: Classification and Regression Prediction Models, training and testing ...
PDF
미움 받을 용기 : 저 팀은 뭘 안다고 추천한다고 들쑤시고 다니는건가
PDF
knn classification
Data Science Project: Advancements in Fetal Health Classification
Datamining R 4th
logistic regression with python and R
Introduction to Fundamentals of Data Science
wk5ppt1_Titanic
Employee Salary Presentation.l based on data science collection of data
Kaggle KDD Cup Report
Lab 2: Classification and Regression Prediction Models, training and testing ...
미움 받을 용기 : 저 팀은 뭘 안다고 추천한다고 들쑤시고 다니는건가

Recently uploaded (20)

PDF
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
PDF
Lecture1 pattern recognition............
PDF
“Getting Started with Data Analytics Using R – Concepts, Tools & Case Studies”
PDF
168300704-gasification-ppt.pdfhghhhsjsjhsuxush
PPTX
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
PPT
Miokarditis (Inflamasi pada Otot Jantung)
PPTX
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
PPTX
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
PPTX
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
PDF
Galatica Smart Energy Infrastructure Startup Pitch Deck
PPTX
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
PDF
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
PPT
Reliability_Chapter_ presentation 1221.5784
PPTX
Introduction to machine learning and Linear Models
PDF
Recruitment and Placement PPT.pdfbjfibjdfbjfobj
PPTX
climate analysis of Dhaka ,Banglades.pptx
PPTX
Business Acumen Training GuidePresentation.pptx
PPTX
STUDY DESIGN details- Lt Col Maksud (21).pptx
PDF
Business Analytics and business intelligence.pdf
PPTX
advance b rammar.pptxfdgdfgdfsgdfgsdgfdfgdfgsdfgdfgdfg
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
Lecture1 pattern recognition............
“Getting Started with Data Analytics Using R – Concepts, Tools & Case Studies”
168300704-gasification-ppt.pdfhghhhsjsjhsuxush
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
Miokarditis (Inflamasi pada Otot Jantung)
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
Galatica Smart Energy Infrastructure Startup Pitch Deck
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
Reliability_Chapter_ presentation 1221.5784
Introduction to machine learning and Linear Models
Recruitment and Placement PPT.pdfbjfibjdfbjfobj
climate analysis of Dhaka ,Banglades.pptx
Business Acumen Training GuidePresentation.pptx
STUDY DESIGN details- Lt Col Maksud (21).pptx
Business Analytics and business intelligence.pdf
advance b rammar.pptxfdgdfgdfsgdfgsdgfdfgdfgsdfgdfgdfg

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)