From d0cf71da4e5203600b01322062e56402cd2fa0d1 Mon Sep 17 00:00:00 2001 From: mufwan Date: Mon, 19 Feb 2024 18:32:21 +0100 Subject: [PATCH] accuracy for application --- scripts/keywordSpotting.dml | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/scripts/keywordSpotting.dml b/scripts/keywordSpotting.dml index 1f4bff40792..acea8539dc0 100644 --- a/scripts/keywordSpotting.dml +++ b/scripts/keywordSpotting.dml @@ -1,5 +1,4 @@ - X = read("tmp/waves.csv", format="csv") y = read("tmp/labels.csv", format="csv") @@ -11,42 +10,25 @@ Xy_shuffled = Xy_shuffled[,1:num_col] # Remove the random column X_shuffled = Xy_shuffled[,1:(num_col-1)] # Features, excluding the last column which is labels y_shuffled = Xy_shuffled[,num_col] # Labels, the last column - [X_train, X_test, y_train, y_test] = split(X=X_shuffled, Y=y_shuffled, seed= 13) -# Preprocess with fft Optionally move before split. [X_train_re, X_train_im] = stft(X_train, 4, 2) [X_test_re, X_test_im] = stft(X_test, 4, 2) - X_train_re_sq = X_train_re^2 X_train_im_sq = X_train_im^2 - X_test_re_sq = X_test_re^2 X_test_im_sq = X_test_im^2 - -# Sum the squared matrices sum_X_train_sq = X_train_re_sq + X_train_im_sq sum_X_test_sq = X_test_re_sq + X_test_im_sq -# Compute the square root of each element in the sum matrix to get the magnitudes magnitudes_train = sqrt(sum_X_train_sq) magnitudes_test = sqrt(sum_X_test_sq) bias = lm(X=magnitudes_train, y=y_train, reg=1e-1, maxi=10, verbose=TRUE) predictions = lmPredict(X=magnitudes_test, B=bias, verbose=FALSE) -#sign_predictions = sign(predictions) -#sign_Y = sign(y_test) - -#correct = sum(sign_predictions == sign_Y) -#total = nrow(y_test) -#accuracy = correct / total - -#print(toString(predictions)) -#print(toString(accuracy)) - -R = lmPredictStats(yhat=predictions, ytest=y_test, lm=TRUE) -print(toString(R)) +accuracy = auc(Y=y_test, P=predictions) +print(toString(accuracy))