This repository has been archived by the owner on Jun 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
22 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,38 @@ | ||
import phoenix as px | ||
import pandas as pd | ||
import numpy as np | ||
import os | ||
|
||
import numpy as np | ||
import pandas as pd | ||
import phoenix as px | ||
from dotenv import load_dotenv | ||
import os | ||
|
||
load_dotenv() | ||
|
||
DEFAULT_SCHEMA = px.Schema( | ||
actual_label_column_name="label", | ||
embedding_feature_column_names={ | ||
"text_embedding": px.EmbeddingColumnNames( | ||
vector_column_name="content_vector", | ||
raw_data_column_name="content", | ||
), | ||
} | ||
actual_label_column_name="label", | ||
embedding_feature_column_names={ | ||
"text_embedding": px.EmbeddingColumnNames( | ||
vector_column_name="content_vector", | ||
raw_data_column_name="content", | ||
), | ||
} | ||
) | ||
|
||
|
||
def create_dataset(name: str, | ||
dataframe: pd.DataFrame, | ||
embedding_vectors: list[np.array], | ||
dataframe: pd.DataFrame, | ||
embedding_vectors: list[np.array], | ||
predicted_labels: np.array = None, | ||
content: np.array = None): | ||
if content is not None: | ||
dataframe['content'] = content | ||
dataframe['content_vector'] = embedding_vectors | ||
if predicted_labels: dataframe['predicted_label'] = predicted_labels | ||
if content is not None: | ||
dataframe['content'] = content | ||
dataframe['content_vector'] = embedding_vectors | ||
if predicted_labels: dataframe['predicted_label'] = predicted_labels | ||
|
||
return px.Dataset(dataframe=dataframe, schema=DEFAULT_SCHEMA, name=name) | ||
|
||
return px.Dataset(dataframe=dataframe, schema=DEFAULT_SCHEMA, name=name) | ||
|
||
def launch_px(primary_dataset: px.Dataset, reference_dataset: px.Dataset): | ||
return px.launch_app(primary=primary_dataset, | ||
return px.launch_app(primary=primary_dataset, | ||
reference=reference_dataset, | ||
host=os.getenv('PHOENIX_HOST'), | ||
port=os.getenv('PHOENIX_PORT')) | ||
port=os.getenv('PHOENIX_PORT')) |