Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature #2887 categorical weights PR 1 of 2 #2967

Merged
merged 16 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
09f802e
Per #2887, update NumArray::vals() to return a reference to the vecto…
JohnHalleyGotway Aug 28, 2024
38a5d4e
Per #2887, switch over the whole ContingencyTable class heirarchy fro…
JohnHalleyGotway Aug 28, 2024
5e1d81d
Add ContingencyTable::is_integer() member function to check whether t…
JohnHalleyGotway Aug 28, 2024
32f3601
Per #2887, update parse_stat_line.cc to get it to compile after chang…
JohnHalleyGotway Aug 28, 2024
5834afd
Per #2887, update PCTInfo::clear() logic.
JohnHalleyGotway Aug 28, 2024
f2a1fd0
Merge remote-tracking branch 'origin/develop' into feature_2887_categ…
JohnHalleyGotway Sep 3, 2024
8c629e6
Per #2887, update ctc_by_row() logic to create reproducible results w…
JohnHalleyGotway Sep 3, 2024
b98276a
Per #2887, update logic of define_prob_bins() to add a final >=1.0 th…
JohnHalleyGotway Sep 3, 2024
dacd1d2
Per #2887, update roc_auc() function to match the develop branch
JohnHalleyGotway Sep 3, 2024
a5403e2
Per #2887, fix bug if computation of far()
JohnHalleyGotway Sep 3, 2024
2a68914
Per #2887, replaced all ==0 integer equality checks with calls to is_…
JohnHalleyGotway Sep 4, 2024
1b8cd06
Merge remote-tracking branch 'origin/develop' into feature_2887_categ…
JohnHalleyGotway Sep 6, 2024
7bce8b8
Per #2887, address some of the 34 SonarQube code smells flagged for t…
JohnHalleyGotway Sep 9, 2024
f0395b0
Per #2887, update run_sonarqube.sh to specify the target CXX standard…
JohnHalleyGotway Sep 9, 2024
8e1ecef
Per #2887, update to SonarQube version 6.1.0.4477 released on 6/27/2024.
JohnHalleyGotway Sep 9, 2024
1144765
Per #2887, updating build_met_sonarqube.sh to specify --std=c++11 sin…
JohnHalleyGotway Sep 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions internal/scripts/sonarqube/run_sonarqube.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ run_command "git checkout ${1}"
# Otherwise, the SonarQube logic does not work.
export MET_DEVELOPMENT=true

# Run the configure script
run_command "./configure --prefix=`pwd` --enable-all"
# Run the configure script.
# Specify the C++ standard to limit the scope of the findings.
run_command "./configure --prefix=`pwd` --enable-all MET_CXX_STANDARD=11"

# Define the version string
SONAR_PROJECT_VERSION=$(grep "^version" docs/conf.py | cut -d'=' -f2 | tr -d "\'\" ")
Expand Down
15 changes: 8 additions & 7 deletions src/basic/vx_util/num_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class NumArray {

double operator[](int) const;

const double * vals() const;
const std::vector<double> & vals() const;
double * buf();

int has(int, bool forward=true) const;
Expand Down Expand Up @@ -127,12 +127,13 @@ class NumArray {
////////////////////////////////////////////////////////////////////////


inline int NumArray::n_elements() const { return ( e.size() ); }
inline int NumArray::n () const { return ( e.size() ); }
inline const double * NumArray::vals() const { return ( e.data() ); }
inline double * NumArray::buf() { return ( e.data() ); }
inline void NumArray::inc(int i, int v) { e[i] += v; return; }
inline void NumArray::inc(int i, double v) { e[i] += v; return; }
inline int NumArray::n_elements() const { return e.size(); }
inline int NumArray::n() const { return e.size(); }
inline const std::vector<double> &
NumArray::vals() const { return e; }
inline double * NumArray::buf() { return e.data(); }
inline void NumArray::inc(int i, int v) { e[i] += v; return; }
inline void NumArray::inc(int i, double v) { e[i] += v; return; }


////////////////////////////////////////////////////////////////////////
Expand Down
6 changes: 6 additions & 0 deletions src/basic/vx_util/thresh_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,12 @@ ThreshArray define_prob_bins(double beg, double end, double inc, int prec) {
v += inc;
}

// Add final 1.0 threshold, if needed
if(!is_eq(ta[(ta.n() - 1)].get_value(), 1.0)) {
cs << cs_erase << ">=1.0";
ta.add(cs.c_str());
}

return ta;
}

Expand Down
36 changes: 16 additions & 20 deletions src/libcode/vx_statistics/compute_ci.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,8 @@ void compute_wilson_ci(double p, int n_int, double alpha, double vif,
////////////////////////////////////////////////////////////////////////

void compute_woolf_ci(double odds, double alpha,
int fy_oy, int fy_on, int fn_oy, int fn_on,
double fy_oy, double fy_on, double fn_oy, double fn_on,
double &odds_cl, double &odds_cu) {
double cv_normal_l, cv_normal_u, a, b;

if(is_bad_data(odds) ||
fy_oy == 0 || fy_on == 0 || fn_oy == 0 || fn_on == 0) {
Expand All @@ -185,14 +184,14 @@ void compute_woolf_ci(double odds, double alpha,
// Compute the upper and lower critical values from the
// normal distribution.
//
cv_normal_l = normal_cdf_inv(alpha/2.0, 0.0, 1.0);
cv_normal_u = normal_cdf_inv(1.0 - (alpha/2.0), 0.0, 1.0);
double cv_normal_l = normal_cdf_inv(alpha/2.0, 0.0, 1.0);
double cv_normal_u = normal_cdf_inv(1.0 - (alpha/2.0), 0.0, 1.0);

//
// Compute the upper and lower bounds of the confidence interval
//
a = exp(cv_normal_l*sqrt(1.0/fy_oy + 1.0/fy_on + 1.0/fn_oy + 1.0/fn_on));
b = exp(cv_normal_u*sqrt(1.0/fy_oy + 1.0/fy_on + 1.0/fn_oy + 1.0/fn_on));
double a = exp(cv_normal_l*sqrt(1.0/fy_oy + 1.0/fy_on + 1.0/fn_oy + 1.0/fn_on));
double b = exp(cv_normal_u*sqrt(1.0/fy_oy + 1.0/fy_on + 1.0/fn_oy + 1.0/fn_on));

odds_cl = odds * a;
odds_cu = odds * b;
Expand All @@ -210,19 +209,16 @@ void compute_woolf_ci(double odds, double alpha,
////////////////////////////////////////////////////////////////////////

void compute_hk_ci(double hk, double alpha, double vif,
int fy_oy, int fy_on, int fn_oy, int fn_on,
double fy_oy, double fy_on, double fn_oy, double fn_on,
double &hk_cl, double &hk_cu) {
double cv_normal, stdev;
double h, h_var, f_var;
int h_n, f_n;

//
// Get the counts
//
h_n = fy_oy + fn_oy;
f_n = fn_on + fy_on;
double h_n = fy_oy + fn_oy;
double f_n = fn_on + fy_on;

if(is_bad_data(hk) || h_n == 0 || f_n == 0) {
if(is_bad_data(hk) || is_eq(h_n, 0.0) || is_eq(f_n, 0.0)) {
hk_cl = hk_cu = bad_data_double;
return;
}
Expand All @@ -231,26 +227,26 @@ void compute_hk_ci(double hk, double alpha, double vif,
// Compute the critical value for the normal distribution based
// on the sample size
//
cv_normal = normal_cdf_inv(alpha/2.0, 0.0, 1.0);
double cv_normal = normal_cdf_inv(alpha/2.0, 0.0, 1.0);

//
// Compute the hit rate and false alarm rate
//
h = (double) fy_oy/h_n;
double h = fy_oy/h_n;

//
// Compute a variance for H and F
//
h_var = sqrt(h*(1.0-h)/h_n + cv_normal*cv_normal/(4.0*h_n*h_n))
/ (1.0 + cv_normal*cv_normal/h_n);
double h_var = sqrt(h*(1.0-h)/h_n + cv_normal*cv_normal/(4.0*h_n*h_n))
/ (1.0 + cv_normal*cv_normal/h_n);

f_var = sqrt(h*(1.0-h)/f_n + cv_normal*cv_normal/(4.0*f_n*f_n))
/ (1.0 + cv_normal*cv_normal/f_n);
double f_var = sqrt(h*(1.0-h)/f_n + cv_normal*cv_normal/(4.0*f_n*f_n))
/ (1.0 + cv_normal*cv_normal/f_n);

//
// Compute the standard deviation for HK
//
stdev = sqrt(vif*(h_var*h_var + f_var*f_var));
double stdev = sqrt(vif*(h_var*h_var + f_var*f_var));

//
// Compute the upper and lower bounds of the confidence interval
Expand Down
4 changes: 2 additions & 2 deletions src/libcode/vx_statistics/compute_ci.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ extern void compute_wilson_ci(double p, int n, double alpha,
double vif, double &p_cl, double &p_cu);

extern void compute_woolf_ci(double odds, double alpha,
int fy_oy, int fy_on, int fn_oy, int fn_on,
double fy_oy, double fy_on, double fn_oy, double fn_on,
double &odds_cl, double &odds_cu);

extern void compute_hk_ci(double hk, double alpha, double vif,
int fy_oy, int fy_on, int fn_oy, int fn_on,
double fy_oy, double fy_on, double fn_oy, double fn_on,
double &hk_cl, double &hk_cu);

extern void compute_cts_stats_ci_bca(const gsl_rng *,
Expand Down
Loading
Loading