<commit_before>package main

import (
	"flag"
	"fmt"
	"github.com/ryanbressler/CloudForest"
	"log"
	"os"
)

func main() {
	fm := flag.String("fm",
		"featurematrix.afm", "AFM formated feature matrix containing test data.")
	rf := flag.String("rfpred",
		"rface.sf", "A predictor forest.")

	flag.Parse()

	datafile, err := os.Open(*fm) // For read access.
	if err != nil {
		log.Fatal(err)
	}
	defer datafile.Close()
	data := CloudForest.ParseAFM(datafile)

	forestfile, err := os.Open(*rf) // For read access.
	if err != nil {
		log.Fatal(err)
	}
	defer forestfile.Close()
	forestreader := CloudForest.NewForestReader(forestfile)
	forest, err := forestreader.ReadForest()
	if err != nil {
		log.Fatal(err)
	}

	target := &data.Data[data.Map[forest.Target]]
	var bb CloudForest.VoteTallyer
	switch target.Numerical {
	case true:
		bb = CloudForest.NewNumBallotBox(len(data.Data[0].Missing))
	case false:
		bb = CloudForest.NewCatBallotBox(len(data.Data[0].Missing))

	}

	for _, tree := range forest.Trees {
		tree.Vote(data, bb)
	}
	er := bb.TallyError(target)
	fmt.Printf("%v\n", er)

}<commit_msg>Move of feature to an interface complete, need to update errorrate, applyforest and leafcount<commit_after>package main

import (
	"flag"
	"fmt"
	"github.com/ryanbressler/CloudForest"
	"log"
	"os"
)

func main() {
	fm := flag.String("fm",
		"featurematrix.afm", "AFM formated feature matrix containing test data.")
	rf := flag.String("rfpred",
		"rface.sf", "A predictor forest.")

	flag.Parse()

	datafile, err := os.Open(*fm) // For read access.
	if err != nil {
		log.Fatal(err)
	}
	defer datafile.Close()
	data := CloudForest.ParseAFM(datafile)

	forestfile, err := os.Open(*rf) // For read access.
	if err != nil {
		log.Fatal(err)
	}
	defer forestfile.Close()
	forestreader := CloudForest.NewForestReader(forestfile)
	forest, err := forestreader.ReadForest()
	if err != nil {
		log.Fatal(err)
	}

	target := data.Data[data.Map[forest.Target]]
	var bb CloudForest.VoteTallyer
	if target.NCats() == 0 {
		bb = CloudForest.NewNumBallotBox(data.Data[0].Length())
	} else {
		bb = CloudForest.NewCatBallotBox(data.Data[0].Length())

	}

	for _, tree := range forest.Trees {
		tree.Vote(data, bb)
	}
	er := bb.TallyError(target)
	fmt.Printf("%v\n", er)

}
{'fraction_non_alphanumeric': 0.15920177383592019, 'fraction_numerical': 0.0022172949002217295, 'mean_word_length': 4.058295964125561, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1512654', 'n_tokens_mistral': 917, 'n_tokens_neox': 854, 'n_words': 185}