whylogs.api.logger
#
Subpackages#
Submodules#
Package Contents#
Classes#
Helper class that provides a standard way to create an ABC using |
|
A holder object for profiling results. |
|
A holder object for profiling results. |
|
A holder object for profiling results. |
|
A rolling logger that continuously rotates files based on time. |
|
Dataset profile represents a collection of in-memory profiling stats for a dataset. |
|
Defines the schema for tracking metrics in whylogs. |
|
Container class for various model-related performance metrics |
Functions#
|
|
|
|
|
|
|
|
|
|
|
Function to track metrics based on validation data. |
|
Function to track regression metrics based on validation data. |
|
|
|
|
|
|
|
|
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)#
- 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
- Return type
- append_writer(name: Optional[str] = None, *, writer: Optional[whylogs.api.writer.Writer] = None, **kwargs: Any) None #
- Parameters
name (Optional[str]) –
writer (Optional[whylogs.api.writer.Writer]) –
kwargs (Any) –
- Return type
- append_store(store: whylogs.api.store.ProfileStore) None #
- Parameters
store (whylogs.api.store.ProfileStore) –
- Return type
- 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]]) –
- Return type
- 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 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
- static reader(name: str = 'local') ResultSetReader #
- Parameters
name (str) –
- Return type
- 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
- add_model_performance_metrics(metrics: whylogs.core.model_performance_metrics.ModelPerformanceMetrics) None #
- Parameters
metrics (whylogs.core.model_performance_metrics.ModelPerformanceMetrics) –
- Return type
- add_metric(name: str, metric: whylogs.core.metrics.metrics.Metric) None #
- Parameters
name (str) –
metric (whylogs.core.metrics.metrics.Metric) –
- Return type
- 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 performance_metrics: Optional[whylogs.core.model_performance_metrics.ModelPerformanceMetrics]#
- Return type
Optional[whylogs.core.model_performance_metrics.ModelPerformanceMetrics]
- static reader(name: str = 'local') ResultSetReader #
- Parameters
name (str) –
- Return type
- 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
- add_model_performance_metrics(metrics: whylogs.core.model_performance_metrics.ModelPerformanceMetrics) None #
- Parameters
metrics (whylogs.core.model_performance_metrics.ModelPerformanceMetrics) –
- Return type
- add_metric(name: str, metric: whylogs.core.metrics.metrics.Metric) None #
- Parameters
name (str) –
metric (whylogs.core.metrics.metrics.Metric) –
- Return type
- 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
- 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
segments (Dict[str, Dict[whylogs.core.Segment, Union[whylogs.core.DatasetProfile, whylogs.core.DatasetProfileView]]]) –
partitions (Optional[List[whylogs.core.segmentation_partition.SegmentationPartition]]) –
metrics (Optional[Dict[str, Any]]) –
properties (Optional[Dict[str, Any]]) –
- property partitions: Optional[List[whylogs.core.segmentation_partition.SegmentationPartition]]#
- Return type
Optional[List[whylogs.core.segmentation_partition.SegmentationPartition]]
- property model_performance_metric: Optional[whylogs.core.model_performance_metrics.ModelPerformanceMetrics]#
- Return type
Optional[whylogs.core.model_performance_metrics.ModelPerformanceMetrics]
- 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
- 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
metrics (whylogs.core.model_performance_metrics.ModelPerformanceMetrics) –
segment (whylogs.core.Segment) –
- Return type
- static zero() SegmentedResultSet #
- Return type
- add_model_performance_metrics(metrics: whylogs.core.model_performance_metrics.ModelPerformanceMetrics) None #
- Parameters
metrics (whylogs.core.model_performance_metrics.ModelPerformanceMetrics) –
- Return type
- add_metric(name: str, metric: whylogs.core.metrics.metrics.Metric) None #
- Parameters
name (str) –
metric (whylogs.core.metrics.metrics.Metric) –
- Return type
- merge(other: ResultSet) SegmentedResultSet #
- Parameters
other (ResultSet) –
- Return type
- static reader(name: str = 'local') ResultSetReader #
- Parameters
name (str) –
- Return type
- 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
schema (Optional[whylogs.core.DatasetSchema]) –
base_name (Optional[str]) –
file_extension (Optional[str]) –
interval (int) –
when (typing_extensions.Literal[S, M, H, D]) –
utc (bool) –
aligned (bool) –
fork (bool) –
skip_empty (bool) –
callback (Optional[Callable[[whylogs.api.writer.Writer, whylogs.core.DatasetProfileView, str], None]]) –
- 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
- append_writer(name: Optional[str] = None, *, writer: Optional[whylogs.api.writer.Writer] = None, **kwargs: Any) None #
- Parameters
name (Optional[str]) –
writer (Optional[whylogs.api.writer.Writer]) –
kwargs (Any) –
- Return type
- append_store(store: whylogs.api.store.ProfileStore) None #
- Parameters
store (whylogs.api.store.ProfileStore) –
- Return type
- 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]]) –
- Return type
- 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.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
result_set (whylogs.api.logger.result_set.ResultSet) –
obj (Any) –
pandas (Optional[whylogs.core.stubs.pd.DataFrame]) –
row (Optional[Dict[str, Any]]) –
name (Optional[str]) –
- Return type
- 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
data (Dict[str, Union[whylogs.core.stubs.pd.DataFrame, List[Dict[str, Any]]]]) –
result_sets (Dict[str, whylogs.api.logger.result_set.ResultSet]) –
- Return type
- 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 typesdataset_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 defaultmetrics (Optional[Dict[str, Union[whylogs.core.metrics.Metric, Any]]]) –
- property creation_timestamp: datetime.datetime#
- Return type
- property dataset_timestamp: datetime.datetime#
- Return type
- property is_active: bool#
Returns True if the profile tracking code is currently running.
- Return type
- property is_empty: bool#
Returns True if the profile tracking code is currently running.
- Return type
- property model_performance_metrics: whylogs.core.model_performance_metrics.model_performance_metrics.ModelPerformanceMetrics#
- set_dataset_timestamp(dataset_timestamp: datetime.datetime) None #
- Parameters
dataset_timestamp (datetime.datetime) –
- Return type
- add_metric(col_name: str, metric: whylogs.core.metrics.Metric) None #
- Parameters
col_name (str) –
metric (whylogs.core.metrics.Metric) –
- Return type
- add_dataset_metric(name: str, metric: whylogs.core.metrics.Metric) None #
- Parameters
name (str) –
metric (whylogs.core.metrics.Metric) –
- Return type
- 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
- track(obj: Any = None, *, pandas: Optional[whylogs.core.stubs.pd.DataFrame] = None, row: Optional[Mapping[str, Any]] = None, execute_udfs: bool = True) None #
- view() whylogs.core.view.DatasetProfileView #
- Return type
- classmethod read(input_path: str) whylogs.core.view.DatasetProfileView #
- Parameters
input_path (str) –
- Return type
- 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 (Optional[Dict[str, Any]]) –
default_configs (Optional[whylogs.core.metrics.metrics.MetricConfig]) –
type_mapper (Optional[whylogs.core.datatypes.TypeMapper]) –
resolvers (Optional[whylogs.core.resolvers.Resolver]) –
cache_size (int) –
schema_based_automerge (bool) –
segments (Optional[Dict[str, whylogs.core.segmentation_partition.SegmentationPartition]]) –
validators (Optional[Dict[str, List[whylogs.core.validators.validator.Validator]]]) –
- 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
- resolve(*, pandas: Optional[whylogs.core.stubs.pd.DataFrame] = None, row: Optional[Mapping[str, Any]] = None) bool #
- 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 (Optional[whylogs.core.model_performance_metrics.confusion_matrix.ConfusionMatrix]) –
regression_metrics (Optional[whylogs.core.model_performance_metrics.regression_metrics.RegressionMetrics]) –
metrics (Optional[Dict[str, whylogs.core.metrics.metrics.Metric]]) –
- confusion_matrix#
ConfusionMatrix which keeps it track of counts with NumberTracker
- Type
- regression_metrics#
Regression Metrics keeps track of a common regression metrics in case the targets are continous.
- Type
- 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
- 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.
- merge(other) ModelPerformanceMetrics #
- Return type
- 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]]) –
debug_event (Optional[Dict[str, Any]]) –
- Return type
- 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
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
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
- whylogs.api.logger.reader(name: str) result_set.ResultSetReader #
- Parameters
name (str) –
- Return type
- whylogs.api.logger.write(profile: whylogs.core.DatasetProfile, base_dir: Optional[str] = None, filename: Optional[str] = None) None #
- Parameters
profile (whylogs.core.DatasetProfile) –
base_dir (Optional[str]) –
filename (Optional[str]) –
- Return type
- 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
- Parameters
schema (Optional[whylogs.core.DatasetSchema]) –
mode (typing_extensions.Literal[transient, rolling]) –
kwargs (Any) –