Skip to content

The example code in the documentation of pr.dbi raise an exception #14

@j0rd1smit

Description

@j0rd1smit

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions