コード例 #1
0
def test_plot_input(X_y, clf):
    plotter = TreeDependencePlotter(clf).fit(X_y[0], X_y[1])
    with pytest.raises(ValueError):
        plotter.plot(feature="not a feature")
    with pytest.raises(ValueError):
        plotter.plot(feature=0, type_binning=5)
    with pytest.raises(ValueError):
        plotter.plot(feature=0, min_q=1, max_q=0)
コード例 #2
0
def test_fit_complex(complex_data_split, complex_fitted_lightgbm):
    X_train, X_test, y_train, y_test = complex_data_split

    plotter = TreeDependencePlotter(complex_fitted_lightgbm)

    plotter.fit(X_test, y_test)

    pd.testing.assert_frame_equal(plotter.X, X_test)
    pd.testing.assert_series_equal(plotter.y, pd.Series(y_test, index=X_test.index))
    assert plotter.fitted is True

    # Check if plotting doesnt cause errors
    with patch('matplotlib.pyplot.figure') as mock_plt:
        for binning in ["simple", "agglomerative", "quantile"]:
            _ = plotter.plot(feature='f2_missing', type_binning=binning)
コード例 #3
0
def test_plot_class_names(X_y, clf):
    plotter = TreeDependencePlotter(clf).fit(X_y[0], X_y[1], class_names=["a", "b"])
    fig = plotter.plot(feature=0)
    assert plotter.class_names == ["a", "b"]
コード例 #4
0
def test_plot_normal(X_y, clf):
    plotter = TreeDependencePlotter(clf).fit(X_y[0], X_y[1])
    for binning in ["simple", "agglomerative", "quantile"]:
        fig = plotter.plot(feature=0, type_binning=binning)