mirror of
https://github.com/TheAlgorithms/Python.git
synced 2026-03-13 09:50:19 +08:00
Modernize Python 2 code to get ready for Python 3
This commit is contained in:
@@ -46,6 +46,7 @@ Usage:
|
||||
5. Have fun..
|
||||
|
||||
'''
|
||||
from __future__ import print_function
|
||||
from sklearn.metrics import pairwise_distances
|
||||
import numpy as np
|
||||
|
||||
@@ -169,4 +170,4 @@ if False: # change to true to run this test case.
|
||||
initial_centroids = get_initial_centroids(dataset['data'], k, seed=0)
|
||||
centroids, cluster_assignment = kmeans(dataset['data'], k, initial_centroids, maxiter=400,
|
||||
record_heterogeneity=heterogeneity, verbose=True)
|
||||
plot_heterogeneity(heterogeneity, k)
|
||||
plot_heterogeneity(heterogeneity, k)
|
||||
|
||||
@@ -41,7 +41,7 @@ def rmse(predict, actual):
|
||||
actual = np.array(actual)
|
||||
|
||||
difference = predict - actual
|
||||
square_diff = np.square(dfference)
|
||||
square_diff = np.square(difference)
|
||||
mean_square_diff = square_diff.mean()
|
||||
score = np.sqrt(mean_square_diff)
|
||||
return score
|
||||
|
||||
Reference in New Issue
Block a user