def fromString(cls, s): """Load a model from PMML in a string""" pc = PMMLContext.getOrCreate() try: java_model = pc._jvm.org.pmml4s.model.Model.fromString(s) return cls(java_model) except Py4JJavaError as e: je = e.java_exception raise PmmlError(je.getClass().getSimpleName(), je.getMessage())
def fromBytes(cls, bytes_array): """Load a model from PMML in an array of bytes""" pc = PMMLContext.getOrCreate() try: java_model = pc._jvm.org.pmml4s.model.Model.fromBytes(bytes_array) return cls(java_model) except Py4JJavaError as e: je = e.java_exception raise PmmlError(je.getClass().getSimpleName(), je.getMessage())
def fromFile(cls, name): """Load a model from PMML file with given pathname""" pc = PMMLContext.getOrCreate() try: java_model = pc._jvm.org.pmml4s.model.Model.fromFile(name) return cls(java_model) except Py4JJavaError as e: je = e.java_exception raise PmmlError(je.getClass().getSimpleName(), je.getMessage())
def close(cls): """Shutdown the gateway of Py4J""" PMMLContext.shutdown()