comet_mpm.api_objects.Model ΒΆ
Model(client: Client, model_id: str)
A model instance for interacting with Comet MPM model-specific operations.
This class provides high-level methods for querying model predictions, metrics, and feature analysis. It can be configured with panel options for default parameter values.
Parameters:
client(Client) βThe Comet MPM client instance
model_id(str) βThe ID of the model to work with
Initialize a Model instance.
Parameters:
client(Client) βThe Comet MPM client instance for making API calls
model_id(str) βThe ID of the model to work with
_configβConfiguration strategy instance
AttributesΒΆ
model_id instance-attribute ΒΆ
model_id = model_id
FunctionsΒΆ
get_categorical_features ΒΆ
get_categorical_features() -> List[str]
Get the list of categorical features available for this model.
Returns:
List[str]βList[str]: List of categorical feature names
get_custom_metric ΒΆ
get_custom_metric(
sql: str,
start_date: Optional[str] = None,
end_date: Optional[str] = None,
interval_type: Optional[str] = None,
filters: Optional[List[str]] = None,
model_version: Optional[str] = None,
) -> pd.DataFrame
Execute a custom SQL query to retrieve model metrics.
Parameters:
sql(str) βSQL query string to execute
start_date(Optional[str], default:None) βStart date for filtering results (ISO format)
end_date(Optional[str], default:None) βEnd date for filtering results (ISO format)
interval_type(Optional[str], default:None) βType of interval for aggregation ("DAILY" or "HOURLY")
filters(Optional[List[str]], default:None) βList of filters to apply to results
model_version(Optional[str], default:None) βSpecific model version to query
Returns:
DataFrame(DataFrame) βResults of the SQL query
get_details ΒΆ
get_details() -> Dict[str, Any]
Get the details of a model.
Returns:
Dict[str, Any]βDict[str, Any]: Model details including metadata, configuration, and status
get_feature_category_distribution ΒΆ
get_feature_category_distribution(
feature_name: str,
normalize: bool = False,
start_date: Optional[str] = None,
end_date: Optional[str] = None,
interval_type: Optional[str] = None,
filters: Optional[List[str]] = None,
model_version: Optional[str] = None,
) -> pd.DataFrame
Get the distribution of categories for a categorical feature.
Parameters:
feature_name(str) βName of the categorical feature
normalize(bool, default:False) βIf True, returns percentages instead of counts
start_date(Optional[str], default:None) βStart date for distribution calculation (ISO format)
end_date(Optional[str], default:None) βEnd date for distribution calculation (ISO format)
interval_type(Optional[str], default:None) βType of interval for aggregation ("DAILY" or "HOURLY")
filters(Optional[List[str]], default:None) βList of filters to apply to distribution calculation
model_version(Optional[str], default:None) βSpecific model version to query
Returns:
DataFrame(DataFrame) βDistribution of feature categories
get_feature_density ΒΆ
get_feature_density(
feature_name: str,
start_date: Optional[str] = None,
end_date: Optional[str] = None,
filters: Optional[List[str]] = None,
model_version: Optional[str] = None,
interval_type: Optional[str] = None,
) -> pd.DataFrame
Get the probability density function (PDF) of a numeric feature.
Parameters:
feature_name(str) βName of the numeric feature
start_date(Optional[str], default:None) βStart date for density calculation (ISO format)
end_date(Optional[str], default:None) βEnd date for density calculation (ISO format)
filters(Optional[List[str]], default:None) βList of filters to apply to density calculation
model_version(Optional[str], default:None) βSpecific model version to query
interval_type(Optional[str], default:None) βType of interval for aggregation ("DAILY" or "HOURLY")
Returns:
DataFrame(DataFrame) βProbability density function of the feature values
get_feature_drift ΒΆ
get_feature_drift(
feature_name: str,
algorithm: str = "EMD",
start_date: Optional[str] = None,
end_date: Optional[str] = None,
interval_type: Optional[str] = None,
filters: Optional[List[str]] = None,
model_version: Optional[str] = None,
) -> pd.DataFrame
Calculate drift metrics for a specific feature.
Parameters:
feature_name(str) βName of the feature to calculate drift for
algorithm(str, default:'EMD') βDrift calculation algorithm ("EMD", "PSI", or "KL")
start_date(Optional[str], default:None) βStart date for drift calculation (ISO format)
end_date(Optional[str], default:None) βEnd date for drift calculation (ISO format)
interval_type(Optional[str], default:None) βType of interval for aggregation ("DAILY" or "HOURLY")
filters(Optional[List[str]], default:None) βList of filters to apply to drift calculation
model_version(Optional[str], default:None) βSpecific model version to query
Returns:
DataFrame(DataFrame) βDrift metrics for the specified feature
get_feature_percentiles ΒΆ
get_feature_percentiles(
feature_name: str,
percentiles: Optional[List[float]] = None,
start_date: Optional[str] = None,
end_date: Optional[str] = None,
filters: Optional[List[str]] = None,
model_version: Optional[str] = None,
interval_type: Optional[str] = None,
) -> pd.DataFrame
Get the specified percentiles for a numeric feature.
Parameters:
feature_name(str) βName of the numeric feature
percentiles(Optional[List[float]], default:None) βList of percentiles to calculate (default: [0, 0.1, 0.25, 0.5, 0.75, 0.9, 1]) Only these specific percentile values are supported
start_date(Optional[str], default:None) βStart date for percentile calculation (ISO format)
end_date(Optional[str], default:None) βEnd date for percentile calculation (ISO format)
filters(Optional[List[str]], default:None) βList of filters to apply to percentile calculation
model_version(Optional[str], default:None) βSpecific model version to query
interval_type(Optional[str], default:None) βType of interval for aggregation. Must be one of "DAILY" or "HOURLY". Passing any other value will raise a ValueError.
Returns:
DataFrame(DataFrame) βPercentile values for the specified feature
get_nb_predictions ΒΆ
get_nb_predictions(
start_date: Optional[str] = None,
end_date: Optional[str] = None,
interval_type: Optional[str] = None,
filters: Optional[List[str]] = None,
model_version: Optional[str] = None,
) -> pd.DataFrame
Get the number of predictions for a model within a specified time range.
Parameters:
start_date(Optional[str], default:None) βStart date for filtering predictions (ISO format)
end_date(Optional[str], default:None) βEnd date for filtering predictions (ISO format)
interval_type(Optional[str], default:None) βType of interval for aggregation ("DAILY" or "HOURLY")
filters(Optional[List[str]], default:None) βList of filters to apply to predictions
model_version(Optional[str], default:None) βSpecific model version to query
Returns:
DataFrameβpd.DataFrame: DataFrame containing the number of predictions matching the criteria
get_numerical_features ΒΆ
get_numerical_features() -> List[str]
Get the list of numerical features available for this model.
Returns:
List[str]βList[str]: List of numerical feature names