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

Error while using nearest_neigh_prop #145

Open
hasan-sayeed opened this issue Feb 25, 2023 · 3 comments
Open

Error while using nearest_neigh_prop #145

hasan-sayeed opened this issue Feb 25, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@hasan-sayeed
Copy link
Contributor

I'm trying to predict using trained model and facing the following error:

InvalidParameterError                     Traceback (most recent call last)
Cell In[16], line 13
     11 for i, val_df in enumerate(val_dfs):
     12     jd = jd + 1
---> 13     disc.predict(val_df, umap_random_state=42)
     14     dens_score.append(disc.dens_score_df.sample(frac=1))
     15     peak_score.append(disc.peak_score_df.sample(frac=1))

File c:\Users\hasan\miniconda3\envs\li_ml\lib\site-packages\mat_discover\mat_discover_.py:665, in Discover.predict(self, val_df, plotting, umap_random_state, pred_weight, proxy_weight, dummy_run, count_repeats, return_peak)
    663 # compound-wise scores (i.e. individual compounds)
    664 with self.Timer("nearest-neighbor-properties"):
--> 665     self.rad_neigh_avg_targ, self.k_neigh_avg_targ = nearest_neigh_props(
    666         self.dm, pred, n_neighbors=self.n_peak_neighbors
    667     )
    668     self.val_rad_neigh_avg = self.rad_neigh_avg_targ[val_ids]
    669     self.val_k_neigh_avg = self.k_neigh_avg_targ[val_ids]

File c:\Users\hasan\miniconda3\envs\li_ml\lib\site-packages\mat_discover\utils\nearest_neigh.py:48, in nearest_neigh_props(X, target, r_strength, radius, n_neighbors, metric, **NN_kwargs)
      6 def nearest_neigh_props(
      7     X,
      8     target,
   (...)
     13     **NN_kwargs,
     14 ):
...
     98     f"The {param_name!r} parameter of {caller_name} must be"
     99     f" {constraints_str}. Got {param_val!r} instead."
    100 )

InvalidParameterError: The 'radius' parameter of NearestNeighbors must be a float in the range [0, inf] or None. Got -0.28528690338134766 instead.
@hasan-sayeed hasan-sayeed added the bug Something isn't working label Feb 25, 2023
@sgbaird
Copy link
Member

sgbaird commented Feb 25, 2023

I can make a new kwarg that allows you to specify the radius directly. Maybe I need to give some more thought to the heuristic that's used to determine the default radius, too. https://mat-discover.readthedocs.io/en/latest/_modules/mat_discover/utils/nearest_neigh.html#nearest_neigh_props

I also wonder if this might have to do with you using so many neighbors. Might not be the issue, but maybe worth reducing the number of umap neighbors to something like 15 or 30 instead of 100's and see if you get the same error.

How many data points are you working with when you get the error?

@hasan-sayeed
Copy link
Contributor Author

My val_df has ~48000 datapoints

@sgbaird
Copy link
Member

sgbaird commented Feb 25, 2023

Lmk if reducing the number of neighbors works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants