Exemple #1
0
 def testSingleCategoricalProcessorPandasSingleDF(self):
     if HAS_PANDAS:
         cat_processor = categorical.CategoricalProcessor()
         data = pd.DataFrame({"Gender": ["Male", "Female", "Male"]})
         X = list(cat_processor.fit_transform(data))
         self.assertAllEqual(list(X), [[1], [2], [1]])
Exemple #2
0
 def testMultiCategoricalProcessor(self):
     cat_processor = categorical.CategoricalProcessor(min_frequency=0,
                                                      share=False)
     x = cat_processor.fit_transform([["0", "Male"], [1, "Female"],
                                      ["3", "Male"]])
     self.assertAllEqual(list(x), [[1, 1], [2, 2], [3, 1]])
Exemple #3
0
 def testSingleCategoricalProcessor(self):
     cat_processor = categorical.CategoricalProcessor(min_frequency=1)
     X = cat_processor.fit_transform([["0"], [1], [float('nan')], ["C"],
                                      ["C"], [1], ["0"], [np.nan], [3]])
     self.assertAllEqual(list(X),
                         [[2], [1], [0], [3], [3], [1], [2], [0], [0]])