The documentation provides the following example:
w = kmeans(a, (3, 150, 'random'))
y = w.eval(a)
e = dbi(a, y)
However, this raises the following exception:
"
Traceback (most recent call last):
File "week5/ex5_9.py", line 21, in main
e = pr.dbi(a, y)
File "prtools\prtools\prtools.py", line 1998, in dbi
e = davies_bouldin_score(a, lab.ravel())
AttributeError: 'prdataset' object has no attribute 'ravel'
"
Based on this exception you might expect that y should be an numpy array. So I also tried the following code:
w = kmeans(a, (3, 150, 'random'))
y = w.eval(a)
e = dbi(a, +y)
Now it can pass the point where the previous exception was raised but now we encounter a different exception namely:
"
Traceback (most recent call last):
File "week5/ex5_9.py", line 21, in main
e = pr.dbi(a, +y)
File "c:\users\j\documents\github\prtools\prtools\prtools.py", line 1998, in dbi
e = davies_bouldin_score(a, lab.ravel())
File "C:\Users\j.conda\envs\prtools\lib\site-packages\sklearn\metrics\cluster_unsupervised.py", line 343, in davies_bouldin_score
X, labels = check_X_y(X, labels)
File "C:\Users\j.conda\envs\prtools\lib\site-packages\sklearn\utils\validation.py", line 739, in check_X_y
estimator=estimator)
File "C:\Users\j.conda\envs\prtools\lib\site-packages\sklearn\utils\validation.py", line 533, in check_array
"if it contains a single sample.".format(array))
ValueError: Expected 2D array, got scalar array instead:
array=150 by 2 prdataset with 1 class: [150].
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.
Process finished with exit code 1
"
So how should I use this function? What are the expected inputs?
The documentation provides the following example:
However, this raises the following exception:
"
Traceback (most recent call last):
File "week5/ex5_9.py", line 21, in main
e = pr.dbi(a, y)
File "prtools\prtools\prtools.py", line 1998, in dbi
e = davies_bouldin_score(a, lab.ravel())
AttributeError: 'prdataset' object has no attribute 'ravel'
"
Based on this exception you might expect that y should be an numpy array. So I also tried the following code:
Now it can pass the point where the previous exception was raised but now we encounter a different exception namely:
"
Traceback (most recent call last):
File "week5/ex5_9.py", line 21, in main
e = pr.dbi(a, +y)
File "c:\users\j\documents\github\prtools\prtools\prtools.py", line 1998, in dbi
e = davies_bouldin_score(a, lab.ravel())
File "C:\Users\j.conda\envs\prtools\lib\site-packages\sklearn\metrics\cluster_unsupervised.py", line 343, in davies_bouldin_score
X, labels = check_X_y(X, labels)
File "C:\Users\j.conda\envs\prtools\lib\site-packages\sklearn\utils\validation.py", line 739, in check_X_y
estimator=estimator)
File "C:\Users\j.conda\envs\prtools\lib\site-packages\sklearn\utils\validation.py", line 533, in check_array
"if it contains a single sample.".format(array))
ValueError: Expected 2D array, got scalar array instead:
array=150 by 2 prdataset with 1 class: [150].
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.
Process finished with exit code 1
"
So how should I use this function? What are the expected inputs?