whylogs.api.logger#

Subpackages#

Submodules#

Package Contents#

Classes#

Logger

Helper class that provides a standard way to create an ABC using

ProfileResultSet

A holder object for profiling results.

ResultSet

A holder object for profiling results.

ResultSetReader

SegmentedResultSet

A holder object for profiling results.

TimedRollingLogger

A rolling logger that continuously rotates files based on time.

TransientLogger

DatasetProfile

Dataset profile represents a collection of in-memory profiling stats for a dataset.

DatasetSchema

Defines the schema for tracking metrics in whylogs.

ModelPerformanceMetrics

Container class for various model-related performance metrics

Functions#

log_debug_event([debug_event, name, tags, ...])

emit_usage(→ None)

notebook_session_log(→ None)

notebook_session_log_comparison(→ None)

log(→ result_set.ResultSet)

log_classification_metrics(→ result_set.ResultSet)

Function to track metrics based on validation data.

log_regression_metrics(→ result_set.ResultSet)

Function to track regression metrics based on validation data.

read(→ result_set.ResultSet)

reader(→ result_set.ResultSetReader)

write(→ None)

logger(→ logger.Logger)

returns

a logger object

Attributes#

whylogs.api.logger.log_debug_event(debug_event: Optional[Dict[str, Any]] = None, *, trace_id: str, name: Optional[str] = None, tags: Optional[List[str]] = None, dataset_timestamp: Optional[datetime.datetime] = None, segment_key_values: Optional[Dict[str, str]] = None, write_local_file: bool = False)#
Parameters
  • debug_event (Optional[Dict[str, Any]]) –

  • trace_id (str) –

  • name (Optional[str]) –

  • tags (Optional[List[str]]) –

  • dataset_timestamp (Optional[datetime.datetime]) –

  • segment_key_values (Optional[Dict[str, str]]) –

  • write_local_file (bool) –

class whylogs.api.logger.Logger(schema: Optional[whylogs.core.DatasetSchema] = None)#

Bases: abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

Parameters

schema (Optional[whylogs.core.DatasetSchema]) –

check_writer(_: whylogs.api.writer.Writer) None#

Checks if a writer is configured correctly for this class

Parameters

_ (whylogs.api.writer.Writer) –

Return type

None

append_writer(name: Optional[str] = None, *, writer: Optional[whylogs.api.writer.Writer] = None, **kwargs: Any) None#
Parameters
Return type

None

append_store(store: whylogs.api.store.ProfileStore) None#
Parameters

store (whylogs.api.store.ProfileStore) –

Return type

None

log(obj: Any = None, *, pandas: Optional[whylogs.core.stubs.pd.DataFrame] = None, row: Optional[Dict[str, Any]] = None, schema: Optional[whylogs.core.DatasetSchema] = None, timestamp_ms: Optional[int] = None, name: Optional[str] = None, trace_id: Optional[str] = None, tags: Optional[List[str]] = None, segment_key_values: Optional[Dict[str, str]] = None) whylogs.api.logger.result_set.ResultSet#
Parameters
  • timestamp_ms (Optional[int]) – The timestamp of the data being logged. This defaults to now if it isn’t provided. This is used to determine what the dataset timestamp should be. For an hourly model, the dataset timestamp will end up being the start of the hour of the provided timestamp_ms, UTC.

  • obj (Any) –

  • pandas (Optional[whylogs.core.stubs.pd.DataFrame]) –

  • row (Optional[Dict[str, Any]]) –

  • schema (Optional[whylogs.core.DatasetSchema]) –

  • name (Optional[str]) –

  • trace_id (Optional[str]) –

  • tags (Optional[List[str]]) –

  • segment_key_values (Optional[Dict[str, str]]) –

Return type

whylogs.api.logger.result_set.ResultSet

close() None#
Return type

None

class whylogs.api.logger.ProfileResultSet(profile: whylogs.core.DatasetProfile)#

Bases: ResultSet

A holder object for profiling results.

A whylogs.log call can result in more than one profile. This wrapper class simplifies the navigation among these profiles.

Note that currently we only hold one profile but we’re planning to add other kinds of profiles such as segmented profiles here.

Parameters

profile (whylogs.core.DatasetProfile) –

property metadata: Optional[Dict[str, str]]#
Return type

Optional[Dict[str, str]]

property count: int#
Return type

int

property performance_metrics: Optional[whylogs.core.model_performance_metrics.ModelPerformanceMetrics]#
Return type

Optional[whylogs.core.model_performance_metrics.ModelPerformanceMetrics]

profile() Optional[whylogs.core.DatasetProfile]#
Return type

Optional[whylogs.core.DatasetProfile]

view() Optional[whylogs.core.DatasetProfileView]#
Return type

Optional[whylogs.core.DatasetProfileView]

static zero() ProfileResultSet#
Return type

ProfileResultSet

merge(other: ResultSet) ViewResultSet#
Parameters

other (ResultSet) –

Return type

ViewResultSet

get_default_path() Optional[str]#
Return type

Optional[str]

static read(multi_profile_file: str) ResultSet#
Parameters

multi_profile_file (str) –

Return type

ResultSet

static reader(name: str = 'local') ResultSetReader#
Parameters

name (str) –

Return type

ResultSetReader

get_writables() Optional[List[whylogs.api.writer.writer._Writable]]#
Return type

Optional[List[whylogs.api.writer.writer._Writable]]

set_dataset_timestamp(dataset_timestamp: datetime.datetime) None#
Parameters

dataset_timestamp (datetime.datetime) –

Return type

None

add_model_performance_metrics(metrics: whylogs.core.model_performance_metrics.ModelPerformanceMetrics) None#
Parameters

metrics (whylogs.core.model_performance_metrics.ModelPerformanceMetrics) –

Return type

None

add_metric(name: str, metric: whylogs.core.metrics.metrics.Metric) None#
Parameters
Return type

None

write(path: Optional[str] = None, **kwargs: Any) Tuple[bool, str]#
Parameters
  • path (Optional[str]) –

  • kwargs (Any) –

Return type

Tuple[bool, str]

writer(name: str = 'local', **kwargs: Any) WriterWrapper#

Utility method to create a Writer of the specified type

Parameters
  • name (str) –

  • kwargs (Any) –

Return type

WriterWrapper

class whylogs.api.logger.ResultSet#

Bases: whylogs.api.writer.writer._Writable, abc.ABC

A holder object for profiling results.

A whylogs.log call can result in more than one profile. This wrapper class simplifies the navigation among these profiles.

Note that currently we only hold one profile but we’re planning to add other kinds of profiles such as segmented profiles here.

property metadata: Optional[Dict[str, str]]#
Return type

Optional[Dict[str, str]]

property count: int#
Return type

int

property performance_metrics: Optional[whylogs.core.model_performance_metrics.ModelPerformanceMetrics]#
Return type

Optional[whylogs.core.model_performance_metrics.ModelPerformanceMetrics]

get_default_path() Optional[str]#
Return type

Optional[str]

static read(multi_profile_file: str) ResultSet#
Parameters

multi_profile_file (str) –

Return type

ResultSet

static reader(name: str = 'local') ResultSetReader#
Parameters

name (str) –

Return type

ResultSetReader

abstract view() Optional[whylogs.core.DatasetProfileView]#
Return type

Optional[whylogs.core.DatasetProfileView]

abstract profile() Optional[whylogs.core.DatasetProfile]#
Return type

Optional[whylogs.core.DatasetProfile]

get_writables() Optional[List[whylogs.api.writer.writer._Writable]]#
Return type

Optional[List[whylogs.api.writer.writer._Writable]]

set_dataset_timestamp(dataset_timestamp: datetime.datetime) None#
Parameters

dataset_timestamp (datetime.datetime) –

Return type

None

add_model_performance_metrics(metrics: whylogs.core.model_performance_metrics.ModelPerformanceMetrics) None#
Parameters

metrics (whylogs.core.model_performance_metrics.ModelPerformanceMetrics) –

Return type

None

add_metric(name: str, metric: whylogs.core.metrics.metrics.Metric) None#
Parameters
Return type

None

abstract merge(other: ResultSet) ResultSet#
Parameters

other (ResultSet) –

Return type

ResultSet

write(path: Optional[str] = None, **kwargs: Any) Tuple[bool, str]#
Parameters
  • path (Optional[str]) –

  • kwargs (Any) –

Return type

Tuple[bool, str]

writer(name: str = 'local', **kwargs: Any) WriterWrapper#

Utility method to create a Writer of the specified type

Parameters
  • name (str) –

  • kwargs (Any) –

Return type

WriterWrapper

class whylogs.api.logger.ResultSetReader(reader: whylogs.api.reader.Reader)#
Parameters

reader (whylogs.api.reader.Reader) –

option(**kwargs: Any) ResultSetReader#
Parameters

kwargs (Any) –

Return type

ResultSetReader

read(**kwargs: Any) ResultSet#
Parameters

kwargs (Any) –

Return type

ResultSet

class whylogs.api.logger.SegmentedResultSet(segments: Dict[str, Dict[whylogs.core.Segment, Union[whylogs.core.DatasetProfile, whylogs.core.DatasetProfileView]]], partitions: Optional[List[whylogs.core.segmentation_partition.SegmentationPartition]] = None, metrics: Optional[Dict[str, Any]] = None, properties: Optional[Dict[str, Any]] = None)#

Bases: ResultSet

A holder object for profiling results.

A whylogs.log call can result in more than one profile. This wrapper class simplifies the navigation among these profiles.

Note that currently we only hold one profile but we’re planning to add other kinds of profiles such as segmented profiles here.

Parameters
property dataset_properties: Optional[Dict[str, Any]]#
Return type

Optional[Dict[str, Any]]

property dataset_metrics: Optional[Dict[str, Any]]#
Return type

Optional[Dict[str, Any]]

property partitions: Optional[List[whylogs.core.segmentation_partition.SegmentationPartition]]#
Return type

Optional[List[whylogs.core.segmentation_partition.SegmentationPartition]]

property count: int#
Return type

int

property model_performance_metric: Optional[whylogs.core.model_performance_metrics.ModelPerformanceMetrics]#
Return type

Optional[whylogs.core.model_performance_metrics.ModelPerformanceMetrics]

property metadata: Optional[Dict[str, str]]#
Return type

Optional[Dict[str, str]]

property performance_metrics: Optional[whylogs.core.model_performance_metrics.ModelPerformanceMetrics]#
Return type

Optional[whylogs.core.model_performance_metrics.ModelPerformanceMetrics]

profile(segment: Optional[whylogs.core.Segment] = None) Optional[Union[whylogs.core.DatasetProfile, whylogs.core.DatasetProfileView]]#
Parameters

segment (Optional[whylogs.core.Segment]) –

Return type

Optional[Union[whylogs.core.DatasetProfile, whylogs.core.DatasetProfileView]]

get_writables() Optional[List[whylogs.api.writer.writer._Writable]]#
Return type

Optional[List[whylogs.api.writer.writer._Writable]]

get_whylabs_tags() List[whylabs_client.model.segment_tag.SegmentTag]#
Return type

List[whylabs_client.model.segment_tag.SegmentTag]

get_timestamps() List[Optional[datetime.datetime]]#
Return type

List[Optional[datetime.datetime]]

set_dataset_timestamp(dataset_timestamp: datetime.datetime) None#
Parameters

dataset_timestamp (datetime.datetime) –

Return type

None

segments(restrict_to_parition_id: Optional[str] = None) Optional[List[whylogs.core.Segment]]#
Parameters

restrict_to_parition_id (Optional[str]) –

Return type

Optional[List[whylogs.core.Segment]]

segments_in_partition(partition: whylogs.core.segmentation_partition.SegmentationPartition) Optional[Dict[whylogs.core.Segment, Union[whylogs.core.DatasetProfile, whylogs.core.DatasetProfileView]]]#
Parameters

partition (whylogs.core.segmentation_partition.SegmentationPartition) –

Return type

Optional[Dict[whylogs.core.Segment, Union[whylogs.core.DatasetProfile, whylogs.core.DatasetProfileView]]]

view(segment: Optional[whylogs.core.Segment] = None) Optional[whylogs.core.DatasetProfileView]#
Parameters

segment (Optional[whylogs.core.Segment]) –

Return type

Optional[whylogs.core.DatasetProfileView]

get_model_performance_metrics_for_segment(segment: whylogs.core.Segment) Optional[whylogs.core.model_performance_metrics.ModelPerformanceMetrics]#
Parameters

segment (whylogs.core.Segment) –

Return type

Optional[whylogs.core.model_performance_metrics.ModelPerformanceMetrics]

add_metrics_for_segment(metrics: whylogs.core.model_performance_metrics.ModelPerformanceMetrics, segment: whylogs.core.Segment) None#
Parameters
Return type

None

static zero() SegmentedResultSet#
Return type

SegmentedResultSet

add_model_performance_metrics(metrics: whylogs.core.model_performance_metrics.ModelPerformanceMetrics) None#
Parameters

metrics (whylogs.core.model_performance_metrics.ModelPerformanceMetrics) –

Return type

None

add_metric(name: str, metric: whylogs.core.metrics.metrics.Metric) None#
Parameters
Return type

None

merge(other: ResultSet) SegmentedResultSet#
Parameters

other (ResultSet) –

Return type

SegmentedResultSet

get_default_path() Optional[str]#
Return type

Optional[str]

static read(multi_profile_file: str) ResultSet#
Parameters

multi_profile_file (str) –

Return type

ResultSet

static reader(name: str = 'local') ResultSetReader#
Parameters

name (str) –

Return type

ResultSetReader

write(path: Optional[str] = None, **kwargs: Any) Tuple[bool, str]#
Parameters
  • path (Optional[str]) –

  • kwargs (Any) –

Return type

Tuple[bool, str]

writer(name: str = 'local', **kwargs: Any) WriterWrapper#

Utility method to create a Writer of the specified type

Parameters
  • name (str) –

  • kwargs (Any) –

Return type

WriterWrapper

class whylogs.api.logger.TimedRollingLogger(schema: Optional[whylogs.core.DatasetSchema] = None, *, base_name: Optional[str] = None, file_extension: Optional[str] = None, interval: int = 1, when: typing_extensions.Literal[S, M, H, D] = 'H', utc: bool = False, aligned: bool = True, fork: bool = False, skip_empty: bool = False, callback: Optional[Callable[[whylogs.api.writer.Writer, whylogs.core.DatasetProfileView, str], None]] = None, metadata: Optional[Dict[str, str]] = None)#

Bases: whylogs.api.logger.logger.Logger

A rolling logger that continuously rotates files based on time.

Parameters
check_writer(writer: whylogs.api.writer.Writer) None#

Checks if a writer is configured correctly for this class

Parameters

writer (whylogs.api.writer.Writer) –

Return type

None

close() None#
Return type

None

append_writer(name: Optional[str] = None, *, writer: Optional[whylogs.api.writer.Writer] = None, **kwargs: Any) None#
Parameters
Return type

None

append_store(store: whylogs.api.store.ProfileStore) None#
Parameters

store (whylogs.api.store.ProfileStore) –

Return type

None

log(obj: Any = None, *, pandas: Optional[whylogs.core.stubs.pd.DataFrame] = None, row: Optional[Dict[str, Any]] = None, schema: Optional[whylogs.core.DatasetSchema] = None, timestamp_ms: Optional[int] = None, name: Optional[str] = None, trace_id: Optional[str] = None, tags: Optional[List[str]] = None, segment_key_values: Optional[Dict[str, str]] = None) whylogs.api.logger.result_set.ResultSet#
Parameters
  • timestamp_ms (Optional[int]) – The timestamp of the data being logged. This defaults to now if it isn’t provided. This is used to determine what the dataset timestamp should be. For an hourly model, the dataset timestamp will end up being the start of the hour of the provided timestamp_ms, UTC.

  • obj (Any) –

  • pandas (Optional[whylogs.core.stubs.pd.DataFrame]) –

  • row (Optional[Dict[str, Any]]) –

  • schema (Optional[whylogs.core.DatasetSchema]) –

  • name (Optional[str]) –

  • trace_id (Optional[str]) –

  • tags (Optional[List[str]]) –

  • segment_key_values (Optional[Dict[str, str]]) –

Return type

whylogs.api.logger.result_set.ResultSet

class whylogs.api.logger.TransientLogger(schema: Optional[whylogs.core.DatasetSchema] = None)#

Bases: whylogs.api.logger.logger.Logger

Parameters

schema (Optional[whylogs.core.DatasetSchema]) –

whylogs.api.logger.emit_usage(event: str) None#
Parameters

event (str) –

Return type

None

whylogs.api.logger.notebook_session_log(result_set: whylogs.api.logger.result_set.ResultSet, obj: Any = None, *, pandas: Optional[whylogs.core.stubs.pd.DataFrame] = None, row: Optional[Dict[str, Any]] = None, name: Optional[str] = None) None#
Parameters
Return type

None

whylogs.api.logger.notebook_session_log_comparison(data: Dict[str, Union[whylogs.core.stubs.pd.DataFrame, List[Dict[str, Any]]]], result_sets: Dict[str, whylogs.api.logger.result_set.ResultSet]) None#
Parameters
Return type

None

class whylogs.api.logger.DatasetProfile(schema: Optional[whylogs.core.schema.DatasetSchema] = None, dataset_timestamp: Optional[datetime.datetime] = None, creation_timestamp: Optional[datetime.datetime] = None, metrics: Optional[Dict[str, Union[whylogs.core.metrics.Metric, Any]]] = None, metadata: Optional[Dict[str, str]] = None)#

Bases: whylogs.api.writer.writer._Writable

Dataset profile represents a collection of in-memory profiling stats for a dataset.

Parameters
  • schema (Optional[whylogs.core.schema.DatasetSchema]) – DatasetSchema, optional An object that represents the data column names and types

  • dataset_timestamp (Optional[datetime.datetime]) – int, optional A timestamp integer that best represents the date tied to the dataset generation. i.e.: A January 1st 2019 Sales Dataset will have 1546300800000 as the timestamp in miliseconds (UTC). If None is provided, it will take the current timestamp as default

  • creation_timestamp (Optional[datetime.datetime]) – int, optional The timestamp tied to the exact moment when the DatasetProfile is created. If None is provided, it will take the current timestamp as default

  • metrics (Optional[Dict[str, Union[whylogs.core.metrics.Metric, Any]]]) –

  • metadata (Optional[Dict[str, str]]) –

property creation_timestamp: datetime.datetime#
Return type

datetime.datetime

property dataset_timestamp: datetime.datetime#
Return type

datetime.datetime

property is_active: bool#

Returns True if the profile tracking code is currently running.

Return type

bool

property is_empty: bool#

Returns True if the profile tracking code is currently running.

Return type

bool

property metadata: Dict[str, str]#
Return type

Dict[str, str]

property model_performance_metrics: whylogs.core.model_performance_metrics.model_performance_metrics.ModelPerformanceMetrics#
Return type

whylogs.core.model_performance_metrics.model_performance_metrics.ModelPerformanceMetrics

set_dataset_timestamp(dataset_timestamp: datetime.datetime) None#
Parameters

dataset_timestamp (datetime.datetime) –

Return type

None

add_metric(col_name: str, metric: whylogs.core.metrics.Metric) None#
Parameters
Return type

None

add_dataset_metric(name: str, metric: whylogs.core.metrics.Metric) None#
Parameters
Return type

None

add_model_performance_metrics(metric: whylogs.core.model_performance_metrics.model_performance_metrics.ModelPerformanceMetrics) None#
Parameters

metric (whylogs.core.model_performance_metrics.model_performance_metrics.ModelPerformanceMetrics) –

Return type

None

track(obj: Any = None, *, pandas: Optional[whylogs.core.stubs.pd.DataFrame] = None, row: Optional[Mapping[str, Any]] = None, execute_udfs: bool = True) None#
Parameters
  • obj (Any) –

  • pandas (Optional[whylogs.core.stubs.pd.DataFrame]) –

  • row (Optional[Mapping[str, Any]]) –

  • execute_udfs (bool) –

Return type

None

view() whylogs.core.view.DatasetProfileView#
Return type

whylogs.core.view.DatasetProfileView

flush() None#
Return type

None

write(path: Optional[str] = None, **kwargs: Any) Tuple[bool, str]#
Parameters
  • path (Optional[str]) –

  • kwargs (Any) –

Return type

Tuple[bool, str]

classmethod read(input_path: str) whylogs.core.view.DatasetProfileView#
Parameters

input_path (str) –

Return type

whylogs.core.view.DatasetProfileView

writer(name: str = 'local', **kwargs: Any) WriterWrapper#

Utility method to create a Writer of the specified type

Parameters
  • name (str) –

  • kwargs (Any) –

Return type

WriterWrapper

class whylogs.api.logger.DatasetSchema(types: Optional[Dict[str, Any]] = None, default_configs: Optional[whylogs.core.metrics.metrics.MetricConfig] = None, type_mapper: Optional[whylogs.core.datatypes.TypeMapper] = None, resolvers: Optional[whylogs.core.resolvers.Resolver] = None, cache_size: int = 1024, schema_based_automerge: bool = False, segments: Optional[Dict[str, whylogs.core.segmentation_partition.SegmentationPartition]] = None, validators: Optional[Dict[str, List[whylogs.core.validators.validator.Validator]]] = None, metadata: Optional[Dict[str, str]] = None)#

Defines the schema for tracking metrics in whylogs.

In order to customize your tracking, you can extend this class to specify your own column schema or your own type resolution. Otherwise, you can just use the default DatasetSchema object.

Schema objects are also used to group datasets together.

Parameters
types#

required. a dictionay of column name to the Python type.

default_configs#

optional. Options to configure various behavior of whylogs.

type_mapper#

Optional. a mapper that transates the Python type to standardized whylogs DataType object.

resolvers#

Optional. an object that defines how to map from a column name, a whylogs DataType and a schema to metrics.

Examples

>>> import pandas as pd
>>> import numpy as np
>>> from whylogs.core import DatasetSchema, DatasetProfile
>>> from whylogs.core.resolvers import Resolver, StandardResolver
>>>
>>> class MyResolver(StandardResolver):
...    pass
>>>
>>> schema = DatasetSchema(
...    types={
...        "col1": str,
...        "col2": np.int32,
...        "col3": pd.CategoricalDtype(categories=('foo', 'bar'), ordered=True)
...    },
...    resolvers=MyResolver()
... )
>>> prof = DatasetProfile(schema)
>>> df = pd.DataFrame({"col1": ['foo'], "col2": np.array([1], dtype=np.int32), "col3": ['bar']})
>>> prof.track(pandas=df)
copy() DatasetSchema#

Returns a new instance of the same underlying schema

Return type

DatasetSchema

resolve(*, pandas: Optional[whylogs.core.stubs.pd.DataFrame] = None, row: Optional[Mapping[str, Any]] = None) bool#
Parameters
  • pandas (Optional[whylogs.core.stubs.pd.DataFrame]) –

  • row (Optional[Mapping[str, Any]]) –

Return type

bool

get_col_names() tuple#
Return type

tuple

get(name: str) Optional[ColumnSchema]#
Parameters

name (str) –

Return type

Optional[ColumnSchema]

whylogs.api.logger.WHYLABS_TRACE_ID_KEY = 'whylabs.traceId'#
class whylogs.api.logger.ModelPerformanceMetrics(confusion_matrix: Optional[whylogs.core.model_performance_metrics.confusion_matrix.ConfusionMatrix] = None, regression_metrics: Optional[whylogs.core.model_performance_metrics.regression_metrics.RegressionMetrics] = None, metrics: Optional[Dict[str, whylogs.core.metrics.metrics.Metric]] = None, field_metadata: Optional[Dict[str, Set[str]]] = None)#

Container class for various model-related performance metrics

Parameters
confusion_matrix#

ConfusionMatrix which keeps it track of counts with NumberTracker

Type

ConfusionMatrix

regression_metrics#

Regression Metrics keeps track of a common regression metrics in case the targets are continous.

Type

RegressionMetrics

property output_fields: Optional[List[str]]#
Return type

Optional[List[str]]

to_protobuf() whylogs.core.proto.v0.ModelProfileMessage#
Return type

whylogs.core.proto.v0.ModelProfileMessage

classmethod from_protobuf(message: whylogs.core.proto.v0.ModelProfileMessage) ModelPerformanceMetrics#
Parameters

message (whylogs.core.proto.v0.ModelProfileMessage) –

Return type

ModelPerformanceMetrics

compute_confusion_matrix(predictions: List[Union[str, int, bool, float]], targets: List[Union[str, int, bool, float]], scores: Optional[List[float]] = None)#

computes the confusion_matrix, if one is already present merges to old one.

Parameters
compute_regression_metrics(predictions: List[Union[float, int]], targets: List[Union[float, int]])#
Parameters
  • predictions (List[Union[float, int]]) –

  • targets (List[Union[float, int]]) –

add_metadata_to_field(column_name: str, categories: Set[str]) None#
Parameters
  • column_name (str) –

  • categories (Set[str]) –

Return type

None

specify_output_fields(column_names: Union[str, Set[str]]) None#
Parameters

column_names (Union[str, Set[str]]) –

Return type

None

merge(other) ModelPerformanceMetrics#
Return type

ModelPerformanceMetrics

whylogs.api.logger.diagnostic_logger#
whylogs.api.logger.Loggable#
whylogs.api.logger.log(obj: Any = None, *, pandas: Optional[whylogs.core.stubs.pd.DataFrame] = None, row: Optional[Dict[str, Any]] = None, schema: Optional[whylogs.core.DatasetSchema] = None, name: Optional[str] = None, multiple: Optional[Dict[str, Loggable]] = None, dataset_timestamp: Optional[datetime.datetime] = None, trace_id: Optional[str] = None, tags: Optional[List[str]] = None, segment_key_values: Optional[Dict[str, str]] = None, debug_event: Optional[Dict[str, Any]] = None) result_set.ResultSet#
Parameters
  • obj (Any) –

  • pandas (Optional[whylogs.core.stubs.pd.DataFrame]) –

  • row (Optional[Dict[str, Any]]) –

  • schema (Optional[whylogs.core.DatasetSchema]) –

  • name (Optional[str]) –

  • multiple (Optional[Dict[str, Loggable]]) –

  • dataset_timestamp (Optional[datetime.datetime]) –

  • trace_id (Optional[str]) –

  • tags (Optional[List[str]]) –

  • segment_key_values (Optional[Dict[str, str]]) –

  • debug_event (Optional[Dict[str, Any]]) –

Return type

result_set.ResultSet

whylogs.api.logger.log_classification_metrics(data: whylogs.core.stubs.pd.DataFrame, target_column: str, prediction_column: str, score_column: Optional[str] = None, schema: Optional[whylogs.core.DatasetSchema] = None, log_full_data: bool = False, dataset_timestamp: Optional[datetime.datetime] = None) result_set.ResultSet#

Function to track metrics based on validation data. user may also pass the associated attribute names associated with target, prediction, and/or score.

Parameters
  • data (pd.DataFrame) – Dataframe with the data to log.

  • target_column (str) – Column name for the actual validated values.

  • prediction_column (str) – Column name for the predicted values.

  • score_column (Optional[str], optional) – Associated scores for each inferred, all values set to 1 if None, by default None

  • schema (Optional[DatasetSchema], optional) – Defines the schema for tracking metrics in whylogs, by default None

  • log_full_data (bool, optional) – Whether to log the complete dataframe or not. If True, the complete DF will be logged in addition to the regression metrics. If False, only the calculated regression metrics will be logged. In a typical production use case, the ground truth might not be available at the time the remaining data is generated. In order to prevent double profiling the input features, consider leaving this as False. by default False.

  • dataset_timestamp (Optional[datetime], optional) – dataset’s timestamp, by default None

Return type

result_set.ResultSet

Examples

data = {
    "product": ["milk", "carrot", "cheese", "broccoli"],
    "category": ["dairies", "vegetables", "dairies", "vegetables"],
    "output_discount": [0, 0, 1, 1],
    "output_prediction": [0, 0, 0, 1],
}
df = pd.DataFrame(data)

results = why.log_classification_metrics(
        df,
        target_column="output_discount",
        prediction_column="output_prediction",
        log_full_data=True,
    )
whylogs.api.logger.log_regression_metrics(data: whylogs.core.stubs.pd.DataFrame, target_column: str, prediction_column: str, schema: Optional[whylogs.core.DatasetSchema] = None, log_full_data: bool = False, dataset_timestamp: Optional[datetime.datetime] = None) result_set.ResultSet#

Function to track regression metrics based on validation data. User may also pass the associated attribute names associated with target, prediction, and/or score.

Parameters
  • data (pd.DataFrame) – Dataframe with the data to log.

  • target_column (str) – Column name for the target values.

  • prediction_column (str) – Column name for the predicted values.

  • schema (Optional[DatasetSchema], optional) – Defines the schema for tracking metrics in whylogs, by default None

  • log_full_data (bool, optional) – Whether to log the complete dataframe or not. If True, the complete DF will be logged in addition to the regression metrics. If False, only the calculated regression metrics will be logged. In a typical production use case, the ground truth might not be available at the time the remaining data is generated. In order to prevent double profiling the input features, consider leaving this as False. by default False.

  • dataset_timestamp (Optional[datetime], optional) – dataset’s timestamp, by default None

Returns

Return type

ResultSet

Examples

import pandas as pd
import whylogs as why

df = pd.DataFrame({"target_temperature": [[10.5, 24.3, 15.6]], "predicted_temperature": [[9.12,26.42,13.12]]})
results = why.log_regression_metrics(df, target_column = "temperature", prediction_column = "prediction_temperature")
whylogs.api.logger.read(path: str) result_set.ResultSet#
Parameters

path (str) –

Return type

result_set.ResultSet

whylogs.api.logger.reader(name: str) result_set.ResultSetReader#
Parameters

name (str) –

Return type

result_set.ResultSetReader

whylogs.api.logger.write(profile: whylogs.core.DatasetProfile, base_dir: Optional[str] = None, filename: Optional[str] = None) None#
Parameters
Return type

None

whylogs.api.logger.logger(schema: Optional[whylogs.core.DatasetSchema] = None, *, mode: typing_extensions.Literal[transient, rolling] = 'transient', **kwargs: Any) logger.Logger#
Returns

a logger object

Return type

Logger

Parameters