Skip to content

Instantly share code, notes, and snippets.

@glamp
Last active December 3, 2018 04:37
Show Gist options
  • Save glamp/6252289 to your computer and use it in GitHub Desktop.
Save glamp/6252289 to your computer and use it in GitHub Desktop.
# only evaluate w/ vintages that have come to term
df.term <- subset(df, year_issued < 2012)
df.term$home_ownership <- factor(df.term$home_ownership)
df.term$is_rent <- df.term$home_ownership=="RENT"
df.term$fico_range <- factor(df.term$fico_range)
df.term$fico_ordered <- as.numeric(df.term$fico_range)
idx <- runif(nrow(df.term)) > 0.75
train <- df.term[idx==FALSE,]
test <- df.term[idx==TRUE,]
rf <- randomForest(factor(is_bad) ~ last_fico_range_high + last_fico_range_low +
pub_rec_bankruptcies + revol_util + inq_last_6mths + is_rent,
type="classification", data=train, importance=TRUE, na.action=na.omit)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment