Commit d766efbc authored by Stanislav's avatar Stanislav
Browse files

applied improvement to distance calculation

parent d9cbac6c
......@@ -384,21 +384,27 @@ def calc_distance(df, weight_index, n, weights):
matrix[k][j] = matrix[j][k]
elif (isinstance(npm[0], float)):
matrix_temp = np.empty([n], dtype=float)
for j in range(n):
matrix[j][j] = 0
first_elem = npm[j]
for k in range(j+1,n):
matrix[j][k] = abs(first_elem - npm[k])
matrix[k][j] = matrix[j][k]
for k in range(j + 1, n):
matrix_temp[k] = abs(first_elem - npm[k])
for m in range(j):
matrix_temp[m] = matrix[m][j]
matrix_temp[j] = 0
matrix[j] = matrix_temp
matrix = matrix / matrix.max()
else:
matrix_temp = np.empty([n], dtype=float)
for j in range(n):
matrix[j][j] = 0
first_elem = npm[j]
for k in range(j+1,n):
matrix[j][k] = lev(first_elem, npm[k])
matrix[k][j] = matrix[j][k]
for k in range(j + 1, n):
matrix_temp[k] = lev(first_elem, npm[k])
for m in range(j):
matrix_temp[m] = matrix[m][j]
matrix_temp[j] = 0
matrix[j] = matrix_temp
matrix = matrix / matrix.max()
return matrix * weights[weight_index]
......
......@@ -27,7 +27,7 @@ p_ocel_file = './data/ocel.jsonocel'
p_mode = 'existence'
# object-type-name
p_object_type = 'product'
p_object_type = 'customers'
# example data for attribute weighting in distance measurements
p_attr_weights = {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment