Пример #1
0
        public GestureModel(IEnumerable <ICollection <Touch> > userTraces)
        {
            models = new HiddenModel[activeFeatures.Length];
            var modelCreator = new SimpleMultiplePathsModelCreator();

            //calc features foreach trace

            foreach (var trace in userTraces)
            {
                featureTraces.Add(new TraceFeatures(trace));
            }

            int iModel = 0;

            foreach (var feature in activeFeatures)
            {
                var symbolTracesByFeature = new LinkedList <ICollection <Observation> >();
                var symbolGenerator       = new ExtremaSymbolGenerator(feature, true);
                foreach (var featureTrace in featureTraces)
                {
                    var symbolTraces = symbolGenerator.generateSymbolTrace(featureTrace);
                    symbolTracesByFeature.AddLast(symbolTraces);
                }

                models[iModel++] = modelCreator.createModel(symbolTracesByFeature);
            }
        }
Пример #2
0
        public double evaluate(ICollection <Touch> trace, bool endStateOnly = false)
        {
            var evals        = new double[activeFeatures.Length];
            var traceFeature = new TraceFeatures(trace);

            int iModel = 0;

            foreach (var feature in activeFeatures)
            {
                var symbolGenerator = new ExtremaSymbolGenerator(feature, true);
                evals[iModel] = models[iModel].evaluate(symbolGenerator.generateSymbolTrace(traceFeature), endStateOnly);
                iModel++;
            }

            if (evals.Any(e => e == 0 || double.IsNaN(e)))
            {
                return(0);
            }
            return(evals.Average());
        }