#!/usr/bin/env python # coding: utf-8 # In[1]: 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() # In[2]: import whylogs as why why.init() # In[3]: profile = why.log(df, name="foo") # In[4]: # Upload the same data as a batch profile by leaving out the name profile = why.log(df) # In[5]: why.log(multiple={'foo': df, 'bar': df}) # # Switch to an autheneticated session # In[6]: why.init(reinit=True, allow_anonymous=False, whylabs_api_key="MPq7Hg002z.Na5VweqsJfu5ArGILjQTlGAyPyOhtOnEVEtqY2b5PXNGJLZLjHscT:org-JpsdM6", default_dataset_id="model-62") # In[7]: profile = why.log(df, name="real_dataset") # ## Or upload via the whylabs writer # This will use the session for credentials as well, it just won't have all of the fancy output. # In[8]: profile.writer('whylabs').write() # In[9]: # as a reference profile profile.writer('whylabs').option(reference_profile_name="authenticated_ref").write()