Clustermethoden om fraude op te sporen

Fraudedetectie in Python

Charlotte Werger

Data Scientist

Clustering: patronen in data vinden

Fraudedetectie in Python

K-means: clusteren op afstand tot centroiden

Fraudedetectie in Python

K-means: clusteren op afstand tot centroiden

Fraudedetectie in Python

K-means: clusteren op afstand tot centroiden

Fraudedetectie in Python

Fraudedetectie in Python

Fraudedetectie in Python

Fraudedetectie in Python

K-means-clustering in Python

# Import the packages
from sklearn.preprocessing import MinMaxScaler
from sklearn.cluster import KMeans

# Transform and scale your data X = np.array(df).astype(np.float)
scaler = MinMaxScaler() X_scaled = scaler.fit_transform(X)
# Define the k-means model and fit to the data kmeans = KMeans(n_clusters=6, random_state=42).fit(X_scaled)
Fraudedetectie in Python

Het juiste aantal clusters

Het aantal clusters bepalen:

  • Silhouetmethode
  • Elleboogcurve
clust = range(1, 10) 
kmeans = [KMeans(n_clusters=i) for i in clust]

score = [kmeans[i].fit(X_scaled).score(X_scaled) for i in range(len(kmeans))]
plt.plot(clust,score) plt.xlabel('Number of Clusters') plt.ylabel('Score') plt.title('Elbow Curve') plt.show()
Fraudedetectie in Python

De elleboogcurve

Fraudedetectie in Python

Laten we oefenen!

Fraudedetectie in Python

Preparing Video For Download...