% ttPredictor.m, the skeleton for the turn-taking prediction exercise
% Nigel Ward, University of Texas at El Paso, April 2015
% works on trainingData and testData, as stored in the file ttData.mat
% each of these matrices has one timepoint per row, with the following columns
% 0 or 1, depending on whether the agent took the turn
% the number of the audio input file
% the time in seconds into the audio input file
% remaining columns are values for the features listed in forPrediction.fss
function ttPredictor()
load ttData;
fprintf('\n==== for a regression-based predictor ====\n');
[npoints, width] = size(trainingData);
nfeatures = width - 1; % use them all (tho might also try using fewer)
model = trainModel(trainingData(:,1), trainingData(:,2:nfeatures+1));
[predictions, likelihoods] = applyModel(model, testData(:,2:nfeatures+1));
evaluatePredictions(predictions, testData(:,1));
fprintf(' prediction, likelihood, actual ...\n');
fprintf(' ... file, time, attr1, attr2, attr3 ...\n');
for i=1:10
fprintf(' %d, %.2f, %d file %d @ %5.2fs: %5.2f %5.2f %5.2f\n', ...
predictions(i), likelihoods(i), testData(i,1), ...
testData(i,2), testData(i,3), ...
testData(i,4), testData(i,5), testData(i,6));
end
fprintf('\n==== for a random predictor ====\n');
randomPredictions = randi(2,length(testData),1)-1;
evaluatePredictions(randomPredictions, testData(:,1));
fprintf('\n==== for predictions based on pitch lowness ====\n');
% the 20th feature is low pitch, sometimes signalling turn yield
phPredictions = testData(:, 20+1) >.1;
evaluatePredictions(phPredictions, testData(:,1));
end
function model = trainModel(trainingOutcomes, trainingFeatureValues)
weights = regress(trainingOutcomes, trainingFeatureValues);
model = weights;
% display weights to see which features are most influential
fprintf('Regression-model weights are: \n');
disp(weights');
end
function [predictions, likelihoods] = applyModel(weights, testsetFeatureValues)
likelihoods = testsetFeatureValues * weights;
predictions = likelihoods > 0.20; % this threshold is pretty arbitrary
end