Note
Go to the end to download the full example code or to run this example in your browser via Binder.
Patterns in the plane of two measures#
Every pattern is a point; the axes are two interestingness measures and grey lines join each pattern to its parent (Stolper, Perer & Gotz, 2014). Frequent but unsurprising patterns sit at the right, rare but confident ones at the top left; lift separates real dependencies from coincidences.
pattern ... lift
197 Your situation → Your situation → Your situati... ... 17.934641
107 Your possessions → The labor market → Other in... ... 16.333333
225 Your situation → Your situation → Your situati... ... 16.141176
151 Your situation → Your situation → Your situati... ... 13.450980
58 The labor market → Other information ... 13.066667
229 Your situation → Your situation → Your income ... ... 11.064516
[6 rows x 4 columns]
import matplotlib.pyplot as plt
import spmviz as sv
from spmviz.viz import plot_pattern_scatter
db = sv.datasets.load_clickstream()
ps = sv.mine(db, 0.01, max_gap=1, max_length=10)
plot_pattern_scatter(ps, "rel_support", "confidence", labels=10)
plot_pattern_scatter(ps.filter(min_length=2), "confidence", "lift", color_by="start", labels=8)
print(ps.measures().sort_values("lift", ascending=False).head(6)[["pattern", "support", "confidence", "lift"]])
plt.show()
Total running time of the script: (0 minutes 0.724 seconds)

