#!/usr/bin/env python # coding: utf-8 # In[ ]: get_ipython().run_line_magic('pip', "install 'whylogs>=1.5.0'") # In[ ]: 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[ ]: import whylogs as why why.init(upload_on_log=True, allow_local=False) # In[ ]: profile = why.log(df, name="foo") # In[ ]: # Upload the same data as a batch profile by leaving out the name profile = why.log(df) # In[ ]: why.log(multiple={'foo': df, 'bar': df}) # # Switch to an autheneticated session # In[ ]: why.init(reinit=True, allow_anonymous=False, upload_on_log=True, whylabs_api_key="MPq7Hg002z.Na5VweqsJfu5ArGILjQTlGAyPyOhtOnEVEtqY2b5PXNGJLZLjHscT:org-JpsdM6", default_dataset_id="model-62") # In[ ]: 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[ ]: profile.writer('whylabs').write() # In[ ]: # as a reference profile profile.writer('whylabs').option(reference_profile_name="authenticated_ref").write()