@Override
    @NotNull
    public Classifier makeObject() throws WekaClassifierException {
        logger.debug("Creating classifier");

        File file = new File(modelDescriptor.getModelFilePath());

        checkArgument(file.exists(), "Source file '"+ file.getAbsolutePath() + "' must exist");

        long time = System.currentTimeMillis();

        switch (modelDescriptor.getFormat()) {
            case BINARY:
                try (FileInputStream fileInputStream = new FileInputStream(file);
                     BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream, 1024 * 1024);
                     ObjectInputStream objectInputStream = new ObjectInputStream(bufferedInputStream)) {
                    Classifier classifier = (Classifier) objectInputStream.readObject();
                    logger.debug("Loaded binary model {} in {} ms.", file.getPath(), (System.currentTimeMillis() - time));
                    return classifier;
                } catch (IOException | ClassNotFoundException e) {
                    throw new WekaClassifierException(e);
                }
            case PMML:
                try {
                    Classifier classifier = PMMLConsumers.consume(file);
                    logger.debug("Loaded PMML model {} in {} ms.", file.getPath(), (System.currentTimeMillis() - time));
                    return classifier;
                } catch (FOSException e) {
                    throw new WekaClassifierException("Failed to consume PMML file " + file.getAbsolutePath() + ".", e);
                }
            default:
                throw new WekaClassifierException("Unknown model type " + modelDescriptor.getFormat());
        }
    }
@Override
    @NotNull
    public Classifier makeObject() throws WekaClassifierException {
        logger.debug("Creating classifier");

        File file = new File(modelDescriptor.getModelFilePath());

        checkArgument(file.exists(), "Source file '"+ file.getAbsolutePath() + "' must exist");

        long time = System.currentTimeMillis();

        switch (modelDescriptor.getFormat()) {
            case BINARY:
                try (FileInputStream fileInputStream = new FileInputStream(file);
                     BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream, 1024 * 1024);
                     ObjectInputStream objectInputStream = new ObjectInputStream(bufferedInputStream)) {
                    Classifier classifier = (Classifier) objectInputStream.readObject();
                    logger.debug("Loaded binary model {} in {} ms.", file.getPath(), (System.currentTimeMillis() - time));
                    return classifier;
                } catch (IOException | ClassNotFoundException e) {
                    throw new WekaClassifierException(e);
                }
            case PMML:
                try {
                    Classifier classifier = PMMLConsumers.consume(file);
                    logger.debug("Loaded PMML model {} in {} ms.", file.getPath(), (System.currentTimeMillis() - time));
                    return classifier;
                } catch (FOSException e) {
                    throw new WekaClassifierException("Failed to consume PMML file " + file.getAbsolutePath() + ".", e);
                }
            default:
                throw new WekaClassifierException("Unknown model type " + modelDescriptor.getFormat());
        }
    }
@ Override @ NotNull public Classifier makeObject ( ) throws WekaClassifierException { logger . debug ( "Creating classifier" ) ; File file = new File ( modelDescriptor . getModelFilePath ( ) ) ; checkArgument ( file . exists ( ) , "Source file '" + file . getAbsolutePath ( ) + "' must exist" ) ; long time = System . currentTimeMillis ( ) ; switch ( modelDescriptor . getFormat ( ) ) { case BINARY : try ( FileInputStream fileInputStream = new FileInputStream ( file ) ; BufferedInputStream bufferedInputStream = new BufferedInputStream ( fileInputStream , 1024 * 1024 ) ; ObjectInputStream objectInputStream = new ObjectInputStream ( bufferedInputStream ) ) { Classifier classifier = ( Classifier ) objectInputStream . readObject ( ) ; logger . debug ( "Loaded binary model {} in {} ms." , file . getPath ( ) , ( System . currentTimeMillis ( ) - time ) ) ; return classifier ; } catch ( IOException | ClassNotFoundException e ) { throw new WekaClassifierException ( e ) ; } case PMML : try { Classifier classifier = PMMLConsumers . consume ( file ) ; logger . debug ( "Loaded PMML model {} in {} ms." , file . getPath ( ) , ( System . currentTimeMillis ( ) - time ) ) ; return classifier ; } catch ( FOSException e ) { throw new WekaClassifierException ( "Failed to consume PMML file " + file . getAbsolutePath ( ) + "." , e ) ; } default : throw new WekaClassifierException ( "Unknown model type " + modelDescriptor . getFormat ( ) ) ; } }
Make on object of the factory type.
<p>
Reads the {@link Classifier} from file.

@return a new classifier instance
@throws WekaClassifierException when the object could not be read from file.
Make on object of the factory type . <p > Reads the { @link Classifier } from file .