Skip to content

Support alternative DerivedField expressions #11

@nf78

Description

@nf78

When loading a PMML model with the following structure:

Regression > RegressionTable > NumericPredictor

I get the following error, when trying to import the model with:

clf = PMMLLinearRegression(pmml="filename.pmml")

Traceback (most recent call last):
  File "test.py", line 23, in <module>
    clf = PMMLLinearRegression(pmml="filename.pmml")
  File "C:\Users\<user>\AppData\Local\Programs\Python\Python36\sklearn_pmml_model\linear_model\implementations.py", line 27, in __init__
    super().__init__(pmml)
  File "C:\Users\<user>\AppData\Local\Programs\Python\Python36\sklearn_pmml_model\linear_model\base.py", line 32, in __init__
    for field in fields
  File "C:\Users\<user>\AppData\Local\Programs\Python\Python36\sklearn_pmml_model\linear_model\base.py", line 33, in <listcomp>
    if field.tag == 'DataField'
  File "C:\Users\<user>\AppData\Local\Programs\Python\Python36\sklearn_pmml_model\linear_model\base.py", line 25, in encoder_for
    encoder.categories_ = np.array([self.field_mapping[field.get('name')][1].categories])
  File "C:\Users\<user>\AppData\Local\Programs\Python\Python36\lib\site-packages\cached_property.py", line 35, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "C:\Users\<user>\AppData\Local\Programs\Python\Python36\sklearn_pmml_model\base.py", line 61, in field_mapping
    for name, e in fields.items()
  File "C:\Users\<user>\AppData\Local\Programs\Python\Python36\sklearn_pmml_model\base.py", line 62, in <dictcomp>
    if e.tag == 'DerivedField'
AttributeError: 'NoneType' object has no attribute 'get'

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions