code: def test_linreg(self):
      trn, val, preproc = txt.texts_from_array(
          x_train=self.trn[0],
          y_train=self.trn[1],
          x_test=self.val[0],
          y_test=self.val[1],
          preprocess_mode="standard",
          ngram_range=3,
          maxlen=200,
          max_features=35000,
      )
      model = txt.text_regression_model(
          "linreg", train_data=trn, preproc=preproc
      )
      learner = ktrain.get_learner(
          model, train_data=trn, val_data=val, batch_size=256
      )
      lr = 0.01
      hist = learner.fit_onecycle(lr, 10)
  
      # test training results
      self.assertAlmostEqual(max(hist.history["lr"]), lr)
      self.assertLess(min(hist.history["val_mae"]), 12)
  
      # test top losses
      obs = learner.top_losses(n=1, val_data=None)
      self.assertIn(obs[0][0], list(range(len(val[0]))))
      learner.view_top_losses(preproc=preproc, n=1, val_data=None)
  
      # test weight decay
      self.assertEqual(learner.get_weight_decay(), None)
      learner.set_weight_decay(1e-2)
      self.assertAlmostEqual(learner.get_weight_decay(), 1e-2)
  
      # test load and save model
      learner.save_model("/tmp/test_model")
      learner.load_model("/tmp/test_model")
  
      # test predictor
      p = ktrain.get_predictor(learner.model, preproc)
      self.assertGreater(p.predict([TEST_DOC])[0], 100)
      p.save("/tmp/test_predictor")
      p = ktrain.load_predictor("/tmp/test_predictor")
      self.assertGreater(p.predict([TEST_DOC])[0], 100)
      self.assertIsNone(p.explain(TEST_DOC))
  
file_path: ktrain/tests/test_textregression.py
imports: from unittest import TestCase, main, skip
  import IPython
  import numpy
  import testenv
  import ktrain
  from ktrain import text
  from ktrain.imports import ACC_NAME, VAL_ACC_NAME
label_desc: Use image node_id 2 for calling the TestTextRegression obj's underlying member method code with example usage: obj.test_linreg() without return types