def test_umap_transform_on_iris(): iris = datasets.load_iris() iris_selection = np.random.choice( [True, False], 150, replace=True, p=[0.75, 0.25]) data = iris.data[iris_selection] fitter = UMAP(n_neighbors=10, min_dist=0.01, verbose=True) fitter.fit(data) new_data = iris.data[~iris_selection] embedding = fitter.transform(new_data) trust = trustworthiness(new_data, embedding, 10) assert trust >= 0.90
def test_umap_downcast_fails(input_type): X = np.array([[1.0, 1.0], [50.0, 1.0], [51.0, 1.0]], dtype=np.float64) # Test fit() fails with double precision when should_downcast set to False umap = UMAP(should_downcast=False, verbose=True) if input_type == 'dataframe': X = cudf.DataFrame.from_pandas(pd.DataFrame(X)) with pytest.raises(Exception): umap.fit(X, should_downcast=False) # Test fit() fails when downcast corrupted data X = np.array([[np.finfo(np.float32).max]], dtype=np.float64) umap = UMAP(should_downcast=True) if input_type == 'dataframe': X = cudf.DataFrame.from_pandas(pd.DataFrame(X)) with pytest.raises(Exception): umap.fit(X, should_downcast=True)