Пример #1
0
    def test_matrix_filter_boston(self):
        X_train, X_test, y_train, y_test, feature_names = create_boston_data()

        model_task = ModelTask.REGRESSION
        run_error_analyzer_on_models(X_train, y_train, X_test, y_test,
                                     feature_names, model_task)

        # Test with single feature instead of two features
        run_error_analyzer_on_models(X_train,
                                     y_train,
                                     X_test,
                                     y_test,
                                     feature_names,
                                     model_task,
                                     matrix_features=[feature_names[0]])

        # Note: Third feature has few unique values, tests code path
        # without binning data
        run_error_analyzer_on_models(X_train,
                                     y_train,
                                     X_test,
                                     y_test,
                                     feature_names,
                                     model_task,
                                     matrix_features=[feature_names[3]])
    def test_importances_boston(self):
        X_train, X_test, y_train, y_test, feature_names = \
            create_boston_data()
        models = create_models_regression(X_train, y_train)

        for model in models:
            categorical_features = []
            run_error_analyzer(model, X_test, y_test, feature_names,
                               categorical_features)
Пример #3
0
def boston():
    x_train, x_test, y_train, y_test, features = create_boston_data()
    yield {
        DatasetConstants.X_TRAIN: x_train,
        DatasetConstants.X_TEST: x_test,
        DatasetConstants.Y_TRAIN: y_train,
        DatasetConstants.Y_TEST: y_test,
        DatasetConstants.FEATURES: features
    }
    def test_modelanalysis_boston(self, manager_type):
        x_train, x_test, y_train, y_test, feature_names = \
            create_boston_data()
        x_train = pd.DataFrame(x_train, columns=feature_names)
        x_test = pd.DataFrame(x_test, columns=feature_names)
        models = create_models_regression(x_train, y_train)
        x_train[LABELS] = y_train
        x_test[LABELS] = y_test
        manager_args = {DESIRED_RANGE: [10, 20]}

        for model in models:
            run_model_analysis(model, x_train, x_test, LABELS, ['RM'],
                               manager_type, manager_args)
Пример #5
0
    def test_matrix_filter_boston_filters(self):
        X_train, X_test, y_train, y_test, feature_names = create_boston_data()

        filters = [{
            'arg': [0.675],
            'column': 'NOX',
            'method': 'less and equal'
        }, {
            'arg': [7.141000000000001],
            'column': 'RM',
            'method': 'greater'
        }]

        model_task = ModelTask.REGRESSION
        run_error_analyzer_on_models(X_train,
                                     y_train,
                                     X_test,
                                     y_test,
                                     feature_names,
                                     model_task,
                                     filters=filters)