This is an automated email from the ASF dual-hosted git repository. mboehm7 pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/systemds.git
The following commit(s) were added to refs/heads/main by this push: new 976d4bd104 [SYSTEMDS-3538] New builtin function for false discovery rates (FDR) 976d4bd104 is described below commit 976d4bd104c10ed9c6a616bc723f81deb4fa416b Author: Matthias Boehm <mboe...@gmail.com> AuthorDate: Fri May 3 20:10:05 2024 +0200 [SYSTEMDS-3538] New builtin function for false discovery rates (FDR) --- scripts/builtin/fdr.dml | 42 ++++++++++++++++++++++ .../java/org/apache/sysds/common/Builtins.java | 1 + 2 files changed, 43 insertions(+) diff --git a/scripts/builtin/fdr.dml b/scripts/builtin/fdr.dml new file mode 100644 index 0000000000..8d1420a085 --- /dev/null +++ b/scripts/builtin/fdr.dml @@ -0,0 +1,42 @@ +#------------------------------------------------------------- +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +#------------------------------------------------------------- + +# This built-in function computes the false discovery rate +# for all classes as false-predictions / all-predictions. +# +# INPUT: +# ------------------------------------------------------------------------------ +# P vector of predictions (1-based, recoded), shape: [N x 1] +# Y vector of actual labels (1-based, recoded), shape: [N x 1] +# ------------------------------------------------------------------------------ +# +# OUTPUT: +# ------------------------------------------------------------------------------ +# FDR vector of false discovery rate per class, shape: [M x 1] +# ------------------------------------------------------------------------------ + +m_fdr = function(Matrix[Double] P, Matrix[Double] Y) + return (Matrix[Double] FDR) +{ + [cS, cA] = confusionMatrix(P, Y); + FDR = (rowSums(cS)-diag(cS)) / rowSums(cS); +} + diff --git a/src/main/java/org/apache/sysds/common/Builtins.java b/src/main/java/org/apache/sysds/common/Builtins.java index 61faccc0bc..5c334f72ae 100644 --- a/src/main/java/org/apache/sysds/common/Builtins.java +++ b/src/main/java/org/apache/sysds/common/Builtins.java @@ -131,6 +131,7 @@ public enum Builtins { EVAL("eval", false), EVALLIST("evalList", false), F1SCORE("f1Score", true), + FDR("fdr", "FDR", true), FIT_PIPELINE("fit_pipeline", true), FIX_INVALID_LENGTHS("fixInvalidLengths", true), FIX_INVALID_LENGTHS_APPLY("fixInvalidLengthsApply", true),