class_docstr: Test class for second set of voting learner API tests.
class_docstr_tok: ["Test","class","for","second","set","of","voting","learner","API","tests","."]
code: def check_learning_curve(self, learner_type, with_soft_voting):
      # to test the learning_curve() method, we instantiate the SKLL voting
      # learner, get the SKLL learning curve output; then we do the
      # same in scikit-learn space and compare the outputs
  
      # instantiate some needed variables
      cv_folds = 10
      random_state = 123456789
      cv = ShuffleSplit(
          n_splits=cv_folds, test_size=0.2, random_state=random_state
      )
      train_sizes = np.linspace(0.1, 1.0, 5)
  
      # set various parameters based on whether we are using
      # a classifier or a regressor
      if learner_type == "classifier":
          learner_names = ["LogisticRegression", "SVC", "MultinomialNB"]
          voting_type = "soft" if with_soft_voting else "hard"
          featureset = FS_DIGITS
          scoring_function = "accuracy"
      else:
          learner_names = ["LinearRegression", "SVR", "Ridge"]
          voting_type = "hard"
          featureset = FS_HOUSING
          scoring_function = "neg_mean_squared_error"
  
      skll_vl = VotingLearner(
          learner_names,
          feature_scaling="none",
          min_feature_count=0,
          voting=voting_type,
      )
      (
          train_scores1,
          test_scores1,
          _,
          train_sizes1,
      ) = skll_vl.learning_curve(
          featureset,
          cv_folds=cv_folds,
          train_sizes=train_sizes,
          metric=scoring_function,
      )
  
      # now instantiate the scikit-learn version with the exact
      # same classifiers;
      # NOTE: here we need to do a bit of hackery
      # to get the same underlying scikit-learn estimators that
      # SKLL would have used since `learning_curve()` doesn't
      # save the underlying estimators like `train()` does
      learner_kwargs = {"probability": True} if with_soft_voting else {}
      learner1 = Learner(learner_names[0], **learner_kwargs)
      learner2 = Learner(learner_names[1], **learner_kwargs)
      learner3 = Learner(learner_names[2], **learner_kwargs)
      learner1.train(featureset[:100], grid_search=False)
      learner2.train(featureset[:100], grid_search=False)
      learner3.train(featureset[:100], grid_search=False)
      clf1, clf2, clf3 = learner1.model, learner2.model, learner3.model
      sklearn_model_type = (
          VotingClassifier
          if learner_type == "classifier"
          else VotingRegressor
      )
      sklearn_model_kwargs = {
          "estimators": [
              (learner_names[0], clf1),
              (learner_names[1], clf2),
              (learner_names[2], clf3),
          ]
      }
      if learner_type == "classifier":
          sklearn_model_kwargs["voting"] = voting_type
      sklearn_vl = sklearn_model_type(**sklearn_model_kwargs)
  
      # now call `learning_curve()` directly from scikit-learn
      # and get its output
      (train_sizes2, train_scores2, test_scores2) = learning_curve(
          sklearn_vl,
          featureset.features,
          featureset.labels,
          cv=cv,
          train_sizes=train_sizes,
          scoring=scoring_function,
      )
  
      # now check that SKLL and scikit-learn outputs match
      assert np.all(train_sizes1 == train_sizes2)
  
      # NOTE: because the digits dataset is quite easy and because
      # we are using SVC, numbers only match up to two significant digits;
      # for regression, we can match to a larger precision
      if learner_type == "classifier":
          assert np.allclose(train_scores1, train_scores2, rtol=1e-2)
          assert np.allclose(test_scores1, test_scores2, rtol=1e-2)
      else:
          assert np.allclose(train_scores1, train_scores2)
          assert np.allclose(test_scores1, test_scores2)
  
imports: import re
  import unittest
  from itertools import product
  import numpy
  from numpy.testing import assert_raises_regex
  from scipy.stats import pearsonr
  from sklearn.ensemble import VotingClassifier, VotingRegressor
  from sklearn.metrics import accuracy_score, f1_score, mean_squared_error
  from sklearn.model_selection import ShuffleSplit, learning_curve
  from sklearn.pipeline import Pipeline
  from skll.learner import Learner
  from skll.learner.voting import VotingLearner
  from skll.utils.logging import close_and_remove_logger_handlers, get_skll_logger
  from skll.utils.testing import make_california_housing_data, make_digits_data, other_dir, output_dir
label_desc: Use image node_id 5 for calling the TestVotingLearnersAPITwo obj's underlying member method code with example usage: obj.check_learning_curve(learner_type, with_soft_voting) without return types