import com.google.gson.Gson;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;


class {class_name} {{

    private class Classifier {{
        private int[] leftChilds;
        private int[] rightChilds;
        private double[] thresholds;
        private int[] indices;
        private int[][] classes;
    }}
    private Classifier clf;

    public {class_name}(String file) throws FileNotFoundException {{
        String jsonStr = new Scanner(new File(file)).useDelimiter("\\Z").next();
        this.clf = new Gson().fromJson(jsonStr, Classifier.class);
    }}

    public int {method_name}(double[] features, int node) {{
        if (this.clf.thresholds[node] != -2) {{
            if (features[this.clf.indices[node]] <= this.clf.thresholds[node]) {{
                return {method_name}(features, this.clf.leftChilds[node]);
            }} else {{
                return {method_name}(features, this.clf.rightChilds[node]);
            }}
        }}
        return findMax(this.clf.classes[node]);
    }}
    public int {method_name}(double[] features) {{
        return this.{method_name}(features, 0);
    }}

    private int findMax(int[] nums) {{
        int index = 0;
        for (int i = 0; i < nums.length; i++) {{
            index = nums[i] > nums[index] ? i : index;
        }}
        return index;
    }}

    public static void main(String[] args) throws FileNotFoundException {{
        if (args.length > 0 && args[0].endsWith(".json")) {{

            // Features:
            double[] features = new double[args.length-1];
            for (int i = 1, l = args.length; i < l; i++) {{
                features[i - 1] = Double.parseDouble(args[i]);
            }}

            // Parameters:
            String modelData = args[0];

            // Estimators:
            {class_name} clf = new {class_name}(modelData);

            // Prediction:
            int prediction = clf.{method_name}(features);
            System.out.println(prediction);

        }}
    }}
}}