import abc
import strawberry
from _typeshed import Incomplete
from abc import ABC, abstractmethod
from enum import Enum
from io import StringIO
from tarandm_analytics_utils.predictive_models.attribute_preprocessing.attribute_preprocessing import AttributePreprocessing as AttributePreprocessing, AttributePreprocessingType as AttributePreprocessingType
from tarandm_analytics_utils.predictive_models.content import ExtendedPredictiveModelContent as ExtendedPredictiveModelContent
from tarandm_analytics_utils.predictive_models.model_description.model_description import PredictiveModelDescription as PredictiveModelDescription, PredictiveModelDescriptionType as PredictiveModelDescriptionType
from tarandm_analytics_utils.predictive_models.model_monitoring.model_monitoring import PredictiveModelMonitoring as PredictiveModelMonitoring, PredictiveModelMonitoringType as PredictiveModelMonitoringType
from tarandm_analytics_utils.predictive_models.model_performance.model_performance import PredictiveModelPerformance as PredictiveModelPerformance, PredictiveModelPerformanceType as PredictiveModelPerformanceType
from tarandm_analytics_utils.utils.base_model import BaseModel as BaseModel
from tarandm_analytics_utils.utils.dump import safe_dumps_json as safe_dumps_json, safe_loads_yaml as safe_loads_yaml, valid_dumps_yaml as valid_dumps_yaml
from typing import Any

class PredictiveModelType(str, Enum):
    LOGISTIC_REGRESSION = 'LOGISTIC_REGRESSION'
    PMML = 'PMML'
    XGB = 'XGB'
    EXPERT_SCORE = 'EXPERT_SCORE'
    RANDOM_FOREST = 'RANDOM_FOREST'

class AbstractExtendedPredictiveModel(BaseModel, ABC, metaclass=abc.ABCMeta):
    attributes: list[str]
    predictive_model_type: PredictiveModelType | None
    target: str | None
    target_class: str | None
    attribute_preprocessing: AttributePreprocessing
    description: PredictiveModelDescription
    performance: PredictiveModelPerformance
    monitoring: PredictiveModelMonitoring
    def preprocess_attributes(self) -> AbstractExtendedPredictiveModel: ...
    def get_content(self) -> ExtendedPredictiveModelContent: ...
    @classmethod
    def parse_from_content(cls, content: ExtendedPredictiveModelContent) -> AbstractExtendedPredictiveModel: ...
    def get_coefficient(self, attribute: str) -> float | None: ...
    @abstractmethod
    def get_external_model_stringio(self) -> StringIO: ...
    @abstractmethod
    def get_external_model_feature_names(self) -> list[str] | None: ...
    @abstractmethod
    def get_external_model_intercept(self) -> float | None: ...
    @abstractmethod
    def get_external_model_intercept_name(self) -> str | None: ...
    @abstractmethod
    def get_external_model_coefficients(self) -> list[float] | None: ...
    @abstractmethod
    def get_external_model_best_iteration(self) -> int | None: ...
    @abstractmethod
    def get_external_model_number_of_trees(self) -> int | None: ...
    @abstractmethod
    def get_external_model_number_of_attributes(self) -> int | None: ...
    @abstractmethod
    def get_external_model_best_eval_metric(self) -> float | None: ...

class ExtendedPredictiveModel(AbstractExtendedPredictiveModel):
    directory_name: str | None
    external_model: dict[str, Any]
    def get_external_model_stringio(self) -> StringIO: ...
    def get_external_model_feature_names(self) -> list[str] | None: ...
    def get_external_model_intercept(self) -> float | None: ...
    def get_external_model_intercept_name(self) -> str | None: ...
    def get_external_model_coefficients(self) -> list[float] | None: ...
    def get_external_model_best_iteration(self) -> int | None: ...
    def get_external_model_number_of_trees(self) -> int | None: ...
    def get_external_model_number_of_attributes(self) -> int | None: ...
    def get_external_model_best_eval_metric(self) -> float | None: ...

class ExternalPredictiveModelType:
    extended_model: Incomplete
    def __init__(self, extended_model: ExtendedPredictiveModel) -> None: ...
    @strawberry.field
    def coefficients(self) -> list[float] | None: ...
    @strawberry.field
    def intercept(self) -> float | None: ...
    @strawberry.field
    def intercept_name(self) -> str | None: ...
    @strawberry.field
    def best_eval_metric(self) -> float | None: ...
    @strawberry.field
    def best_iteration(self) -> int | None: ...
    @strawberry.field
    def number_of_attributes(self) -> int | None: ...
    @strawberry.field
    def number_of_trees(self) -> int | None: ...

class ExtendedPredictiveModelType:
    directory_name: strawberry.auto
    attributes: strawberry.auto
    predictive_model_type: strawberry.auto
    target: strawberry.auto
    target_class: strawberry.auto
    attribute_preprocessing: AttributePreprocessingType
    description: PredictiveModelDescriptionType
    performance: PredictiveModelPerformanceType
    monitoring: PredictiveModelMonitoringType
    @strawberry.field
    def formula(self, parent: strawberry.Parent[ExtendedPredictiveModel]) -> str | None: ...
    @strawberry.field
    def external_model(self, parent: strawberry.Parent[ExtendedPredictiveModel]) -> ExternalPredictiveModelType: ...
