public static void produce(Classifier classifier, File file, boolean compress) throws PMMLConversionException {
    """
	Converts the given {@link weka.classifiers.Classifier} to PMML and saves it to the given file.
	
	@param classifier The {@link weka.classifiers.Classifier} to convert to PMML.
	@param file       The file to save the PMML.
	@param compress   {@code true} to save the classifier GZipped, or {@code false} otherwise.
	@throws com.feedzai.fos.impl.weka.exception.PMMLConversionException If if fails to convert to PMML.
    """
        Algorithm algorithm = Algorithm.fromClassifier(classifier);

        PMML pmml = algorithm.getPMMLProducer().produce(classifier);
        addAlgorithm(pmml, algorithm);

        try {
            if (compress) {
                String finalPath = file.getAbsolutePath();

                logger.debug("Saving compressed file to '{}'.", finalPath);

                try (FileOutputStream fileOutputStream = new FileOutputStream(finalPath);
                     GZIPOutputStream gzipOutputStream = new GZIPOutputStream(fileOutputStream);)
                {
                    JAXBUtil.marshalPMML(pmml, new StreamResult(gzipOutputStream));
                }
            } else {
                logger.debug("Saving file to '{}'.", file.getAbsolutePath());

                try (FileOutputStream fos = new FileOutputStream(file)) {
                    JAXBUtil.marshalPMML(pmml, new StreamResult(file));
                }
            }

            logger.debug("File successfully saved.");
        } catch (Exception e) {
            logger.error("Failed to marshal the PMML to file.", e);
            throw new PMMLConversionException("Failed to marshal the PMML to file.", e);
        }
    }
public static void produce(Classifier classifier, File file, boolean compress) throws PMMLConversionException {
        Algorithm algorithm = Algorithm.fromClassifier(classifier);

        PMML pmml = algorithm.getPMMLProducer().produce(classifier);
        addAlgorithm(pmml, algorithm);

        try {
            if (compress) {
                String finalPath = file.getAbsolutePath();

                logger.debug("Saving compressed file to '{}'.", finalPath);

                try (FileOutputStream fileOutputStream = new FileOutputStream(finalPath);
                     GZIPOutputStream gzipOutputStream = new GZIPOutputStream(fileOutputStream);)
                {
                    JAXBUtil.marshalPMML(pmml, new StreamResult(gzipOutputStream));
                }
            } else {
                logger.debug("Saving file to '{}'.", file.getAbsolutePath());

                try (FileOutputStream fos = new FileOutputStream(file)) {
                    JAXBUtil.marshalPMML(pmml, new StreamResult(file));
                }
            }

            logger.debug("File successfully saved.");
        } catch (Exception e) {
            logger.error("Failed to marshal the PMML to file.", e);
            throw new PMMLConversionException("Failed to marshal the PMML to file.", e);
        }
    }
public static void produce ( Classifier classifier , File file , boolean compress ) throws PMMLConversionException { Algorithm algorithm = Algorithm . fromClassifier ( classifier ) ; PMML pmml = algorithm . getPMMLProducer ( ) . produce ( classifier ) ; addAlgorithm ( pmml , algorithm ) ; try { if ( compress ) { String finalPath = file . getAbsolutePath ( ) ; logger . debug ( "Saving compressed file to '{}'." , finalPath ) ; try ( FileOutputStream fileOutputStream = new FileOutputStream ( finalPath ) ; GZIPOutputStream gzipOutputStream = new GZIPOutputStream ( fileOutputStream ) ; ) { JAXBUtil . marshalPMML ( pmml , new StreamResult ( gzipOutputStream ) ) ; } } else { logger . debug ( "Saving file to '{}'." , file . getAbsolutePath ( ) ) ; try ( FileOutputStream fos = new FileOutputStream ( file ) ) { JAXBUtil . marshalPMML ( pmml , new StreamResult ( file ) ) ; } } logger . debug ( "File successfully saved." ) ; } catch ( Exception e ) { logger . error ( "Failed to marshal the PMML to file." , e ) ; throw new PMMLConversionException ( "Failed to marshal the PMML to file." , e ) ; } }
Converts the given {@link weka.classifiers.Classifier} to PMML and saves it to the given file.

@param classifier The {@link weka.classifiers.Classifier} to convert to PMML.
@param file       The file to save the PMML.
@param compress   {@code true} to save the classifier GZipped, or {@code false} otherwise.
@throws com.feedzai.fos.impl.weka.exception.PMMLConversionException If if fails to convert to PMML.
Converts the given { @link weka . classifiers . Classifier } to PMML and saves it to the given file .