code: def test_LabelBinarizer2(self):
      arr = np.array(["X", "Y", "Z", "X"])
      s = pdml.ModelSeries(arr)
  
      lb = s.preprocessing.LabelBinarizer()
      s.fit(lb)
  
      binarized = s.transform(lb)
      self.assertIsInstance(binarized, pdml.ModelFrame)
  
      expected = pd.DataFrame(
          {0: [1, 0, 0, 1], 1: [0, 1, 0, 0], 2: [0, 0, 1, 0]}
      )
      tm.assert_frame_equal(binarized, expected)
  
      df = pdml.ModelFrame(datasets.load_iris())
      df.target.fit(lb)
      binarized = df.target.transform(lb)
  
      expected = pd.DataFrame(
          {
              0: [1] * 50 + [0] * 100,
              1: [0] * 50 + [1] * 50 + [0] * 50,
              2: [0] * 100 + [1] * 50,
          }
      )
      tm.assert_frame_equal(binarized, expected)
  
      df = pdml.ModelFrame(datasets.load_iris())
      df.target.fit(lb)
      df.target = df.target.transform(lb)
      self.assertEqual(df.shape, (150, 7))
      tm.assert_frame_equal(df.target, expected)
  
imports: import pytest
  import numpy
  import pandas
  import sklearn.datasets
  import sklearn.preprocessing
  import pandas_ml
  import pandas_ml.util.testing
label_desc: Use image node_id 18 for calling the TestPreprocessing obj's underlying member method code with example usage: obj.test_LabelBinarizer2() without return types