-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add default UMAP parameters in launch_app() (#1224)
* Reaching till GraphQLWithContext * typing.Dict not dict() * Dict import * Suggested review changes Added validation, moved umap_params to pointcloud and removed Optional for self.umap_parameters in context * CamelCase -> SnakeCase Co-authored-by: Mikyo King <mikeldking@gmail.com> * CamelCase -> SnakeCase all suggested changes Co-authored-by: Mikyo King <mikeldking@gmail.com> * Default UMAPparam changes Removed hardcoded defaults for single source of truth. * typing hints & process_session() Process_session() error. Logs at -> https://textdoc.co/maM9oCZwexUA4EWQ * Prettier check I'd installed the pre-commit hooks, but "black ." was taking too long and checking venv lib packages, so I was doing it manually just on src/*. * Adjust frontend * parse string correctly * fix duplicate lines * Update umap_parameters.py Co-authored-by: Roger Yang <80478925+RogerHYang@users.noreply.github.com> * Update umap_parameters.py Co-authored-by: Roger Yang <80478925+RogerHYang@users.noreply.github.com> * Update umap_parameters.py Co-authored-by: Roger Yang <80478925+RogerHYang@users.noreply.github.com> * Update src/phoenix/session/session.py Co-authored-by: Roger Yang <80478925+RogerHYang@users.noreply.github.com> * Update src/phoenix/session/session.py Co-authored-by: Roger Yang <80478925+RogerHYang@users.noreply.github.com> * Update src/phoenix/session/session.py Co-authored-by: Roger Yang <80478925+RogerHYang@users.noreply.github.com> * use positional arguments * fix style and imports --------- Co-authored-by: Mikyo King <mikeldking@gmail.com> Co-authored-by: Mikyo King <mikyo@arize.com> Co-authored-by: Roger Yang <80478925+RogerHYang@users.noreply.github.com>
- Loading branch information
1 parent
8bad5ac
commit dce7551
Showing
10 changed files
with
154 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export {}; | ||
|
||
declare global { | ||
interface Window { | ||
Config: { | ||
hasCorpus: boolean; | ||
UMAP: { | ||
minDist: number; | ||
nNeighbors: number; | ||
nSamples: number; | ||
}; | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from dataclasses import dataclass | ||
from typing import Any, Mapping, Optional | ||
|
||
DEFAULT_MIN_DIST = 0.0 | ||
DEFAULT_N_NEIGHBORS = 30 | ||
DEFAULT_N_SAMPLES = 500 | ||
|
||
MIN_NEIGHBORS = 5 | ||
MAX_NEIGHBORS = 100 | ||
MIN_SAMPLES = 1 | ||
MAX_SAMPLES = 1000 | ||
MIN_MIN_DIST = 0.0 | ||
MAX_MIN_DIST = 0.99 | ||
|
||
|
||
@dataclass | ||
class UMAPParameters: | ||
min_dist: float = DEFAULT_MIN_DIST | ||
n_neighbors: int = DEFAULT_N_NEIGHBORS | ||
n_samples: int = DEFAULT_N_SAMPLES | ||
|
||
def __post_init__(self) -> None: | ||
if not isinstance(self.min_dist, float) or not ( | ||
MIN_MIN_DIST <= self.min_dist <= MAX_MIN_DIST | ||
): | ||
raise ValueError( | ||
f"minDist must be float type, and between {MIN_MIN_DIST} and {MAX_MIN_DIST}" | ||
) | ||
|
||
if not isinstance(self.n_neighbors, int) or not ( | ||
MIN_NEIGHBORS <= self.n_neighbors <= MAX_NEIGHBORS | ||
): | ||
raise ValueError( | ||
f"nNeighbors must be int type, and between {MIN_NEIGHBORS} and {MAX_NEIGHBORS}" | ||
) | ||
|
||
if not isinstance(self.n_samples, int) or not ( | ||
MIN_SAMPLES <= self.n_samples <= MAX_SAMPLES | ||
): | ||
raise ValueError( | ||
f"nSamples must be int type, and between {MIN_SAMPLES} and {MAX_SAMPLES}" | ||
) | ||
|
||
|
||
def get_umap_parameters(default_umap_parameters: Optional[Mapping[str, Any]]) -> UMAPParameters: | ||
if not default_umap_parameters: | ||
return UMAPParameters() | ||
return UMAPParameters( | ||
min_dist=float(default_umap_parameters.get("min_dist", DEFAULT_MIN_DIST)), | ||
n_neighbors=int(default_umap_parameters.get("n_neighbors", DEFAULT_N_NEIGHBORS)), | ||
n_samples=int(default_umap_parameters.get("n_samples", DEFAULT_N_SAMPLES)), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters