标记欺诈与非欺诈

Python 中的欺诈检测

Charlotte Werger

Data Scientist

从聚类数据开始

Python 中的欺诈检测

指定聚类质心

Python 中的欺诈检测

定义到质心的距离

Python 中的欺诈检测

将远离质心者标记为欺诈

Python 中的欺诈检测

基于到质心的距离标记欺诈

# Run the kmeans model on scaled data
kmeans = KMeans(n_clusters=6, random_state=42).fit(X_scaled)

# Get the cluster number for each datapoint X_clusters = kmeans.predict(X_scaled)
# Save the cluster centroids X_clusters_centers = kmeans.cluster_centers_
# Calculate the distance to the cluster centroid for each point dist = [np.linalg.norm(x-y) for x,y in zip(X_scaled, X_clusters_centers[X_clusters])]
# Create predictions based on distance km_y_pred = np.array(dist) km_y_pred[dist>=np.percentile(dist, 93)] = 1 km_y_pred[dist<np.percentile(dist, 93)] = 0
Python 中的欺诈检测

验证模型结果

  • 与欺诈分析师核对
  • 更深入调查并描述被标记的案例
  • 与以往已知欺诈案例对比
Python 中的欺诈检测

Passons à la pratique !

Python 中的欺诈检测

Preparing Video For Download...