title: Anomaly detection using K nearest neighbors?
body: <p>I want to make a network intrusion detection system based on 19-features traffic statistics. I have successfully tried the One Class SVM algorithm but heard that the k Nearest Neighbors can perform this task too. In the same way I have an anomaly free training data set and a testing data set with some anomalies and the associated labels (1 for normal and -1 for anomalous).</p>
  
  <p><strong>training_samples.csv</strong> (200 first samples, complete file contains ~1200)</p>
  
  <pre><code>7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 4, 3, 4, 1, 1, 106, 395.142857143, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  6, 3, 2, 1, 2, 0, 3, 3, 3, 1, 1, 106, 359.0, 64009.0, 612, 0, 0, 0, 0
  8, 3, 2, 1, 2, 0, 3, 5, 5, 1, 1, 106, 295.75, 60008.4375, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  6, 3, 2, 1, 2, 0, 3, 3, 3, 1, 1, 106, 359.0, 64009.0, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 4, 3, 2, 2, 0, 2, 4, 4, 1, 1, 92, 248.571428571, 52854.5306122, 612, 0, 0, 0, 0
  8, 4, 3, 2, 2, 0, 3, 4, 4, 1, 1, 92, 294.0, 60694.0, 612, 0, 0, 0, 0
  9, 4, 3, 2, 2, 0, 3, 4, 4, 2, 2, 92, 289.111111111, 54141.4320988, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  6, 3, 2, 1, 2, 0, 2, 4, 4, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  8, 3, 2, 1, 2, 0, 3, 5, 5, 1, 1, 106, 295.75, 60008.4375, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  6, 3, 2, 1, 2, 0, 3, 3, 3, 1, 1, 106, 359.0, 64009.0, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  8, 4, 3, 2, 2, 0, 3, 4, 4, 1, 1, 92, 294.0, 60694.0, 612, 0, 0, 0, 0
  8, 4, 3, 2, 2, 0, 2, 4, 4, 1, 1, 92, 229.0, 48929.0, 612, 0, 0, 0, 0
  9, 4, 3, 2, 2, 0, 3, 5, 5, 1, 1, 92, 273.111111111, 57440.9876543, 612, 0, 0, 0, 0
  8, 4, 3, 2, 2, 0, 2, 4, 4, 1, 1, 92, 229.0, 48929.0, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  9, 4, 3, 2, 2, 0, 3, 4, 4, 1, 1, 92, 271.555555556, 57980.2469136, 612, 0, 0, 0, 0
  8, 4, 3, 2, 2, 0, 2, 5, 5, 1, 1, 92, 230.75, 48470.9375, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  6, 3, 2, 1, 2, 0, 2, 4, 4, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  8, 4, 3, 2, 2, 0, 3, 4, 4, 1, 1, 106, 313.75, 55445.4375, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 4, 3, 2, 2, 0, 2, 4, 4, 1, 1, 92, 248.571428571, 52854.5306122, 612, 0, 0, 0, 0
  8, 4, 3, 2, 2, 0, 2, 5, 5, 1, 1, 92, 230.75, 48470.9375, 612, 0, 0, 0, 0
  8, 4, 3, 2, 2, 0, 3, 4, 4, 1, 1, 92, 294.0, 60694.0, 612, 0, 0, 0, 0
  6, 3, 2, 1, 2, 0, 2, 4, 4, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  6, 3, 2, 1, 2, 0, 3, 3, 3, 1, 1, 106, 359.0, 64009.0, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  8, 4, 3, 2, 2, 0, 2, 4, 4, 1, 1, 92, 229.0, 48929.0, 612, 0, 0, 0, 0
  8, 4, 3, 2, 2, 0, 3, 4, 4, 1, 1, 92, 294.0, 60694.0, 612, 0, 0, 0, 0
  8, 3, 2, 1, 2, 0, 3, 5, 5, 1, 1, 106, 295.75, 60008.4375, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  6, 3, 2, 1, 2, 0, 3, 3, 3, 1, 1, 106, 359.0, 64009.0, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 4, 3, 4, 1, 1, 106, 395.142857143, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  6, 3, 2, 1, 2, 0, 3, 3, 3, 1, 1, 106, 359.0, 64009.0, 612, 0, 0, 0, 0
  8, 3, 2, 1, 2, 0, 3, 5, 5, 1, 1, 106, 295.75, 60008.4375, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  6, 3, 2, 1, 2, 0, 3, 3, 3, 1, 1, 106, 359.0, 64009.0, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  6, 3, 2, 1, 2, 0, 2, 4, 4, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  9, 4, 3, 2, 2, 0, 3, 4, 4, 1, 1, 92, 271.555555556, 57980.2469136, 612, 0, 0, 0, 0
  8, 4, 3, 2, 2, 0, 2, 5, 5, 1, 1, 92, 230.75, 48470.9375, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  6, 3, 2, 1, 2, 0, 2, 4, 4, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  8, 4, 3, 2, 2, 0, 3, 4, 4, 1, 1, 92, 294.0, 60694.0, 612, 0, 0, 0, 0
  8, 4, 3, 2, 2, 0, 2, 4, 4, 1, 1, 92, 229.0, 48929.0, 612, 0, 0, 0, 0
  8, 4, 3, 2, 2, 0, 2, 5, 5, 1, 1, 92, 230.75, 48470.9375, 612, 0, 0, 0, 0
  8, 4, 3, 2, 2, 0, 2, 4, 4, 1, 1, 92, 229.0, 48929.0, 612, 0, 0, 0, 0
  6, 3, 2, 1, 2, 0, 3, 3, 3, 1, 1, 106, 359.0, 64009.0, 612, 0, 0, 0, 0
  8, 3, 2, 1, 2, 0, 3, 5, 5, 1, 1, 106, 295.75, 60008.4375, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  6, 3, 2, 1, 2, 0, 3, 3, 3, 1, 1, 106, 359.0, 64009.0, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 4, 3, 4, 1, 1, 106, 395.142857143, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  6, 3, 2, 1, 2, 0, 3, 3, 3, 1, 1, 106, 359.0, 64009.0, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  6, 3, 2, 1, 2, 0, 3, 3, 3, 1, 1, 106, 359.0, 64009.0, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  6, 3, 2, 1, 2, 0, 2, 4, 4, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  </code></pre>
  
  <p><strong>testing_samples.csv</strong> (100 first samples, complete file contains 193)</p>
  
  <pre><code>7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 3, 4, 4, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  6, 3, 2, 1, 2, 0, 3, 3, 3, 1, 1, 106, 359.0, 64009.0, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 2, 5, 5, 1, 1, 106, 250.571428571, 52252.244898, 612, 0, 0, 0, 0
  7, 3, 2, 1, 2, 0, 4, 3, 4, 1, 1, 106, 395.142857143, 62702.6938776, 612, 0, 0, 0, 0
  6, 3, 2, 1, 2, 0, 2, 4, 4, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  1272, 3, 2, 2, 3, 0, 2, 5, 5, 1, 1, 42, 43.572327044, 532.118982635, 612, 1205, 0, 0, 0
  5664, 1, 1, 2, 2, 0, 0, 5, 5, 1, 1, 42, 42.113700565, 4.63255240751, 106, 5623, 0, 0, 0
  12, 3, 2, 1, 2, 0, 4, 8, 8, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 4, 8, 8, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 5, 7, 7, 1, 1, 106, 316.833333333, 62230.9722222, 612, 0, 0, 0, 0
  10, 3, 2, 1, 2, 0, 4, 6, 6, 1, 1, 106, 308.4, 61448.64, 612, 0, 0, 0, 0
  18, 4, 3, 2, 2, 0, 6, 8, 8, 1, 1, 92, 271.555555556, 57980.2469136, 612, 0, 0, 0, 0
  12, 4, 3, 2, 2, 0, 4, 6, 6, 1, 1, 92, 272.333333333, 57711.2222222, 612, 0, 0, 0, 0
  12, 4, 3, 2, 2, 0, 3, 7, 7, 1, 1, 92, 230.166666667, 48624.3055556, 612, 0, 0, 0, 0
  18, 4, 3, 2, 2, 0, 6, 8, 8, 1, 1, 92, 271.555555556, 57980.2469136, 612, 0, 0, 0, 0
  14, 4, 3, 2, 2, 0, 4, 7, 7, 1, 1, 92, 247.571428571, 53152.6734694, 612, 0, 0, 0, 0
  1660, 3, 3, 3, 2, 174, 1652, 1652, 1652, 1, 1, 57, 57.2108433735, 9.40132820438, 106, 0, 0, 0, 0
  190, 5, 4, 3, 3, 24, 180, 176, 176, 1, 1, 57, 70.9684210526, 6391.23058172, 612, 0, 0, 0, 0
  14, 4, 3, 2, 2, 0, 4, 8, 8, 1, 1, 92, 248.571428571, 52854.5306122, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 4, 8, 8, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 5, 7, 7, 1, 1, 106, 316.833333333, 62230.9722222, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 5, 7, 7, 1, 1, 106, 316.833333333, 62230.9722222, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 5, 7, 7, 1, 1, 106, 316.833333333, 62230.9722222, 612, 0, 0, 0, 0
  10, 3, 2, 1, 2, 0, 4, 6, 6, 1, 1, 106, 308.4, 61448.64, 612, 0, 0, 0, 0
  14, 3, 2, 1, 2, 0, 5, 9, 9, 1, 1, 106, 286.714285714, 58783.7755102, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 4, 8, 8, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  40, 2, 2, 2, 2, 0, 33, 33, 7, 1, 17, 64, 71.35, 254.6775, 106, 0, 0, 0, 0
  18, 4, 3, 2, 3, 0, 11, 7, 7, 1, 4, 64, 202.111111111, 48345.5432099, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 4, 8, 8, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  14, 3, 2, 1, 2, 0, 7, 7, 7, 1, 1, 106, 359.0, 64009.0, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 5, 7, 7, 1, 1, 106, 316.833333333, 62230.9722222, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 4, 8, 8, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 4, 8, 8, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 4, 8, 8, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 5, 7, 7, 1, 1, 106, 316.833333333, 62230.9722222, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 4, 8, 8, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  242, 3, 3, 2, 3, 238, 1, 3, 3, 1, 1, 106, 430.669421488, 1453.51881702, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 4, 8, 8, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  14, 4, 3, 2, 2, 0, 4, 8, 8, 1, 1, 106, 270.142857143, 48891.5510204, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 4, 8, 8, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 5, 7, 7, 1, 1, 106, 316.833333333, 62230.9722222, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 4, 8, 8, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 6, 6, 6, 1, 1, 106, 359.0, 64009.0, 612, 0, 0, 0, 0
  10, 3, 2, 1, 2, 0, 4, 6, 6, 1, 1, 106, 308.4, 61448.64, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 4, 8, 8, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  34, 4, 6, 2, 4, 0, 13, 8, 6, 1, 1, 42, 144.882352941, 38046.633218, 612, 1, 0, 0, 0
  138, 11, 21, 2, 3, 0, 56, 38, 18, 1, 1, 42, 56.768115942, 186.323041378, 106, 1, 0, 0, 0
  12, 3, 2, 1, 2, 0, 5, 7, 7, 1, 1, 106, 316.833333333, 62230.9722222, 612, 0, 0, 0, 0
  10, 3, 2, 1, 2, 0, 3, 7, 7, 1, 1, 106, 257.8, 53767.56, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 5, 7, 7, 1, 1, 106, 316.833333333, 62230.9722222, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 6, 6, 6, 1, 1, 106, 359.0, 64009.0, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 4, 8, 8, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  10, 3, 2, 1, 2, 0, 4, 6, 6, 1, 1, 106, 308.4, 61448.64, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 5, 7, 7, 1, 1, 106, 316.833333333, 62230.9722222, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 4, 8, 8, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  20, 4, 4, 2, 3, 0, 4, 9, 7, 1, 1, 102, 205.4, 41334.04, 612, 0, 0, 0, 0
  576, 4, 4, 2, 3, 0, 4, 565, 283, 1, 1, 102, 105.590277778, 1793.55434992, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 5, 7, 7, 1, 1, 106, 316.833333333, 62230.9722222, 612, 0, 0, 0, 0
  14, 3, 2, 1, 2, 0, 6, 8, 8, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  10, 3, 2, 1, 2, 0, 4, 6, 6, 1, 1, 106, 308.4, 61448.64, 612, 0, 0, 0, 0
  10, 3, 2, 1, 2, 0, 4, 6, 6, 1, 1, 106, 308.4, 61448.64, 612, 0, 0, 0, 0
  14, 3, 2, 1, 2, 0, 5, 9, 9, 1, 1, 106, 286.714285714, 58783.7755102, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 4, 8, 8, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 4, 8, 8, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 4, 8, 8, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  14, 3, 2, 1, 3, 0, 6, 8, 8, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  14, 4, 3, 2, 3, 0, 6, 8, 8, 1, 2, 60, 171.428571429, 32598.5306122, 612, 0, 0, 0, 0
  10, 2, 2, 1, 2, 0, 2, 8, 8, 1, 1, 106, 207.2, 40965.76, 612, 0, 0, 0, 0
  10, 2, 2, 1, 2, 0, 2, 8, 8, 1, 1, 106, 207.2, 40965.76, 612, 0, 0, 0, 0
  10, 2, 2, 1, 2, 0, 3, 7, 7, 1, 1, 106, 257.8, 53767.56, 612, 0, 0, 0, 0
  12, 2, 2, 1, 2, 0, 3, 9, 9, 1, 1, 106, 232.5, 48006.75, 612, 0, 0, 0, 0
  14, 4, 3, 2, 3, 0, 6, 8, 8, 1, 2, 60, 172.285714286, 32487.3469388, 612, 0, 0, 0, 0
  10, 2, 2, 1, 2, 0, 2, 8, 8, 1, 1, 106, 207.2, 40965.76, 612, 0, 0, 0, 0
  10, 2, 2, 1, 2, 0, 2, 8, 8, 1, 1, 106, 207.2, 40965.76, 612, 0, 0, 0, 0
  10, 2, 2, 1, 2, 0, 3, 7, 7, 1, 1, 106, 257.8, 53767.56, 612, 0, 0, 0, 0
  14, 3, 3, 2, 3, 0, 4, 6, 6, 1, 1, 42, 162.857142857, 34231.8367347, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 4, 8, 8, 1, 2, 60, 182.666666667, 37147.5555556, 612, 0, 0, 0, 0
  10, 2, 2, 1, 2, 0, 3, 7, 7, 1, 1, 106, 257.8, 53767.56, 612, 0, 0, 0, 0
  10, 2, 2, 1, 2, 0, 2, 8, 8, 1, 1, 106, 207.2, 40965.76, 612, 0, 0, 0, 0
  10, 2, 2, 1, 2, 0, 2, 8, 8, 1, 1, 106, 207.2, 40965.76, 612, 0, 0, 0, 0
  12, 4, 3, 2, 3, 0, 5, 7, 7, 1, 2, 60, 185.833333333, 36478.3055556, 612, 0, 0, 0, 0
  10, 3, 2, 1, 2, 0, 3, 7, 7, 1, 2, 60, 202.6, 42087.24, 612, 0, 0, 0, 0
  10, 2, 2, 1, 2, 0, 2, 8, 8, 1, 1, 106, 207.2, 40965.76, 612, 0, 0, 0, 0
  14, 3, 2, 1, 3, 0, 6, 8, 8, 1, 1, 106, 322.857142857, 62702.6938776, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 4, 8, 8, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 4, 8, 8, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 5, 7, 7, 1, 1, 106, 316.833333333, 62230.9722222, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 6, 6, 6, 1, 1, 106, 359.0, 64009.0, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 4, 8, 8, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  10, 3, 2, 1, 2, 0, 4, 6, 6, 1, 1, 106, 308.4, 61448.64, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 5, 7, 7, 1, 1, 106, 316.833333333, 62230.9722222, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 4, 8, 8, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  32, 3, 3, 2, 3, 0, 21, 20, 7, 1, 10, 42, 74.9375, 9984.49609375, 612, 0, 0, 0, 0
  12, 3, 2, 1, 3, 0, 5, 7, 7, 1, 1, 106, 316.833333333, 62230.9722222, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 4, 8, 8, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 5, 7, 7, 1, 1, 106, 316.833333333, 62230.9722222, 612, 0, 0, 0, 0
  12, 3, 2, 1, 2, 0, 4, 8, 8, 1, 1, 106, 274.666666667, 56896.8888889, 612, 0, 0, 0, 0
  10, 3, 2, 1, 2, 0, 4, 6, 6, 1, 1, 106, 308.4, 61448.64, 612, 0, 0, 0, 0
  </code></pre>
  
  <p><strong>testing_labels.csv</strong> (100 first labels, complete file contains 193)</p>
  
  <pre><code>1
  1
  1
  1
  1
  1
  1
  -1
  -1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  -1
  -1
  1
  1
  1
  1
  1
  1
  1
  1
  -1
  -1
  1
  1
  1
  1
  1
  1
  1
  1
  -1
  1
  1
  1
  1
  1
  1
  1
  1
  -1
  -1
  1
  1
  1
  1
  1
  1
  1
  1
  -1
  -1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  1
  </code></pre>
  
  <p>I am using KNeighborsClassifier implementation of Scikit-Learn, but all predicted labels are set to 1:</p>
  
  <pre><code>#!/usr/bin/python
  import csv, numpy
  from sklearn.neighbors import KNeighborsClassifier
  from sklearn.preprocessing import MinMaxScaler
  
  # To save time and avoid attribute reconstruction, we have prebuilt training and testing files 
  # where the attributes are presented under CSV format.
  # We just need to convert these files into matrices so they can be used directly as input 
  # of the machine learning algorithms.
  
  def csv_attributes_to_matrix(csv_file):
      with open(csv_file, 'r') as data:
          rows = csv.reader(data, delimiter=',', quoting=csv.QUOTE_NONNUMERIC)
          return MinMaxScaler().fit_transform(numpy.array(list(rows)))
  
  def csv_labels_to_matrix(csv_file):
      with open(csv_file, 'r') as data:
          rows = csv.reader(data, delimiter=',')
          return [(int(row[0])) for row in rows]
  
  # Create vectors of normal labels for training =&gt; all-1-vector
  def create_normal_vectors(MATRIX_NORM_length):
      y = list()
      for l in range(MATRIX_NORM_length):
          y.append(1)
      return numpy.array(y)
  
  # Test of KNeighborsClassifier for anomaly detection
  def kNN_test(MATRIX_NORM, MATRIX_ANOM, real_labels):
      Y = create_normal_vectors(len(MATRIX_NORM))
  
      # Parameter grid search    
      for n_neighbors in [1, 2, 3, 5, 10]:
          for weights in ["uniform", "distance"]:
              for algo in ["ball_tree", "kd_tree", "brute"]:
                  for p in [1, 5, 10]:
                      for leaf_size in [1, 5, 10] if algo in ["ball_tree", "kd_tree"] else [None]:
                          trained_model = KNeighborsClassifier(n_neighbors, weights, algo, leaf_size, p)
                          trained_model.fit(MATRIX_NORM, Y)
                          predicted_labels = trained_model.predict(MATRIX_ANOM)
                          # Predicted labels are always all set to 1, why ?
                          print (n_neighbors, weights, algo, p, leaf_size), "\n", predicted_labels
  
  # Normal (training) and anomalous (testing) input csv files:
  MATRIX_NORM = csv_attributes_to_matrix("training_samples.csv")
  MATRIX_ANOM = csv_attributes_to_matrix("testing_samples.csv")
  real_labels = csv_labels_to_matrix("testing_labels.csv")
  
  # Launch test
  kNN_test(MATRIX_NORM, MATRIX_ANOM, real_labels)
  </code></pre>
  
  <p>It is possible to use the K Nearest Neighbor algorithm (if not from sklearn, one from another library) to perform novelty/outlier detection?</p>