Beispiel #1
0
    def test_print_help_net(self, print_help, net, capsys):
        print_help(net)
        out = capsys.readouterr()[0]

        expected_snippets = [
            '-- --help', '<NeuralNetClassifier> options',
            '--module : torch module (class or instance)',
            '--batch_size : int (default=128)', '<MLPModule> options',
            '--module__hidden_units : int (default=10)'
        ]
        for snippet in expected_snippets:
            assert snippet in out
Beispiel #2
0
    def test_print_help_net_custom_defaults(self, print_help, net, capsys):
        defaults = {'batch_size': 256, 'module__hidden_units': 55}
        print_help(net, defaults)
        out = capsys.readouterr()[0]

        expected_snippets = [
            '-- --help', '<NeuralNetClassifier> options',
            '--module : torch module (class or instance)',
            '--batch_size : int (default=256)', '<MLPModule> options',
            '--module__hidden_units : int (default=55)'
        ]
        for snippet in expected_snippets:
            assert snippet in out
Beispiel #3
0
    def test_print_help_pipeline(self, print_help, pipe, capsys):
        print_help(pipe)
        out = capsys.readouterr()[0]

        expected_snippets = [
            '-- --help', '<MinMaxScaler> options',
            '--features__scale__feature_range',
            '<NeuralNetClassifier> options',
            '--net__module : torch module (class or instance)',
            '--net__batch_size : int (default=128)', '<MLPModule> options',
            '--net__module__hidden_units : int (default=10)'
        ]
        for snippet in expected_snippets:
            assert snippet in out
Beispiel #4
0
    def test_print_help_sklearn_estimator(self, print_help, clf_sklearn, capsys):
        # Should also work with non-skorch sklearn estimator;
        # need to assert that count==1 since there was a bug in my
        # first implementation that resulted in the help for the final
        # estimator appearing twice.
        print_help(clf_sklearn)
        out = capsys.readouterr()[0]

        expected_snippets = [
            '-- --help',
            '--fit_intercept',
            '--copy_X',
            '--normalize',
        ]
        for snippet in expected_snippets:
            assert snippet in out
            assert out.count(snippet) == 1
Beispiel #5
0
    def test_print_help_sklearn_pipeline(self, print_help, pipe_sklearn, capsys):
        # Should also work with non-skorch sklearn pipelines;
        # need to assert that count==1 since there was a bug in my
        # first implementation that resulted in the help for the final
        # estimator appearing twice.
        print_help(pipe_sklearn)
        out = capsys.readouterr()[0]

        expected_snippets = [
            '-- --help',
            '<MinMaxScaler> options',
            '--features__scale__feature_range',
            '--clf__fit_intercept',
            '--clf__normalize',
        ]
        for snippet in expected_snippets:
            assert snippet in out
            assert out.count(snippet) == 1