Пример #1
0
def test_feature_importance_attribute_exists_for_elasticnet(wandb_init_run):
    X, y = make_regression(n_features=2, random_state=42)
    two_features = ['a', 'b']
    model = ElasticNet(random_state=42)
    model.fit(X, y)

    result = plot_feature_importances(model, feature_names=two_features)

    assert isinstance(result, wandb.viz.Visualize)
Пример #2
0
def test_feature_importance_attribute_does_not_exists(
    wandb_init_run, dummy_model, dummy_data
):
    dummy_model.fit(*dummy_data, epochs=2, batch_size=36, callbacks=[WandbCallback()])
    dummy_features = []

    result = plot_feature_importances(dummy_model, feature_names=dummy_features)

    assert result is None
Пример #3
0
def test_feature_importance_attribute_exists_for_random_forest(wandb_init_run):
    X, y = make_hastie_10_2(random_state=0)

    model = GradientBoostingClassifier(
        n_estimators=100, learning_rate=1.0, max_depth=1, random_state=42
    )
    ten_features = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "k"]
    model.fit(X, y)

    result = plot_feature_importances(model, feature_names=ten_features)

    assert isinstance(result, wandb.viz.Visualize)
Пример #4
0
def test_feature_importance_attribute_exists_for_random_forest(wandb_init_run):
    X, y = make_hastie_10_2(random_state=0)

    model = GradientBoostingClassifier(n_estimators=100,
                                       learning_rate=1.0,
                                       max_depth=1,
                                       random_state=42)
    ten_features = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'k']
    model.fit(X, y)

    result = plot_feature_importances(model, feature_names=ten_features)

    assert isinstance(result, wandb.viz.Visualize)
Пример #5
0
def test_feature_importance_attribute_type(wandb_init_run):
    X, y = make_regression(n_features=2, random_state=42)
    model = ElasticNet(random_state=42)
    model.fit(X, y)

    # input np.array instead of list
    two_features = np.array(["a", "b"])

    result = None
    try:
        result = plot_feature_importances(model, feature_names=two_features)
    except ValueError:
        pytest.fail('incorrect plot_feature_importances arguments: ValueError')

    assert isinstance(result, wandb.viz.Visualize)