schema
ExperimentSchema
Bases: BaseSchema
Schema for a machine learning experiment.
Schema
Operations for working with machine learning experiment schemas.
from_df
classmethod
from_df(
df: pd.DataFrame,
metric_column_name: Optional[str] = None,
group_column_name: Optional[str] = None,
success_count_column_name: Optional[str] = None,
fail_count_column_name: Optional[str] = None,
identifier_column_name: Optional[str] = None,
ignore_column_names: Union[str, Collection[str]] = (),
) -> ExperimentSchema
Create a schema from a pandas dataframe.
Sends a sample of the dataframe to the NannyML Cloud API to inspect the schema. Heuristics are used to identify what each column represents. The schema is then modified according to the provided arguments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df |
DataFrame
|
The pandas dataframe to create a schema from. |
required |
metric_column_name |
Optional[str]
|
The name of the column containing the metric names. |
None
|
group_column_name |
Optional[str]
|
The name of the column containing the group names for each group. |
None
|
success_count_column_name |
Optional[str]
|
The name of the column containing the success count for a metric and group. |
None
|
fail_count_column_name |
Optional[str]
|
The name of the column containing the fail count for a metric and group. |
None
|
identifier_column_name |
Optional[str]
|
The name of the identifier column. Any column that heuristics identified as identifier will be changed to a feature column. |
None
|
ignore_column_names |
Union[str, Collection[str]]
|
The names of columns to ignore. |
()
|
Returns:
Type | Description |
---|---|
ExperimentSchema
|
The inspected schema with any modifications applied. |
set_fail_count
classmethod
set_fail_count(schema: ExperimentSchema, column_name: str) -> ExperimentSchema
Set the fail count column in a schema.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
schema |
ExperimentSchema
|
The schema to modify. |
required |
column_name |
str
|
The name of the fail count column. Any column that was previously set as the metric column will be changed to an ignored column. |
required |
set_group_name
classmethod
set_group_name(schema: ExperimentSchema, column_name: str) -> ExperimentSchema
Set the group name column in a schema.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
schema |
ExperimentSchema
|
The schema to modify. |
required |
column_name |
str
|
The name of the group name column. Any column that was previously set as the metric column will be changed to an ignored column. |
required |
set_identifier
classmethod
set_identifier(schema: ExperimentSchema, column_name: str) -> ExperimentSchema
Set the identifier column in a schema.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
schema |
ExperimentSchema
|
The schema to modify. |
required |
column_name |
str
|
The name of the identifier column. Any column that was previously set as identifier will be changed to a feature column. |
required |
Returns:
Type | Description |
---|---|
ExperimentSchema
|
The modified schema. |
set_ignored
classmethod
set_ignored(
schema: ExperimentSchema, column_names: Union[str, Collection[str]]
) -> ExperimentSchema
Set one or more columns to be ignored.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
schema |
ExperimentSchema
|
The schema to modify. |
required |
column_names |
Union[str, Collection[str]]
|
The name of the column or columns to ignore. |
required |
Returns:
Type | Description |
---|---|
ExperimentSchema
|
The modified schema. |
set_metric_name
classmethod
set_metric_name(schema: ExperimentSchema, column_name: str) -> ExperimentSchema
Set the metric name column in a schema.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
schema |
ExperimentSchema
|
The schema to modify. |
required |
column_name |
str
|
The name of the metric name column. Any column that was previously set as the metric column will be changed to an ignored column. |
required |
set_success_count
classmethod
set_success_count(
schema: ExperimentSchema, column_name: str
) -> ExperimentSchema
Set the success count column in a schema.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
schema |
ExperimentSchema
|
The schema to modify. |
required |
column_name |
str
|
The name of the success column. Any column that was previously set as the metric column will be changed to an ignored column. |
required |