Skip to content

WangZhen1175701153/kNN_for_anomaly_detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

k-Nearest Neighbors (kNN) for anomaly detection

python kNN_for_anomaly_detection.PY

or run kNN_for_anomaly_detection.ipynb in jupyter notebook.

Introduction

This script uses the KNN(k-Nearest Neighbors) algorithm to detect anomaly and outlier with hands-on example codes.

(kNN)_for_anomaly_detection Folder
datasets Folder(Store local dataset)

iris.csv (Very small and famous data,This is a good sample data for this example. Each sample contains four features.)

results Folder(Store Results)

Result picture,and PDF.

kNN_for_anomaly_detection.ipynb(This code can run directly on jupyter notebook)
kNN_for_anomaly_detection.py(python file)

Datasets

We will use the famous Iris dataset(https://raw.githubusercontent.com/uiuc-cse/data-fa14/gh-pages/data/iris.csv). In this example,only two characteristics are used("sepal_length", "sepal_width").

Requirements

This script can run on any system, including Windows, Linux, and OS. But here are some requirements about module version.

Currently, the code supports python >=3.5

  • scikit-learn (==0.23.2)
  • numpy (==1.19.2)
  • matplotlib
  • pandas

Results

see results.pdf

Reference

https://towardsdatascience.com/k-nearest-neighbors-knn-for-anomaly-detection-fdf8ee160d13

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages