Пример #1
0
 def greater_is_better_distinction(metric):
     sign = Scorer.metric_sign(metric)
     if sign == 1:
         return True
     elif sign == -1:
         return False
     else:
         raise_PhotonaiError("Metric can not be of sign: {}".format(sign))
Пример #2
0
 def metric_metadata(m: str = "accuracy",
                     metadata_id: int = METRIC_PKGID) -> Union[str, int]:
     Scorer.is_metric(m)
     if metadata_id < METRIC_METADATA_OUT_OF_BOUNDS and metadata_id > -1:
         return METRIC_METADATA[m][metadata_id]
     else:
         raise_PhotonaiError(
             "METRIC_METADATA_index OUT_OF_BOUNDS bounds: {}, was index: {}"
             .format(METRIC_METADATA_OUT_OF_BOUNDS, metadata_id))
Пример #3
0
    def is_score_type(score_type: str) -> bool:
        """

        Parameters
        ----------
        score_type

        Returns
        -------
        True or PhotonaiError

        """
        if score_type in Scorer.SCORE_TYPES:
            return True

        raise_PhotonaiError("Specify valid score_type:{} of [{}]".format(
            score_type, Scorer.SCORE_TYPES))
Пример #4
0
    def is_metric(metric: str) -> Union[bool, PhotonaiError]:
        """
        Raises
        --------
        if not known metric

        Parameters
        ----------
        metric

        Returns
        -------
        True or PhotonaiError
        """
        if metric in Scorer.METRIC_METADATA:
            return True

        raise_PhotonaiError("Specify valid ml_type:{} of [{}]".format(
            metric, Scorer.METRIC_METADATA))
Пример #5
0
    def is_machine_learning_type(ml_type: str) -> Union[bool, PhotonaiError]:
        """

        Parameters
        ----------
        ml_type

        Returns
        -------
        True or PhotonaiError

        Raises
        ------
        if not known machine_learning_type

        """
        if ml_type in Scorer.ML_TYPES:
            return True

        raise_PhotonaiError(
            "Specify valid ml_type. invalid :{} of supported: [{}]".format(
                ml_type, Scorer.ML_TYPES))
Пример #6
0
    def is_estimator_predict(estimator: str) -> Union[bool, PhotonaiError]:
        """

        Parameters
        ----------
        element_type

        Returns
        -------
        True - if element_type is one of Scorer.ELEMENT_TYPES

        Raises
        -------
        PhotonaiError

        """
        if hasattr(estimator, Scorer.ESTIMATOR_PREDICT):
            return True

        raise_PhotonaiError(
            "Estimator does not implement predict() method: {}]".format(
                estimator))
Пример #7
0
    def is_estimator(element_type: str) -> Union[bool, PhotonaiError]:
        """

        Parameters
        ----------
        element_type

        Returns
        -------
        True - if element_type is one of Scorer.ELEMENT_TYPES

        Raises
        -------
        PhotonaiError

        """

        if hasattr(element_type, Scorer.ESTIMATOR):
            return True

        raise_PhotonaiError("Specify valid element_type:{} of [{}]".format(
            element_type, Scorer.ELEMENT_TYPES))
Пример #8
0
    def is_estimator_not_predict(
            element_type: str) -> Union[bool, PhotonaiError]:
        """

        Parameters
        ----------
        element_type

        Returns
        -------
        True - if element_type is one of Scorer.ELEMENT_TYPES

        Raises
        -------
        PhotonaiError

        """
        if not hasattr(element_type, Scorer.ESTIMATOR_PREDICT):
            return True

        raise_PhotonaiError(
            "Element has predict() method but does not specify whether it is an estimator,\
             Remember to inherit from <estimator>Mixin.")