Models¶
Core data structures for building expert scorecards. ExpertScorecard is natively sklearn-compatible.
Scorecard¶
- class risk_kit.expert_scorecard.models.ExpertScorecard(features, validation_registry=None)[source]¶
Bases:
BaseEstimator,RegressorMixin
Features¶
- class risk_kit.expert_scorecard.models.BaseFeature(*, name, family, description, buckets, weight, default_score=0.0)[source]¶
-
Base class for all feature types.
- buckets: list[NumericBucket] | list[ObjectBucket]¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class risk_kit.expert_scorecard.models.NumericFeature(*, name, family, description, buckets, weight, default_score=0.0)[source]¶
Bases:
BaseFeatureFeature for numeric values using NumericBucket instances.
- buckets: list[NumericBucket]¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class risk_kit.expert_scorecard.models.ObjectFeature(*, name, family, description, buckets, weight, default_score=0.0)[source]¶
Bases:
BaseFeatureFeature for categorical/string values using ObjectBucket instances.
- buckets: list[ObjectBucket]¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Buckets¶
- class risk_kit.expert_scorecard.models.Bucket(*, definition, score)[source]¶
Bases:
BaseModel,ABC,Generic[T]Abstract base class for all bucket types. bucket types can be whatever you want them to be. We have two concrete implementations: NumericBucket and ObjectBucket. Subclasses must implement get_score get_sort_key and overlaps_with methods. TODO: Can we do away with sort keys and display_definition or make them nicer/easier to work with since it is only a visual thing? TODO: think about whether an ABC is the best way to go here. Do we need BaseModel?
- definition: BucketDefinitionType¶
- abstractmethod overlaps_with(other)[source]¶
Check if this bucket overlaps with another bucket of the same type
- abstractmethod display_definition()[source]¶
Return a human-readable string representation of the bucket definition
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class risk_kit.expert_scorecard.models.NumericBucket(*, definition, score, left_inclusive=True, right_inclusive=False)[source]¶
Bases:
Bucket[NumericBucket]Implementation of a Bucket class for numeric values. Numerical buckets are made up of ranges or exact values. Usually exact values are used for “special cases” such as a number than has a special meaning like 99999 or 0. Ranges are used for “normal cases” such as 18-25, 26-65, 66-100.
- definition: NumericDefinitionType¶
- display_definition()[source]¶
Return a human-readable string representation of the bucket definition
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class risk_kit.expert_scorecard.models.ObjectBucket(*, definition, score)[source]¶
Bases:
Bucket[ObjectBucket]Bucket for string/categorical values. Supports single strings or lists of strings.
- definition: ObjectDefinitionType¶
- display_definition()[source]¶
Return a human-readable string representation of the bucket definition
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].