-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from enum import Enum | ||
|
||
|
||
class BaseEnum(str, Enum): | ||
@classmethod | ||
def get(cls, text: str) -> Enum: | ||
cls.__check_valid(text) | ||
return cls[text] | ||
|
||
@classmethod | ||
def __check_valid(cls, text: str) -> None: | ||
if text not in cls._member_map_.keys(): | ||
valid_members = ", ".join(list(cls._member_map_.keys())) | ||
raise ValueError( | ||
f"Invalid value: '{text}'. Expected one of: {valid_members}." | ||
) | ||
|
||
|
||
class SupportedTask(BaseEnum): | ||
binary: str = "binary" | ||
multiclass: str = "multiclass" | ||
|
||
|
||
class Metric(BaseEnum): | ||
auc: str = "auc" | ||
binary_logloss: str = "binary_logloss" | ||
binary_error: str = "binary_error" | ||
auc_mu: str = "auc_mu" | ||
multi_logloss: str = "multi_logloss" | ||
multi_error: str = "multi_error" | ||
|
||
|
||
class Objective(BaseEnum): | ||
focal: str = "focal" | ||
weighted: str = "weighted" |