Open Chowdeshetty opened 7 years ago
Same problem here.... :)
Don't think I'll have time to fix this at the moment, but happy to receive a pull request.
This issue is fixed in this implementation : https://github.com/LeeDoYup/Anomaly-Detection-with-K-means
I am having the same error :((
Traceback (most recent call last): File "learn.py", line 68, in
main()
File "learn.py", line 55, in main
reconstruction = learn_utils.reconstruct(data, window, clusterer)
File "/Users/hotify/Downloads/thermometr-master/models/learn_utils.py", line 63, in reconstruct
nearest_match_idx = clusterer.predict(segment)[0]
File "/usr/local/lib/python2.7/site-packages/sklearn/cluster/kmeans.py", line 981, in predict
X = self._check_test_data(X)
File "/usr/local/lib/python2.7/site-packages/sklearn/cluster/kmeans.py", line 865, in _check_test_data
X = check_array(X, accept_sparse='csr', dtype=FLOAT_DTYPES)
File "/usr/local/lib/python2.7/site-packages/sklearn/utils/validation.py", line 410, in check_array
"if it contains a single sample.".format(array))
ValueError: Expected 2D array, got 1D array instead:
array=[ -0.00000000e+00 -4.09401175e-02 -2.02605471e-01 -1.79236559e-01
-3.11033081e-01 -7.06553985e-01 -6.52694747e-01 -1.69714444e+00
-2.62662292e+00 -5.00261013e+00 -5.04137953e+00 -8.86658290e+00
-7.03503249e+00 -1.03089064e+01 -1.07477659e+01 -8.97691196e+00
9.97434662e-01 5.86241777e+00 1.12460797e+01 9.67316967e+00
1.93452718e+01 1.22433503e+01 6.87858893e+00 -1.05064917e+00
-4.24286111e-01 -5.87425272e+00 -4.47484190e+00 -3.42136389e+00
-1.70274731e+00 -9.31985166e-01 -1.94465558e-01 -3.59942348e-31].
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.