Exemplo n.º 1
0
 public ClassifierAccuracyAnalysis(IEventSeriesProbabalisticClassifier <Ty> classifier, string classifierName, DiscreteSeriesDatabase <Ty> labeledData, string criterionByWhichToClassify, double trainSplitFrac, int iterations, double bucketSize)
 {
     this.classifier                 = classifier;
     this.classifierName             = classifierName;
     this.labeledData                = labeledData;
     this.criterionByWhichToClassify = criterionByWhichToClassify;
     this.trainSplitFrac             = trainSplitFrac;
     this.iterations                 = iterations;
     this.bucketSize                 = bucketSize;
 }
Exemplo n.º 2
0
 public static string GetAlgorithmName <Ty>(this IEventSeriesProbabalisticClassifier <Ty> model)
 {
     return(GetAlgorithmName((object)model));
 }
Exemplo n.º 3
0
        //Name, true class, predicted class, scores, winning score;
        public static Tuple <string, string, string, double[], double> classificationInfo(IEventSeriesProbabalisticClassifier <Ty> classifier, string[] classifierSchema, Dictionary <string, int> trueSchemaMapping, DiscreteEventSeries <Ty> data, string nameCriterion, string criterionByWhichToClassify)
        {
            //scores in the synthesizer scorespace
            double[] synthScores = classifier.Classify(data);

            int maxIndex = synthScores.MaxIndex();

            /*
             * classifierSchema = classifier.GetClasses();
             * if (maxIndex >= classifierSchema.Length) {
             *      Console.WriteLine ("Schema not long enough.  synthlen, max, schema = " + synthScores.Length + ", " + maxIndex + ", " + classifierSchema.Length);
             *      Console.WriteLine ("Classifier Info:");
             *      Console.WriteLine (classifier.ToString ());
             *      Console.WriteLine ("Synth Features:");
             *      Console.WriteLine (((SeriesFeatureSynthesizerToVectorProbabalisticClassifierEventSeriesProbabalisticClassifier<string>)classifier).synthesizer.GetFeatureSchema().FoldToString ());
             *      Console.WriteLine ("Classifier Features:");
             *      Console.WriteLine (((SeriesFeatureSynthesizerToVectorProbabalisticClassifierEventSeriesProbabalisticClassifier<string>)classifier).classifier.GetClasses().FoldToString ());
             *      return null;
             * }
             */

            string predictedClass = classifierSchema[maxIndex];
            double maxScore       = synthScores[maxIndex];

            //convert scores to the true space.
            double[] trueScores = new double[trueSchemaMapping.Count];
            for (int j = 0; j < classifierSchema.Length; j++)
            {
                trueScores[trueSchemaMapping[classifierSchema[j]]] = synthScores[j];
            }

            return(new Tuple <string, string, string, double[], double> (data.labels[nameCriterion], data.labels[criterionByWhichToClassify], predictedClass, trueScores, maxScore));
        }