Skip to content

Instantly share code, notes, and snippets.

@naranjja
Created June 10, 2015 20:09
Show Gist options
  • Save naranjja/f0e06d73f9bc9bfdb9ae to your computer and use it in GitHub Desktop.
Save naranjja/f0e06d73f9bc9bfdb9ae to your computer and use it in GitHub Desktop.
setwd("C:/Users/Usuario/Desktop/R")
getwd()
library(neuralnet)
fireforest<-read.csv("fireforest_data.csv")
attach(fireforest)
pairs(fireforest)
dim(fireforest)
size.sample<-400
normalize<-function(x){
return((x-min(x))/(max(x)-min(x)))}
fireforest_norm<-as.data.frame(lapply(fireforest[5:12],normalize))
fireforest_norma<-as.data.frame(fireforest[13])
fireforest_normal<-as.data.frame(fireforest[1:4])
fireforest_norma
fireforest_final<-cbind(fireforest_normal,fireforest_norm,fireforest_norma)
fireforest_final
names(fireforest_final)
fireforest_train<-fireforest_final[1:300,]
fireforest_test<-fireforest_final[401:517,]
neural.net<-neuralnet(area~X+Y+month+day+FFMC+DMC+DC+ISI+temp+RH+wind+rain,data=fireforest_final,hidden=1,threshold=0.02,stepmax=10000000)
plot(neural.net)
prediction<-compute(neural.net,fireforest_test[1:12])$net.result
prediction
tab<-table(prediction,fireforest_test$area)
tab
cor(prediction,fireforest_test$area)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment