def _local_umap_trustworthiness(local_X, local_y, n_neighbors, supervised): """ Train model on all data, report trustworthiness """ from cuml.manifold import UMAP local_model = UMAP(n_neighbors=n_neighbors, random_state=42) y_train = None if supervised: y_train = local_y local_model.fit(local_X, y=y_train) embedding = local_model.transform(local_X) return trustworthiness(local_X, embedding, n_neighbors=n_neighbors, batch_size=5000)
def local_umap_trustworthiness(): local_model = UMAP(n_neighbors=n_neighbors) local_model.fit(local_X, local_y) embedding = local_model.transform(local_X) return trustworthiness(local_X, embedding, n_neighbors)
from sklearn.datasets import load_digits from numba import cuda from pyrr import Matrix44 import numpy as np import cudatashader as ds from cudatashader import transfer_functions as tf from cudatashader.colors import Hot from IPython.core.display import display, HTML, clear_output digits = load_digits() data, target_classes = digits.data, digits.target n_samples = target_classes.shape[0] reducer = UMAP(n_components=3) reducer.fit(data) embedding = reducer.transform(data) maxThreadsPerBlock = cuda.get_current_device().MAX_THREADS_PER_BLOCK @cuda.jit('void(int64[:], float64[:,:])') def fill_agg_value(target_classes, result): i = cuda.grid(1) result[i, 2] = target_classes[i] @cuda.jit('void(float64[:,:], float64[:,:], float64[:,:])') def apply_projection(MVP, embedding, result): i = cuda.grid(1) x, y, z = embedding[i, 0], embedding[i, 1], embedding[i, 2] result[i, 0] = MVP[0, 0] * x + MVP[1, 0] * y + MVP[2, 0] * z + MVP[3, 0]