Created
December 15, 2017 04:26
-
-
Save WalkerHarrison/b540a751dfb6a399467fcb7e8cf8afb2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
load("paintings_train.Rdata") | |
load("paintings_test.Rdata") | |
load("paintings_validation.Rdata") | |
paintings_full <- rbind(paintings_train, paintings_test) | |
paint_full <- clean_data(paintings_full) %>% distinct() | |
paint_valid <- clean_data(paintings_validation) | |
main.lm <- lm(logprice ~ dealer + year + Interm + origin_cat + endbuyer + | |
engraved + prevcoll + finished + lrgfont + discauth + logSurface + | |
winningbiddertype + winningbiddertype*dealer + logSurface*position + | |
dealer*position + | |
## interactions | |
dealer*I(year^3) + lrgfont*year + lrgfont*Interm + | |
endbuyer*dealer + endbuyer*Interm + origin_cat*logSurface, | |
data = paint_full) | |
aux.lm <- lm(logprice ~ dealer + year + Interm + origin_cat + endbuyer + | |
engraved + prevcoll + finished + lrgfont + discauth + | |
winningbiddertype + winningbiddertype*dealer + | |
dealer*position + | |
## interactions | |
dealer*I(year^3) + lrgfont*year + lrgfont*Interm + | |
endbuyer*dealer + endbuyer*Interm, | |
data = paint_full) | |
predict_main <- as.data.frame( | |
exp(predict(main.lm, newdata=paint_valid, | |
interval = "pred"))) | |
predict_aux <- as.data.frame( | |
exp(predict(aux.lm, newdata=paint_valid[is.na(paint_valid$logSurface),], | |
interval = "pred"))) | |
predict_valid <- predict_main | |
predict_valid[is.na(predict_valid$fit),] <- predict_aux | |
predictions <- predict_valid | |
top.price <- data.frame(id = 1:nrow(predictions), price = predictions$fit, paint_valid) %>% arrange(desc(price)) %>% head(10) %>% | |
select(id, price, year, winningbiddertype, Interm, engraved, finished, prevcoll, logSurface) | |
top.price %>% kable() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment