online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
import numpy as np from sklearn.datasets import load_iris data = load_iris() X = data.data # 1. Load data (first 4 features), transpose K, m, e, i = 3, 2, 1e-5, 10 # 2. clusters, fuzziness, error, iterations c = X[:, np.random.choice(X.shape[1], K, 0)] # 3. Randomly init cluster centers for _ in range(i): # 4. Repeat update steps d = np.linalg.norm(X[:, :, None]-c[:, None], axis=0) + 1e-9 # 5. Distance matrix u = 1 / d**(2/(m-1)) # 6. Compute membership (unnormalized) u = u / u.sum(1, keepdims=1) # 7. Normalize memberships c = (X @ (u**m)) / (u**m).sum(0) # 8. Update cluster centers labels = u.argmax(1) # 9. Final cluster labels print(labels, sum(d[n, labels[n]] for n in range(len(labels)))) #10. Labels + performance

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue