Skip to content

Commit

Permalink
Update clustering_quality.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
jaksle committed Oct 29, 2023
1 parent c1d787d commit e8f9538
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/clustering_quality.jl
Original file line number Diff line number Diff line change
Expand Up @@ -218,17 +218,17 @@ function _cluquality_calinski_harabasz(
)

n, k = size(data, 2), size(centers, 2)
w_idx1, w_idx2 = axes(weights)

global_center = vec(mean(data, dims=2))
center_distances = colwise(metric, centers, global_center)
outer_intertia = sum(
weights[i,j₁]^fuzziness * center_distances[j₂] for i in w_idx1, (j₁,j₂) in zip(w_idx2, 1:k)
)

outer_inertia =
sum(sum(w^fuzziness for w in w_col) * d
for (w_col, d) in zip(eachcol(weights), center_distances)
)
inner_inertia = _inner_inertia(data, centers, weights, fuzziness, metric)

return (outer_intertia / inner_inertia) * (n - k) / (k - 1)
return (outer_inertia / inner_inertia) * (n - k) / (k - 1)
end

# Davies-Bouldin index
Expand Down

0 comments on commit e8f9538

Please sign in to comment.