class_docstr: Test class for regression tests.
docstr: Test that non-negative regression works as expected.
docstr_tok: ["Test","that","non-negative","regression","works","as","expected","."]
code: def test_non_negative_regression(self):
      """Test that non-negative regression works as expected."""
      # read in the example training data into a featureset
      train_path = train_dir / "test_non_negative.jsonlines"
      train_fs = NDJReader.for_path(train_path).read()
  
      # train a regular SKLL linear regerssion learner first
      # and check that it gets some negative weights with this data
      skll_estimator1 = Learner("LinearRegression", min_feature_count=0)
      skll_estimator1.train(train_fs, grid_search=False)
      self.assertTrue(
          np.any(np.where(skll_estimator1.model.coef_ < 0, True, False))
      )
  
      # now train a non-negative linear regression learner and check
      # that _none_ of its weights are negative with the same data
      skll_estimator2 = Learner(
          "LinearRegression",
          model_kwargs={"positive": True},
          min_feature_count=0,
      )
      skll_estimator2.train(train_fs, grid_search=False)
      self.assertFalse(
          np.any(np.where(skll_estimator2.model.coef_ < 0, True, False))
      )
  
      # just for good measure, train a non-negative learner directly
      # in sklearn space and check that it has the same weights
      sklearn_estimator = LinearRegression(positive=True)
      X, y = train_fs.features.toarray(), train_fs.labels
      _ = sklearn_estimator.fit(X, y)
      assert_array_equal(
          skll_estimator2.model.coef_, sklearn_estimator.coef_
      )
  
imports: import math
  import re
  import unittest
  import warnings
  from itertools import chain, product
  import numpy
  from numpy.testing import assert_allclose, assert_array_equal
  from scipy.stats import pearsonr
  from sklearn.exceptions import ConvergenceWarning
  from sklearn.linear_model import LinearRegression, LogisticRegression
  from skll.config import _setup_config_parser
  from skll.data import FeatureSet, NDJReader, NDJWriter
  from skll.experiments import run_configuration
  from skll.learner import Learner
  from skll.learner.utils import rescaled
  from skll.utils.constants import CLASSIFICATION_ONLY_METRICS
  from skll.utils.testing import config_dir, fill_in_config_paths_for_fancy_output, make_regression_data, other_dir, output_dir, test_dir, train_dir, unlink
label_desc: Use image node_id 35 for calling the TestRegression obj's underlying member method code with example usage: obj.test_non_negative_regression() without return types