コード例 #1
0
def integer_to_count(cls) -> InferenceRelation:
    return InferenceRelation(
        relationship=is_unsigned_int,
        transformer=lambda s: s.astype(np.uint64),
        type=cls,
        related_type=Integer,
    )
コード例 #2
0
def integer_to_count(cls) -> InferenceRelation:
    return InferenceRelation(
        relationship=is_unsigned_int,
        transformer=to_unsigned_int,
        type=cls,
        related_type=Integer,
    )
def categorical_to_ordinal(cls) -> InferenceRelation:
    from visions.types import Categorical

    return InferenceRelation(cls,
                             Categorical,
                             relationship=is_ordinal_cat,
                             transformer=to_ordinal)
コード例 #4
0
def string_to_ordinal(cls) -> InferenceRelation:
    from visions.types import String

    return InferenceRelation(
        type=cls,
        related_type=String,
        relationship=is_ordinal_str,
        transformer=to_ordinal,
    )
def string_to_categorical_distinct_count(cls) -> InferenceRelation:
    """Convert string to categorical when it has fewer than 50% unique values.

    Returns:
        relation
    """
    # TODO: only when not any other string relation (either exclude others or have ordering and evaluate last)
    return InferenceRelation(
        relationship=lambda s, state: s.nunique() / len(s) < 0.5,
        transformer=lambda s: s.astype("category"),
        related_type=String,
        type=cls,
    )