コード例 #1
0
def test__get_target_info_regressor():
    np.random.seed(123)
    y = np.random.randn(100)

    result = OutSamplerTransformer._get_target_info(y, False)
    assert result["multi_output"] == False

    result = OutSamplerTransformer._get_target_info(y.reshape((50, 2)), False)
    assert result["multi_output"] == True
    assert result["y_names"] == ["output0", "output1"]

    result = OutSamplerTransformer._get_target_info(
        pd.DataFrame(y.reshape((50, 2)), columns=["tA", "tB"]), False)
    assert result["multi_output"] == True
    assert result["y_names"] == ["tA", "tB"]
コード例 #2
0
def test__get_target_info_classifier():
    np.random.seed(123)
    y = 1 * (np.random.randn(100) > 0)

    result = OutSamplerTransformer._get_target_info(y, True)
    assert result["multi_output"] == False
    assert result["nby"] == 2

    result = OutSamplerTransformer._get_target_info(y.reshape((50, 2)), True)
    assert result["multi_output"] == True
    assert result["y_names"] == ["output0", "output1"]
    assert result["nby"] == [2, 2]

    result = OutSamplerTransformer._get_target_info(
        pd.DataFrame(y.reshape((50, 2)), columns=["tA", "tB"]), True)
    assert result["multi_output"] == True
    assert result["y_names"] == ["tA", "tB"]
    assert result["nby"] == [2, 2]

    y = np.array(["a", "b", "c"])[np.random.randint(0, 3, 100)]
    result = OutSamplerTransformer._get_target_info(y, True)
    assert result["multi_output"] == False
    assert result["nby"] == 3

    result = OutSamplerTransformer._get_target_info(y.reshape((50, 2)), True)
    assert result["multi_output"] == True
    assert result["y_names"] == ["output0", "output1"]
    assert result["nby"] == [3, 3]

    result = OutSamplerTransformer._get_target_info(
        pd.DataFrame(y.reshape((50, 2)), columns=["tA", "tB"]), True)
    assert result["multi_output"] == True
    assert result["y_names"] == ["tA", "tB"]
    assert result["nby"] == [3, 3]