我尝试docker-compose up -d在两个不同的服务器中运行两个相同的 docker-compose.yml 文件。问题是我无法连接到其中一台服务器中的容器。我不知道配置或其他什么有什么问题。对我来说唯一不同的是docker ps两个服务器中命令的输出:
第二个连接超时。
I'm trying to plot a pandas data frame on two plots. One with a pie chart of matplotlib pyplot and the other with seaborn barchart. On each chart, I sorted the data frame but based on a different column. Also, each chart is representative of the respective value which data frame is sorted by. So, the order of rows is different in the two charts. This way, same indexes(or category) in data frame appears with different color on charts which …
我正在 python 和 Spark 上从头开始实现 kmeans 算法。事实上,这是我的作业。问题是用不同的初始化方法实现具有预定义质心的kmeans,其中一种是随机初始化(c1),另一种是kmeans++(c2)。此外,还需要使用不同的距离度量、欧几里得距离和曼哈顿距离。两者的公式介绍如下:
每个部分中的第二个公式用于相应的成本函数,该函数将被最小化。我已经实现了这两个,但我认为有一个问题。这是使用不同设置的 kmeans 每次迭代的成本函数图:
第一个图看起来不错,但第二个图似乎有问题,因为就我而言,每次迭代后 kmeans 的成本必须减少。那么,问题是什么?这是我的代码或公式吗?
这些是我计算距离和成本的函数:
def Euclidean_distance(point1, point2):
return np.sqrt(np.sum((point1 - point2) ** 2))
def Manhattan_distance(point1, point2):
return np.sum(np.absolute(point1 - point2))
def cost_per_point(point, center, cost_type = 'E'):
if cost_type =='E':
return Euclidean_distance(point, center)**2
else:
return Manhattan_distance(point, center)
Run Code Online (Sandbox Code Playgroud)
这是我在 GitHub 上的完整代码: https://github.com/mrasoolmirzaei/My-Data-Science-Projects/blob/master/Implementing%20Kmeans%20With%20Spark.ipynb