我正在尝试运行下面的示例代码。即使--尽管我已经缓存了数据,但我还是收到了“输入数据不是缓存的火花”警告。由于这个问题,我无法对大型数据集使用fp增长算法。
from pyspark.ml.fpm import FPGrowth
from pyspark.sql import SparkSession
"""
An example demonstrating FPGrowth.
Run with:
bin/spark-submit examples/src/main/python/ml/fpgrowth_example.py
"""
if __name__ == "__main__":
spark = SparkSession\
.builder\
.appName("FPGrowthExample")\
.getOrCreate()
# $example on$
df = spark.createDataFrame([
(0, [1, 2, 5]),
(1, [1, 2, 3, 5]),
(2, [1, 2])
], ["id", "items"])
df = df.cache()
fpGrowth = FPGrowth(itemsCol="items", minSupport=0.5, minConfidence=0.6)
model = fpGrowth.fit(df)
# Display frequent itemsets.
model.freqItemsets.show()
# Display generated association rules.
model.associationRules.show()
# transform examines the input items against all the association rules and summarize the
# consequents as prediction
model.transform(df).show()
spark.stop()发布于 2017-12-13 11:42:31
为什么
因为ml.fpm.FPGrowth将数据转换为RDD,并在此RDD上运行mllib.fpm.FPGrowth。不缓存RDD,这将导致mllib代码中的警告。
你能做些什么
在你的代码里什么都没有。如果您认为这是一个大问题(不应该是),请打开JIRA票证并创建一个拉请求。
由于这个问题,我无法对大型数据集使用fp增长算法。
它可能导致不必要的分配和减速,但不应受到限制。如果遇到故障,参数可能需要调优。
https://stackoverflow.com/questions/47790807
复制相似问题