Skip to content
April 18, 2013 / jphoward

HBR Visualization Webinar data

I’ll be presenting an HBR Visualization Webinar tomorrow. For those interested in following along, here are the data files I’ll be using:

And here is some R code that we’ll use for the bulldozers data set:

setwd("C:\\YOUR_PATH_HERE")
df = read.csv("bulldozers.csv")
samp = df[sample(1:nrow(df), nrow(df)/10, replace=FALSE),]
summary(samp)
write.csv(samp, "bulldozers_samp.csv", row.names=F)

library(plyr)

appendNAs <- function(dataset) {
  append_these = data.frame( is.na(dataset[, names(dataset)] ) )
  names(append_these) = paste(names(append_these), "NA", sep = "_")
  append_these = colwise(identity, function(x) any(x))(append_these)
  dataset = cbind(dataset, append_these)
  dataset[is.na(dataset)] = -1000
  return(dataset)
}

samp2 = appendNAs(samp)
f0 = function(x) {
  if (nlevels(x)>32) {
    return (unclass(x))
  } else {
    return (x)
  }
}
samp2 = colwise(f0)(samp2)

library(randomForest)
m = randomForest(SalePrice~., data=samp2, ntree=15, sampsize=5000, nodesize=25, do.trace=T)
partialPlot(m, samp2, Enclosure)
partialPlot(m, samp2, ProductSize)
varImpPlot(m)
Advertisements

One Comment

Leave a Comment
  1. Punit (@puneethmishra) / Apr 29 2013 4:33 pm

    Hi Jeremy,

    Does HBR have plans to make the recording of the webinar available.
    They had mentioned it will be made available in a week, but still it has not been done.

    Request you to please make the webinar available, so that we can re-visit some of the important concepts you touched upon.

    Thanks,
    Punit

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: