Last night I gave a talk on my new gem Apriori.rb at the LA Ruby Meetup. Here are the slides from that presentation. Coby Randquist from Confreaks recorded the talk on his MacBookPro. I’ll see if I can get a copy and post it up here in the next couple of weeks.
Apriori.rb - a gem to find regularities in buying behavior (frequent itemsets)
What it is
Apriori.rb is a library to efficiently find item association rules within large sets of transactions. The goal is to find regularities in buying behavior. This library provides a thin ruby wrapper around Christian Borgelt’s C implementation of this algorithm.
Why use it?
Finding items that are frequently purchased together can be very useful in learning how to position products in your store or website. If you find that customers who buy product a also buy product b then you know to put a and b close together, thus increasing revenue.
An association rule is something like:
If a customer buys wine he buys cheese too.
How to use it
require 'apriori' transactions = [ %w{beer doritos}, %w{apple cheese}, %w{beer doritos}, %w{apple cheese}, %w{apple cheese}, %w{apple doritos} ] rules = Apriori.find_association_rules(transactions, :min_items => 2, :max_items => 5, :min_support => 1, :max_support => 100, :min_confidence => 20) puts rules.join("\n") # Results: # beer -> doritos (33.3/2, 100.0) # doritos -> beer (50.0/3, 66.7) # doritos -> apple (50.0/3, 33.3) # apple -> doritos (66.7/4, 25.0) # cheese -> apple (50.0/3, 100.0) # apple -> cheese (66.7/4, 75.0) # NOTE: # beer -> doritos (33.3/2, 100.0) # means: # * beer appears in 33.3% (2 total) of the transactions (the support) # * beer implies doritos 100% of the time (the confidence)
More information and code samples available in the documentation (rdoc).
How to get it
Install the gem:
gem install apriori
Get the source:
git clone git://github.com/jashmenn/apriori.git
Or view the source on github.
requirements
requires rubygems >= 1.2.0 . This is a requirement that hopefully will be changed in the future. But for now, know that if you don’t have rubygems >= 1.2.0 it will fail silently on the install. To update your rubygems version do:
gem update --system
a simple script to organize downloads
Description
Organize all files in a given folder by date. This is commonly used to organize a “Downloads” folder. Currently this script will only move files more than 24 hours old. This is to protect against moving a file as it is downloaded.
Motivation
I love SafariStand. One of the features that I love is the sort-downloads-by-date feature. Now that I have moved to Firefox I really miss this feature. I been unable to find a good extension that will sort my downloads in a similar way. This script was written as an simple way to fill that gap.
Setup
I keep a ~/bin directory where I keep simple scripts such as this. Then setup a crontab such as the following:
*/10 * * * * /usr/local/bin/ruby /Users/nathan/bin/organize_folder_by_date.rb /Users/nathan/Desktop/Downloads
Acquiring
It is available on github: here (raw).
or
git clone git://github.com/jashmenn/download_sort.git
,
Recent Comments