func createRandomForest(opts *options) (forest *rf.Runtime, e error) {
	config, e := ioutil.ReadFile(opts.trainCfg)
	if e != nil {
		return nil, e
	}
	forest = &rf.Runtime{}
	e = json.Unmarshal(config, &forest)
	if e != nil {
		return nil, e
	}
	if opts.nTree > 0 {
		forest.NTree = opts.nTree
	}
	if opts.nRandomFeature > 0 {
		forest.NRandomFeature = opts.nRandomFeature
	}
	if opts.percentBoot > 0 {
		forest.PercentBoot = opts.percentBoot
	}
	if opts.oobStatsFile != "" {
		forest.OOBStatsFile = opts.oobStatsFile
	}
	if opts.perfFile != "" {
		forest.PerfFile = opts.perfFile
	}
	return forest, nil
}
createRandomForest will create random forest for training, with the
following steps,
(1) load training configuration.
(2) Overwrite configuration parameter if its set from command line.
package main
import (
	"encoding/json"
	"flag"
	"fmt"
	"io/ioutil"
	"os"
	"time"
	"github.com/shuLhan/share/lib/dsv"
	"github.com/shuLhan/share/lib/mining/classifier/rf"
	"github.com/shuLhan/share/lib/tabula"
)
const (
	tag = "[rf]"
)
type options struct {
	nTree int
	nRandomFeature int
	percentBoot int
	oobStatsFile string
	perfFile string
	trainCfg string
	testCfg string
}
func usage() {
	flag.PrintDefaults()
}
func initFlags() (opts options) {
	flagUsage := []string{
		"Number of tree in forest (default 100)",
		"Number of feature to compute (default 0)",
		"Percentage of bootstrap (default 64%)",
		"OOB statistic file, where OOB data will be written",
		"Performance file, where statistic of classifying data set will be written",
		"Training configuration",
		"Test configuration",
	}
	flag.IntVar(&opts.nTree, "ntree", -1, flagUsage[0])
	flag.IntVar(&opts.nRandomFeature, "nrandomfeature", -1, flagUsage[1])
	flag.IntVar(&opts.percentBoot, "percentboot", -1, flagUsage[2])
	flag.StringVar(&opts.oobStatsFile, "oobstatsfile", "", flagUsage[3])
	flag.StringVar(&opts.perfFile, "perffile", "", flagUsage[4])
	flag.StringVar(&opts.trainCfg, "train", "", flagUsage[5])
	flag.StringVar(&opts.testCfg, "test", "", flagUsage[6])
	flag.Parse()
	return opts
}
func trace() (start time.Time) {
	start = time.Now()
	fmt.Println(tag, "start", start)
	return
}
func un(startTime time.Time) {
	endTime := time.Now()
	fmt.Println(tag, "elapsed time", endTime.Sub(startTime))
}