EXPERIMENT_FILE_PATH = join( KINECT_EXPERIMENT_DIR, OPTION_INFO['dir_name'], OPTION_INFO['file_name'] ) ## Open file and extract JSON frames data. FRAMES = normalize_scale(normalize_origin(load_skeleton_data(EXPERIMENT_FILE_PATH), 'HipCenter'), 'HipCenter', 'Head') ## Get the joint distances from the frame data. DISTANCES = map(generate_distances, FRAMES) ## Split the distance data. Use one half for ## training and the other half for testing. seed(OPTION_INFO['shuffle_seed']) shuffle(DISTANCES) TRAINING_DISTANCES, TESTING_DISTANCES = split_items(DISTANCES, 0.5) seed(OPTION_INFO['training_seed']) ## Train the weights. WEIGHTS, _ = KinectWeightsProblem(TRAINING_DISTANCES).anneal() ## Test the weights and display info on how well they work. SCORES = score_weights(TESTING_DISTANCES, WEIGHTS) print 'Good:\t%d' % SCORES['good'] print 'Bad:\t%d' % SCORES['bad'] print 'Error:\t%d' % SCORES['error'] print 'Score:\t%.4f%%' % (SCORES['accuracy'] * 100) print json.dumps(WEIGHTS)
score = self.fitness(skeleton) if frame['label'] == 1 and score < pivot_score: correct_count += 1 elif frame['label'] == 0 and score > pivot_score: correct_count += 1 elif frame['label'] == 1 and score > pivot_score: incorrect_count += 1 elif frame['label'] == 0 and score < pivot_score: incorrect_count += 1 total_count = correct_count + incorrect_count + 1 #TODO remove + 1 return float(correct_count) / total_count ## Split the distance data. Use one half for ## training and the other half for testing. random.seed(OPTION_INFO['shuffle_seed']) random.shuffle(FRAMES) TRAINING_FRAMES, TESTING_FRAMES = split_items(FRAMES, 0.5) random.seed(OPTION_INFO['training_seed']) ## Train the weights. WEIGHTS, _ = KinectWeightsProblem(TRAINING_FRAMES).anneal() ## Test the weights and display info on how well they work. SCORES = score_weights(TESTING_DISTANCES, WEIGHTS) print 'Good:\t%d' % SCORES['good'] print 'Bad:\t%d' % SCORES['bad'] print 'Error:\t%d' % SCORES['error'] print 'Score:\t%.4f%%' % (SCORES['accuracy'] * 100) print json.dumps(WEIGHTS)
for frame in self.frames: score = self.fitness(skeleton) if frame['label'] == 1 and score < pivot_score: correct_count += 1 elif frame['label'] == 0 and score > pivot_score: correct_count += 1 elif frame['label'] == 1 and score > pivot_score: incorrect_count += 1 elif frame['label'] == 0 and score < pivot_score: incorrect_count += 1 total_count = correct_count + incorrect_count + 1 #TODO remove + 1 return float(correct_count) / total_count ## Split the distance data. Use one half for ## training and the other half for testing. random.seed(OPTION_INFO['shuffle_seed']) random.shuffle(FRAMES) TRAINING_FRAMES, TESTING_FRAMES = split_items(FRAMES, 0.5) random.seed(OPTION_INFO['training_seed']) ## Train the weights. WEIGHTS, _ = KinectWeightsProblem(TRAINING_FRAMES).anneal() ## Test the weights and display info on how well they work. SCORES = score_weights(TESTING_DISTANCES, WEIGHTS) print 'Good:\t%d' % SCORES['good'] print 'Bad:\t%d' % SCORES['bad'] print 'Error:\t%d' % SCORES['error'] print 'Score:\t%.4f%%' % (SCORES['accuracy'] * 100) print json.dumps(WEIGHTS)