2017-09-14 33 views

回答

0

看看my answer關於如何使用DEAP和Spark,看看它是否適合你。

這裏是一個如何使用Spark配置DEAP toolboxreplace the map function的例子。

from pyspark import SparkContext 

sc = SparkContext(appName="DEAP") 

def sparkMap(algorithm, population): 
    return sc.parallelize(population).map(algorithm) 

toolbox.register("map", sparkMap) 
+0

什麼是'toolbox'?請不要複製答案。提供一個好的,然後通過註釋鏈接到它 –

+0

這是一個由DEAP提供的實用程序類,它可以在不影響算法其餘部分的情況下輕鬆更改運算符(docs [here](http://deap.readthedocs.io /en/master/tutorials/basic/part2.html#using-the-toolbox)。在我的示例中,它使用Spark並行化函數通過自定義函數替換映射函數(用於將適應函數映射到所有個體)。你可以在[docs]中找到另一個例子(http://deap.readthedocs.io/en/master/tutorials/basic/part4.html)。 – frenchoverflow