private void btn_CreateSystem_Click(object sender, RoutedEventArgs e) { var conf = getConfiguration(); var gestureSetName = cmb_gestureSet.Text; var nSubsets = int.Parse(tb_nSubsets.Text); var subsetIndex = int.Parse(tb_SubsetIndex.Text); var shuffle = cb_shuffled.IsChecked.Value; currentSystem = createTrainedRecognitionSystem(conf, gestureSetName, nSubsets, subsetIndex, shuffle); fillGestureList(); }
public CHnMMRecognitionSystem createTrainedRecognitionSystem(Configuration conf, string gestureSetName, int nSubsets, int subsetIndex, bool shuffle) { var system = new CHnMMRecognitionSystem(conf); var gesturesData = getSetGestureTraces(gestureSetName); gesturesData.createSubsets(nSubsets, shuffle); gesturesData.trainRecognitionSystem(system, subsetIndex); return(system); }
public void execute() { var results = new LinkedList <GestureRecognitionResults.CrossValidationResult>(); foreach (var config in configs) { var chnmmRec = new CHnMMRecognitionSystem(config); var subsetResults = RecognitionExperiment.DoRecognition(chnmmRec, trainingSubSets, testSubSets); results.AddLast(new GestureRecognitionResults.CrossValidationResult(config, subsetResults.ToArray(), -1)); } var txt = (crossValidate) ? $"{nTrainingOrSubsets}subsets" : $"{nTrainingOrSubsets}trainingtraces"; string fileName = $"GestureRecognition_CHnMM_{dataSourceName}_{txt}.csv"; GestureRecognitionResults.saveResultsToFile("..\\..\\ExperimentResults\\" + fileName, results.ToArray()); }
public void execute() { var results = new LinkedList <VerificationResults.BasicResult>(); foreach (var config in configs) { var chnmmRec = new CHnMMRecognitionSystem(config); var res = VerificationExperiment.DoVerification(chnmmRec, trainingSet, genuineSet, forgerySet); results.AddLast(res); } var txtSession = session2 ? "2" : "1"; string fileName = $"Verification_CHnMM_{dataSourceName}_{nTraining}trainingTraces_Session{txtSession}_{DateTime.Now.ToFileTime()}.csv"; VerificationResults.saveResultsToFile("..\\..\\ExperimentResults\\" + fileName, configs, results); }
public void execute() { var results = new LinkedList <GestureRecognitionResults.CrossValidationResult>(); foreach (var config in configs) { var chnmmRec = new CHnMMRecognitionSystem(config); ISubsetCreator subsetCreator = crossValidate ? new CrossvalidationSubsetCreator(nTrainingOrSubsets) : (ISubsetCreator) new SimpleSplitSubsetCreator(nTrainingOrSubsets); var recognitionExperiment = new RecognitionExperiment(chnmmRec, subsetCreator, null, dataSourceName); results.AddLast(new GestureRecognitionResults.CrossValidationResult(config, recognitionExperiment.execute().ToArray(), -1)); } var txt = (crossValidate) ? $"{nTrainingOrSubsets}subsets" : $"{nTrainingOrSubsets}trainingtraces"; string fileName = $"GestureRecognition_CHnMM_{dataSourceName}_{txt}.csv"; GestureRecognitionResults.saveResultsToFile("..\\..\\ExperimentResults\\" + fileName, results.ToArray()); }
public static LinkedList <AuthenticationResultRow> validateAuthentication(CHnMMRecognitionSystem system, Dictionary <string, GestureTrace[]> dataSets, int nSubsets) { //if(nTrainSets + nTestSets != nSubsets) throw new ArgumentException("Anzahl der Train- und Testsets passt nicht zur angegebenen Anzahl an Subsets"); var results = new LinkedList <AuthenticationResultRow>(); foreach (var entry in dataSets) { var trueUser = entry.Key; var trueUserData = entry.Value; var subsets = createSubsets(trueUserData, nSubsets); //Leave one out cross validation: http://en.wikipedia.org/wiki/Cross-validation_%28statistics%29#Leave-one-out_cross-validation for (int curTestSetIndex = 0; curTestSetIndex < nSubsets; curTestSetIndex++) { var trainSet = subsets.Where((ss, i) => i != curTestSetIndex).SelectMany(ss => ss).ToArray(); var testSet = subsets[curTestSetIndex]; //use trainSet to train the model system.trainGesture(trueUser, trainSet.Select(gt => gt.LongestStroke).ToArray()); //true positives, false negatives, false positives and true negatives int TP = 0; int FN = 0; int FP = 0; int TN = 0; int wbfTU = 0; int wbtTU = 0; int wbfFU = 0; int wbtFU = 0; //calc estimated FRR foreach (var testTrace in testSet) { TrajectoryModel.ReasonForFail reason; if (!system.authenticateUser(trueUser, testTrace, out reason)) { FN++; } else { TP++; } if (reason == TrajectoryModel.ReasonForFail.MissedArea) { wbfTU++; } if (reason == TrajectoryModel.ReasonForFail.MissedTransition) { wbtTU++; } } //calc estimated FAR foreach (var falseData in dataSets) { var falseUser = falseData.Key; var falseUserData = falseData.Value; if (trueUser == falseUser) { continue; } TrajectoryModel.ReasonForFail reason = TrajectoryModel.ReasonForFail.UNDEFINED; foreach (var falseUserTrace in falseUserData) { if (!system.authenticateUser(trueUser, falseUserTrace, out reason)) { TN++; } else { FP++; } } if (reason == TrajectoryModel.ReasonForFail.MissedArea) { wbfFU++; } if (reason == TrajectoryModel.ReasonForFail.MissedTransition) { wbtFU++; } } //save result var result = new AuthenticationResultRow(); result.user = trueUser; result.run = curTestSetIndex; result.FN = FN; result.FP = FP; result.TP = TP; result.TN = TN; result.wrongByFormFalseUser = wbfFU; result.wrongByFormTrueUser = wbfTU; result.wrongByTimeFalseUser = wbtFU; result.wrongByTimeTrueUser = wbtTU; results.AddLast(result); } } return(results); }
public IEnumerable <GestureRecognitionResults.SingleResult> testRecognitionSystem(CHnMMRecognitionSystem system, int subsetIndex) { Stopwatch sw = new Stopwatch(); //e => GestureName, GestureTraces foreach (var gesture in data) { foreach (var trace in gesture.Value.getTestSet(subsetIndex)) { TrajectoryModel.ReasonForFail failReason; sw.Restart(); var recogGesture = system.recognizeGesture(gesture.Key, trace.LongestStroke, out failReason); var recogTime = sw.ElapsedMilliseconds; yield return(new GestureRecognitionResults.SingleResult(gesture.Key, recogGesture, (int)recogTime, trace.ID, failReason)); } } }