Showing posts with label speed. Show all posts
Showing posts with label speed. Show all posts

Monday, October 12, 2015

Faster BTYD

The R-library "Buy 'Til You Die" for customer equity forecasting looked promising, but I quickly realised that the implementation relies heavily on loops and is not suited for any data set bigger than a couple of thousand rows.

To speed things up, I switched out a couple of the loops for some data.table magic. Here it is, about 10000X faster than the original, but there is still some room for improvement.

If you're having trouble getting the BTYD package to run, take a look at this post for fixes.

Tuesday, September 08, 2015

How to speed up csv import in R

If you're storing a lot of data in csv files, reading it to R with read.csv can be painfully slow. Using the fread function from the data.table library increase read speed by 100x, so definitely check it out.

library(data.table)
data <- fread('data.csv')

If you prefer to work with a data.frame, it's easy to tell fread to save it as such as well.

data <- fread('data.csv', data.table=FALSE)
Entertaining Blogs - BlogCatalog Blog Directory
Bloggtoppen.se