Exemplo n.º 1
0
    def test_XGBoost(self):
        model=XGBClassifier()
        sk_model=iris_dataset(model)
        derived_col_names=['sepal_length','petal_length']
        col_names=['sepal_length','petal_length']
        target_name='species'
        mining_imp_value=()
        categoric_values=()

        self.assertEqual(
            len(xgb.get_segments_for_xgbc(sk_model,derived_col_names,col_names,target_name,mining_imp_value,categoric_values)),
            4)
        self.assertEqual(
            xgb.get_segments_for_xgbc(sk_model,derived_col_names,col_names,target_name,mining_imp_value,categoric_values)[
                3].get_id(),4)
        self.assertEqual(
            xgb.get_segments_for_xgbc(sk_model, derived_col_names, col_names, target_name, mining_imp_value,categoric_values)[
                3].get_RegressionModel().get_RegressionTable()[0].get_intercept(), '0.0')



        self.assertEqual(
            xgb.mining_Field_For_First_Segment(col_names).__class__.__name__,
            pml.MiningSchema().__class__.__name__)
        self.assertEqual(
            xgb.mining_Field_For_First_Segment(col_names).get_MiningField()[0].get_name(),
            'sepal_length')
        self.assertEqual(len(xgb.mining_Field_For_First_Segment(['a','b','d','e']).get_MiningField())
                         ,4)


        self.assertEqual(
            type(xgb.generate_Segments_Equal_To_Estimators([],derived_col_names,col_names)),
            type([]))


        self.assertEqual(
            xgb.add_segmentation(sk_model,[],[],pml.Output,1).__class__.__name__,
            pml.Segment().__class__.__name__)
        self.assertEqual(
            xgb.add_segmentation(sk_model,[],[],pml.Output,1).get_MiningModel().__class__.__name__,
            pml.MiningModel().__class__.__name__)
        self.assertEqual(xgb.add_segmentation(sk_model, [], [], pml.Output, 1).get_id(),
                         2)

        self.assertEqual(type(xgb.get_regrs_tabl(sk_model,col_names,'species',categoric_values)),type([]))
Exemplo n.º 2
0
    def test_LightGradientBoostingRegressor(self):
        model = LGBMRegressor()
        sk_model, feature_names, target_name = auto_dataset_for_regression(
            model)
        derived_col_names = feature_names
        mining_imp_value = ()
        categoric_values = ()

        self.assertEqual(
            lgbToPmml.get_segments_for_lgbr(
                sk_model, derived_col_names, feature_names, target_name,
                mining_imp_value, categoric_values).__class__.__name__,
            pml.Segmentation().__class__.__name__)

        self.assertEqual(
            len(
                lgbToPmml.get_segments_for_lgbr(
                    sk_model, derived_col_names, feature_names, target_name,
                    mining_imp_value, categoric_values).get_Segment()),
            model.n_estimators)

        self.assertEqual(
            lgbToPmml.get_ensemble_models(
                sk_model, derived_col_names, feature_names, target_name,
                mining_imp_value, categoric_values)[0].__class__.__name__,
            pml.MiningModel().__class__.__name__)

        self.assertEqual(
            lgbToPmml.get_ensemble_models(
                sk_model, derived_col_names, feature_names, target_name,
                mining_imp_value, categoric_values)[0].get_functionName(),
            'regression')

        self.assertEqual(
            len(
                lgbToPmml.get_ensemble_models(
                    sk_model, derived_col_names, feature_names, target_name,
                    mining_imp_value,
                    categoric_values)[0].get_MiningSchema().get_MiningField()),
            model.n_features_ + 1)