Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README visualizations example code error in Colab environment #13

Open
gzorpidis opened this issue Oct 31, 2024 · 0 comments
Open

README visualizations example code error in Colab environment #13

gzorpidis opened this issue Oct 31, 2024 · 0 comments

Comments

@gzorpidis
Copy link

gzorpidis commented Oct 31, 2024

I am running, in a Colab environment, the code that is suggested in the README.md for visualizations. However there is an error that keeps popping up when initializing ZADU(). I have tried both !pip install zadu and !pip install git+https://github.com/hj-n/zadu.git but neither work and the error seems to be coming from knn_with_ranking(). Python version is: 3.10.12.

Error:

TypeError                                 Traceback (most recent call last)
[<ipython-input-6-6c5f17626372>](https://localhost:8080/#) in <cell line: 18>()
     16     "params": {"k": 50}
     17 }]
---> 18 zadu_obj = zadu.ZADU(spec, hd, return_local=True)
     19 
     20 ld = TSNE().fit_transform(hd)

1 frames
[/usr/local/lib/python3.10/dist-packages/zadu/measures/utils/knn.py](https://localhost:8080/#) in knn_with_ranking(points, k, distance_matrix)
     21     distance_matrix = pairwise_distance_matrix(points, "euclidean")
     22 
---> 23   knn_indices = np.empty((points.shape[0], k), dtype=np.int32)
     24   ranking = np.empty((points.shape[0], points.shape[0]), dtype=np.int32)
     25 

TypeError: an integer is required

Code:

from zaduvis import zaduvis
import matplotlib.pyplot as plt
from sklearn.manifold import TSNE
from sklearn.datasets import fetch_openml


hd = fetch_openml('mnist_784', version=1, cache=True).data.to_numpy()[::7]

spec = [{
    "id": "tnc",
    "params": {"k": 25}
},{
    "id": "snc",
    "params": {"k": 50}
}]
zadu_obj = zadu.ZADU(spec, hd, return_local=True)

ld = TSNE().fit_transform(hd)
scores, local_list = zadu_obj.measure(ld)

tnc_local = local_list[0]
snc_local = local_list[1]

local_trustworthiness = tnc_local["local_trustworthiness"]
local_continuity = tnc_local["local_continuity"]
local_steadiness = snc_local["local_steadiness"]
local_cohesiveness = snc_local["local_cohesiveness"]

fig, ax = plt.subplots(1, 4, figsize=(50, 12.5))
zaduvis.checkviz(ld, local_trustworthiness, local_continuity, ax=ax[0])
zaduvis.reliability_map(ld, local_trustworthiness, local_continuity, k=10, ax=ax[1])
zaduvis.checkviz(ld, local_steadiness, local_cohesiveness, ax=ax[2])
zaduvis.reliability_map(ld, local_steadiness, local_cohesiveness, k=10, ax=ax[3])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant