Skip to content

Commit

Permalink
treetop: tidy up the opimisation tab
Browse files Browse the repository at this point in the history
  • Loading branch information
natoscott committed Sep 25, 2024
1 parent c214a37 commit afa207e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
16 changes: 11 additions & 5 deletions src/treetop/pcp/Feature.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ const FeatureFieldData Feature_fields[] = {
[LOCAL_FEATURE] = { .name = "LOCAL_FEATURE", .title = " Important Metrics ", .description = "Most important metrics (features) from local SHAP" },
[LOCAL_IMPORTANCE] = { .name = "LOCAL_IMPORTANCE", .title = "SHAP VALUE ", .description = "SHAP value importance measure" },
[LOCAL_MUTUALINFO] = { .name = "LOCAL_MUTUALINFO", .title = "MUTUALINFO ", .description = "Mutual information for high SHAP value features" },
[OPTIM_FEATURE] = { .name = "OPTMIN_FEATURE", .title = " Key Metrics for Optimisation ", .description = "Important metrics for optimisation based on minima perturbations" },
[OPTIM_MIN_MAX] = { .name = "OPTIM_MIN_MAX", .title = "MIN/MAX", .description = "Used minimum or maximum for perturbation" },
[OPTIM_DIFFERENCE] = { .name = "OPTIM_DIFFERENCE", .title = "DELTA ", .description = "Change in prediction from perturbation" },
[OPTIM_FEATURE] = { .name = "OPTIM_FEATURE", .title = " Key Metrics for Optimisation ", .description = "Important metrics for optimisation based on minima perturbations" },
[OPTIM_MIN_MAX] = { .name = "OPTIM_MIN_MAX", .title = " TYPE ", .description = "Used minimum or maximum for perturbation" },
[OPTIM_DIFFERENCE] = { .name = "OPTIM_DIFFERENCE", .title = "DIFFERENCE ", .description = "Change in prediction from perturbation" },
[OPTIM_MUTUALINFO] = { .name = "OPTIM_MUTUALINFO", .title = "MUTUALINFO ", .description = "Mutual information with the target variable" },
// End of list
};
Expand Down Expand Up @@ -59,10 +59,10 @@ static const char* Feature_name(Row* rp) {
}

static void Feature_writeMinMax(const Feature* fp, RichString* str) {
char buffer[16]; buffer[16] = '\0';
char buffer[8]; buffer[8] = '\0';
int shadow = CRT_colors[PROCESS_SHADOW];
size_t n = sizeof(buffer) - 1;
snprintf(buffer, n, "%8s ", fp->min_max);
snprintf(buffer, n, " %s ", fp->min_max);
RichString_appendWide(str, shadow, buffer);
}

Expand Down Expand Up @@ -142,13 +142,19 @@ static int Feature_compareByKey(const Row* v1, const Row* v2, int key) {
switch (key) {
case LOCAL_FEATURE:
case MODEL_FEATURE:
case OPTIM_FEATURE:
return SPACESHIP_NULLSTR(f1->name, f2->name);
case LOCAL_MUTUALINFO:
case MODEL_MUTUALINFO:
case OPTIM_MUTUALINFO:
return SPACESHIP_NUMBER(f1->mutualinfo, f2->mutualinfo);
case LOCAL_IMPORTANCE:
case MODEL_IMPORTANCE:
return SPACESHIP_NUMBER(f1->importance, f2->importance);
case OPTIM_DIFFERENCE:
return SPACESHIP_NUMBER(f1->difference, f2->difference);
case OPTIM_MIN_MAX:
return SPACESHIP_NULLSTR(f1->min_max, f2->min_max);
default:
return Row_compare(v1, v2);
}
Expand Down
4 changes: 2 additions & 2 deletions src/treetop/pcp/Feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ typedef struct Feature_ {
/* default result offset to use for searching metrics */
unsigned int offset;

char min_max[4];
float difference;
float importance;
float mutualinfo;
float difference;
char min_max[16];
} Feature;

typedef struct FeatureFieldData_ {
Expand Down
4 changes: 2 additions & 2 deletions src/treetop/pcp/FeatureTable.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ static void FeatureTable_updateOptimInfo(Feature* fp, int id, int offset) {
String_safeStrncpy(fp->name, value.cp, sizeof(fp->name));
free(value.cp);

if (Metric_instance(PCP_OPTIM_MIN_MAX, id, offset, &value, PM_TYPE_STRING))
value.cp = xStrdup("<unknown>");
if (!Metric_instance(PCP_OPTIM_MIN_MAX, id, offset, &value, PM_TYPE_STRING))
value.cp = xStrdup("---");
String_safeStrncpy(fp->min_max, value.cp, sizeof(fp->min_max));
free(value.cp);

Expand Down
4 changes: 2 additions & 2 deletions src/treetop/pcp/TreeTop.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const ScreenDefaults Platform_defaultScreens[] = {
.sortKey = "LOCAL_IMPORTANCE",
},
{ .name = "Optimum importance",
.columns = "OPTIM_FEATURE OPTIM_MIN_MAX OPTIM_DELTA OPTIM_MUTUALINFO",
.columns = "OPTIM_FEATURE OPTIM_MIN_MAX OPTIM_DIFFERENCE OPTIM_MUTUALINFO",
},
};

Expand Down Expand Up @@ -120,7 +120,7 @@ static const char* Platform_metricNames[] = {
[PCP_OPTIM_FEATURES] = "mmv.treetop.server.optimising.features",
[PCP_OPTIM_MIN_MAX] = "mmv.treetop.server.optimising.min_max",
[PCP_OPTIM_DIFFERENCE] = "mmv.treetop.server.optimising.difference",
[PCP_OPTIM_MUTUALINFO] = "mmv.treetop.server.optimising.mutual_infomation",
[PCP_OPTIM_MUTUALINFO] = "mmv.treetop.server.optimising.mutual_information",
[PCP_OPTIM_ELAPSED] = "mmv.treetop.server.optimising.elapsed_time",

[PCP_METRIC_COUNT] = NULL
Expand Down

0 comments on commit afa207e

Please sign in to comment.