FPGrowthModel¶
-
class
pyspark.mllib.fpm.
FPGrowthModel
(java_model)[source]¶ 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 method of java_model
Returns the frequent itemsets of this model.
load
(sc, path)Load a model from the given path.
save
(sc, path)Save this model to the given path.
Methods Documentation
-
call
(name, *a)¶ Call method of java_model
-
save
(sc, path)¶ Save this model to the given path.
New in version 1.3.0.
-