package main

import (
	"os"
	"fmt"
	"strconv"
)

type {class_name} struct {{
	lChilds []int
	rChilds []int
	thresholds []float64
	indices []int
	classes [][]int
}}

func (dtc {class_name}) {method_name}_(features []float64, node int) int {{
    if dtc.thresholds[node] != -2 {{
        if features[dtc.indices[node]] <= dtc.thresholds[node] {{
            return dtc.{method_name}_(features, dtc.lChilds[node])
        }} else {{
            return dtc.{method_name}_(features, dtc.rChilds[node])
        }}
    }}
    var index int = 0
	for i := 0; i < len(dtc.classes[node]); i++ {{
	    if dtc.classes[node][i] > dtc.classes[node][index] {{
	        index = i
	    }}
	}}
	return index
}}

func (dtc {class_name}) {method_name}(features []float64) int {{
    return dtc.{method_name}_(features, 0)
}}

func main() {{

	// Features:
	var features []float64
	for _, arg := range os.Args[1:] {{
		if n, err := strconv.ParseFloat(arg, 64); err == nil {{
			features = append(features, n)
		}}
	}}

    // Parameters:
    {left_childs}
    {right_childs}
    {thresholds}
    {indices}
    {classes}

	// Prediction:
	clf := {class_name}{{lChilds, rChilds, thresholds, indices, classes}}
	estimation := clf.{method_name}(features)
	fmt.Printf("%d\n", estimation)

}}