368.5.2. 모델 빌드

모델을 작성할 때 사용할 분류 알고리즘을 선택한 다음 일부 데이터로 교육합니다. 그 결과는 나중에 보이지 않는 데이터를 분류하는 데 사용할 수 있는 학습된 모델입니다.

여기서는 J48을 10개의 교차 유효성 확인으로 교육합니다.

try (CamelContext camelctx = new DefaultCamelContext()) {

    camelctx.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {

            // Use the file component to read the training data
            from("file:src/test/resources/data?fileName=sfny-train.arff")

            // Build a J48 classifier using cross-validation with 10 folds
            .to("weka:model?build=J48&xval=true&folds=10&seed=1")

            // Persist the J48 model
            .to("weka:model?saveTo=src/test/resources/data/sfny-j48.model")
        }
    });
    camelctx.start();
}