class_docstr: Test class for custom learner tests.
class_docstr_tok: ["Test","class","for","custom","learner","tests","."]
code: def test_majority_class_custom_learner(self):
      num_labels = 10
  
      # This will make data where the last class happens about 50% of the time.
      class_weights = [
          (0.5 / (num_labels - 1)) for _ in range(num_labels - 1)
      ] + [0.5]
      train_fs, test_fs = make_classification_data(
          num_examples=600,
          train_test_ratio=0.8,
          num_labels=num_labels,
          num_features=5,
          non_negative=True,
          class_weights=class_weights,
      )
  
      # Write training feature set to a file
      train_path = (
          train_dir / "test_majority_class_custom_learner.jsonlines"
      )
      writer = NDJWriter(train_path, train_fs)
      writer.write()
  
      # Write test feature set to a file
      test_path = (
          test_dir / "test_majority_class_custom_learner.jsonlines"
      )
      writer = NDJWriter(test_path, test_fs)
      writer.write()
  
      cfgfile = "test_majority_class_custom_learner.template.cfg"
      config_template_path = config_dir / cfgfile
      config_path = fill_in_config_paths(config_template_path)
  
      run_configuration(config_path, quiet=True, local=True)
  
      outprefix = "test_majority_class_custom_learner"
  
      prediction_path = (
          output_dir
          / f"{outprefix}_{outprefix}_MajorityClassLearner_predictions.tsv"
      )
      preds = self.read_predictions(prediction_path)
  
      expected = np.array([float(num_labels - 1) for _ in preds])
      assert_array_equal(preds, expected)
  
file_path: skll/tests/test_custom_learner.py
imports: import csv
  import unittest
  from itertools import chain
  import numpy
  from numpy.testing import assert_array_equal
  from skll.data import NDJWriter
  from skll.experiments import run_configuration
  from skll.learner import Learner
  from skll.utils.testing import config_dir, fill_in_config_paths, make_classification_data, other_dir, output_dir, test_dir, train_dir, unlink
label_desc: Use image node_id 4 for calling the TestCustomLearner obj's underlying member method code with example usage: obj.test_majority_class_custom_learner() without return types