%pip install 'whylogs>=1.5.0'
from typing import Any
import pandas as pd
import numpy as np
def load_testing_data() -> pd.DataFrame: # TODO remove after user testing
data = pd.read_csv("https://guest-session-testing-public.s3.us-west-2.amazonaws.com/adult_income_m.csv")
def convert_random_values(value: Any) -> Any:
if isinstance(value, int) and np.random.random() < 1 / 100:
return str(value)
return value
data["capital-gain"] = data["capital-loss"].apply(convert_random_values)
data["capital-loss"] = data["capital-loss"].apply(convert_random_values)
return data
df = load_testing_data()
import whylogs as why
why.init(upload_on_log=True, allow_local=False)
Initializing session with config /home/anthony/.config/whylogs/config.ini ✅ Using session type: WHYLABS_ANONYMOUS ⤷ session id: session-6LpLjnAE
<whylogs.api.whylabs.session.session.GuestSession at 0x7fc674559c70>
profile = why.log(df, name="foo")
✅ Aggregated 48842 rows into profile foo Visualize and explore this profile with one-click 🔍 https://hub.whylabsapp.com/resources/model-1/profiles?profile=ref-zv5Qm5zwJw0XEzpo&sessionToken=session-6LpLjnAE
# Upload the same data as a batch profile by leaving out the name
profile = why.log(df)
✅ Aggregated 48842 rows into profile Visualize and explore this profile with one-click 🔍 https://hub.whylabsapp.com/resources/model-1/profiles?profile=1691712000000&sessionToken=session-6LpLjnAE
why.log(multiple={'foo': df, 'bar': df})
✅ Aggregated 48842 lines into profile 'foo', 48842 lines into profile 'bar' Visualize and explore the profiles with one-click 🔍 https://hub.whylabsapp.com/resources/model-1/profiles?profile=ref-aj7Q52Zszb0VhjeW&profile=ref-6awZJWQI347XFBgD&sessionToken=session-6LpLjnAE Or view each profile individually ⤷ https://hub.whylabsapp.com/resources/model-1/profiles?profile=ref-aj7Q52Zszb0VhjeW&sessionToken=session-6LpLjnAE ⤷ https://hub.whylabsapp.com/resources/model-1/profiles?profile=ref-6awZJWQI347XFBgD&sessionToken=session-6LpLjnAE
<whylogs.api.logger.result_set.ViewResultSet at 0x7fc5dc310d30>
why.init(reinit=True, allow_anonymous=False, upload_on_log=True, whylabs_api_key="MPq7Hg002z.Na5VweqsJfu5ArGILjQTlGAyPyOhtOnEVEtqY2b5PXNGJLZLjHscT:org-JpsdM6", default_dataset_id="model-62")
Initializing session with config /home/anthony/.config/whylogs/config.ini ✅ Using session type: WHYLABS ⤷ org id: org-JpsdM6 ⤷ api key: MPq7Hg002z ⤷ default dataset: model-62
<whylogs.api.whylabs.session.session.ApiKeySession at 0x7fc6765e76a0>
profile = why.log(df, name="real_dataset")
✅ Aggregated 48842 rows into profile real_dataset Visualize and explore this profile with one-click 🔍 https://hub.whylabsapp.com/resources/model-62/profiles?profile=ref-WvU6X5tH0Nrkh4a3
This will use the session for credentials as well, it just won't have all of the fancy output.
profile.writer('whylabs').write()
[(True, 'log-KCaCKErR8Gi7TooV')]
# as a reference profile
profile.writer('whylabs').option(reference_profile_name="authenticated_ref").write()
[(True, 'ref-vdBRFKAO8y9J2C7M')]