Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SW-2573] Fix interactionConstraints on H2OXGBoostMOJOModel in Python #2554

Merged
merged 1 commit into from Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -78,6 +78,7 @@ object MOJOModelTemplate
}

private def generateValueConversion(parameter: Parameter): String = parameter.dataType match {
case x if x.isArray && x.getComponentType.isArray() => "H2OTypeConverters.scala2DArrayToPython2DArray(value)"
case x if x.isArray => "H2OTypeConverters.scalaArrayToPythonArray(value)"
case _ => "value"
}
Expand Down
Expand Up @@ -501,6 +501,15 @@ def scalaArrayToPythonArray(array):
else:
raise TypeError("Invalid type.")

@staticmethod
def scala2DArrayToPython2DArray(array):
if array is None:
return None
elif isinstance(array, JavaObject):
return [H2OTypeConverters.scalaArrayToPythonArray(v) for v in array]
else:
raise TypeError("Invalid type.")

@staticmethod
def scalaToPythonDataFrame(jdf):
if jdf is None:
Expand Down
Expand Up @@ -39,7 +39,7 @@ def testXGBoostParameters(prostateDataset):
monotoneConstraints={'AGE': 1, 'RACE': -1},
interactionConstraints=[['AGE', 'RACE', 'DPROS'], ['DCAPS', 'PSA']])
model = algorithm.fit(prostateDataset)
ignored=["getInteractionConstraints", "getMonotoneConstraints"] # Will be fixed by SW-2573 and SW-2572
ignored=["getMonotoneConstraints"] # Will be fixed by SW-2572
compareParameterValues(algorithm, model, ignored)


Expand Down