pyspark.mllib.fpm.
FPGrowthModel
A FP-Growth model for mining frequent itemsets using the Parallel FP-Growth algorithm.
New in version 1.4.0.
Examples
>>> data = [["a", "b", "c"], ["a", "b", "d", "e"], ["a", "c", "e"], ["a", "c", "f"]] >>> rdd = sc.parallelize(data, 2) >>> model = FPGrowth.train(rdd, 0.6, 2) >>> sorted(model.freqItemsets().collect()) [FreqItemset(items=['a'], freq=4), FreqItemset(items=['c'], freq=3), ... >>> model_path = temp_path + "/fpm" >>> model.save(sc, model_path) >>> sameModel = FPGrowthModel.load(sc, model_path) >>> sorted(model.freqItemsets().collect()) == sorted(sameModel.freqItemsets().collect()) True
Methods
call(name, *a)
call
Call method of java_model
freqItemsets()
freqItemsets
Returns the frequent itemsets of this model.
load(sc, path)
load
Load a model from the given path.
save(sc, path)
save
Save this model to the given path.
Methods Documentation
New in version 2.0.0.
New in version 1.3.0.