Ejemplo n.º 1
0
        private void Categorize(string prefix, double thresh, SparseVector <double> vec, ArrayList <string> categories)
        {
            if (!mModel.ContainsKey(prefix))
            {
                categories.Add(prefix);
                return;
            }
            IModel <string>     classifier = mModel[prefix];
            Prediction <string> p          = ((IModel <string>)classifier).Predict(ModelUtils.ConvertExample(vec, classifier.RequiredExampleType));
            double maxSim = p.Count == 0 ? 0 : p.BestScore;

            foreach (KeyDat <double, string> item in p)
            {
                if (item.Key == 0)
                {
                    break;
                }
                double score = item.Key / maxSim;
                if (score < thresh)
                {
                    break;
                }
                Categorize(prefix + item.Dat + '/', thresh, vec, categories);
            }
        }
Ejemplo n.º 2
0
 public override Prediction <LblT> Predict(SparseVector <double> example)
 {
     return(mModel.Predict((BinaryVector)ModelUtils.ConvertExample(example, typeof(BinaryVector))));
 }