Phát hiện mới lạ

Thiết kế quy trình Machine Learning bằng Python

Dr. Chris Anagnostopoulos

Honorary Associate Professor

Phân loại một lớp

Dữ liệu huấn luyện không có bất thường:

Hai cụm điểm đen.

Dữ liệu tương lai/kiểm thử có bất thường:

Hai cụm điểm đen cùng vài điểm cô lập.

Thiết kế quy trình Machine Learning bằng Python

LoF cho mới lạ

Cách làm tạm

preds = lof().fit_predict(
   np.concatenate([X_train, X_test]))

preds = preds[X_train.shape[0]:]

Hai cụm điểm đen với vài điểm đỏ cô lập.

LoF cho mới lạ

clf = lof(novelty=True)

clf.fit(X_train) y_pred = clf.predict(X_test)

Hai cụm điểm đen với vài điểm đỏ cô lập.

Thiết kế quy trình Machine Learning bằng Python

SVM một lớp

clf = OneClassSVM()

clf.fit(X_train) y_pred = clf.predict(X_test)
y_pred[:4]
array([ 1,  1,  1, -1])

Hai cụm điểm với vài điểm cô lập. Phần lớn điểm là đỏ, cả trong cụm lẫn điểm cô lập.

Thiết kế quy trình Machine Learning bằng Python

SVM một lớp

clf = OneClassSVM()
clf.fit(X_train)
y_scores = clf.score_samples(X_test)

threshold = np.quantile(y_scores, 0.1)
y_pred = y_scores <= threshold

Hai cụm điểm đen với vài điểm đỏ cô lập.

Thiết kế quy trình Machine Learning bằng Python

Isolation Forests

clf = IsolationForest()
clf.fit(X_train)
y_scores = clf.score_samples(X_test)
clf = LocalOutlierFactor(novelty=True)
clf.fit(X_train)
y_scores = clf.score_samples(X_test)

Hai cụm điểm đen với vài điểm đỏ cô lập.

Thiết kế quy trình Machine Learning bằng Python
clf_lof = LocalOutlierFactor(novelty=True).fit(X_train)
clf_isf = IsolationForest().fit(X_train)
clf_svm = OneClassSVM().fit(X_train)
roc_auc_score(y_test, clf_lof.score_samples(X_test)
0.9897
roc_auc_score(y_test, clf_isf.score_samples(X_test))
0.9692
roc_auc_score(y_test, clf_svm.score_samples(X_test))
0.9948
Thiết kế quy trình Machine Learning bằng Python
clf_lof = LocalOutlierFactor(novelty=True).fit(X_train)
clf_isf = IsolationForest().fit(X_train)
clf_svm = OneClassSVM().fit(X_train)
accuracy_score(y_test, clf_lof.predict(X_test))
0.9318
accuracy_score(y_test, clf_isf.predict(X_test))
0.9545
accuracy_score(y_test, clf_svm.predict(X_test))
0.5
Thiết kế quy trình Machine Learning bằng Python

Có gì mới?

Thiết kế quy trình Machine Learning bằng Python

Preparing Video For Download...