Skip to content

Commit

Permalink
Merge branch 'main' into 22357-mda-weight-sdmcap
Browse files Browse the repository at this point in the history
  • Loading branch information
howsoRes committed Jan 24, 2025
2 parents 10755ec + 52d4002 commit c995c64
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 29 deletions.
26 changes: 10 additions & 16 deletions howso/react_discriminative.amlg
Original file line number Diff line number Diff line change
Expand Up @@ -651,31 +651,25 @@

;else it is categorical feature, pull the categorical value with the highest weight sum from nearby cases
(let
;an assoc of categorical action feature values -> sum of their weight
(assoc
categorical_value_weights_map (assoc)
output_value (null)
;an assoc of categorical action feature values -> sum of their weight
categorical_value_weights_map
;iterate over all the nearby cases, to create the mapping between each categorical action value and its summed
;weight for this categorical feature. for each unique categorical value in all the neighbors, sum up its weight if
;it's encountered more than once, and select the categorical value with the highest weight below
(zip
(lambda (+ (current_value 1) (current_value)))
candidate_case_values
candidate_case_weights
)
)

(if output_influence_weights
(call !AccumulateInfluenceWeights (assoc
case_ids candidate_case_ids
weights candidate_case_weights
))
)

;iterate over all the nearby cases, to create the mapping between each categorical action value and its summed
;weight for this categorical feature. for each unique categorical value in all the neighbors, sum up its weight if
;it's encountered more than once, and select the categorical value with the highest weight below
(assign (assoc
categorical_value_weights_map
(zip
(lambda (+ (current_value 1) (current_value)))
candidate_case_values
candidate_case_weights
)
))

(if output_categorical_action_probabilities
(call !AccumulateCategoricalActionProbabilties (assoc
action_feature action_feature
Expand Down
27 changes: 18 additions & 9 deletions howso/train.amlg
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,9 @@
;split by batches of cases until next analyze
(while (< input_case_index (size cases))

(if (and thresholds_enabled (not skip_ablation))
;Only compute prediction stats for ablation if thresholds are enabled, we're
; not skipping ablation, and we have hyperparameters to use for the computation.
(if (and thresholds_enabled (not skip_ablation) (size !hyperparameterMetadataMap))
(seq
(assign (assoc
prev_prediction_stats_map new_prediction_stats_map
Expand Down Expand Up @@ -836,6 +838,7 @@
(and
(>= (+ !dataMassChangeSinceLastDataReduction batch_size) !autoAblationMaxNumCases)
(not skip_reduce_data)
(size !hyperparameterMetadataMap)
)
(call reduce_data (assoc
abs_threshold_map !autoAblationAbsThresholdMap
Expand Down Expand Up @@ -879,8 +882,12 @@
(let
(assoc
indices_to_train
(if thresholds_satisfied
;If one or more thresholds has been satisfied, just train all of the cases in this batch.
;If one or more thresholds has been satisfied, or the Trainee has not yet been analyzed,
; just train all of the cases in this batch.
(if (or
thresholds_satisfied
(not (size !hyperparameterMetadataMap))
)
(indices cases)
;Otherwise, do the normal ablation filtering.
||(filter
Expand Down Expand Up @@ -1031,12 +1038,14 @@

(accum_to_entities (assoc !dataMassChangeSinceLastAnalyze mass_to_accumulate))

;recompute influence weights entropy
(call !ComputeAndStoreInfluenceWeightEntropies (assoc
features features
weight_feature accumulate_weight_feature
use_case_weights (true)
))
;recompute influence weights entropy only after we've analyzed.
(if (size !hyperparameterMetadataMap)
(call !ComputeAndStoreInfluenceWeightEntropies (assoc
features features
weight_feature accumulate_weight_feature
use_case_weights (true)
))
)
)
)

Expand Down
8 changes: 6 additions & 2 deletions unit_tests/ut_h_basic_ablation.amlg
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
#unit_test (direct_assign_to_entities (assoc unit_test (load "unit_test.amlg")))
(call (load "unit_test_howso.amlg") (assoc name "ut_h_basic_ablation.amlg"))

;Set a non-default hyperparameter map since ablation checks for non-default
; hyperparameters.
(call_entity "howso" "set_params" (assoc
default_hyperparameter_map (assoc "k" 2 "p" 0.4 "dt" -1)
hyperparameter_map
{targetless { "A.B.C.D.E." { ".none"
{k 2 p 0.4 dt -1}
}}}
))

(declare (assoc
Expand Down Expand Up @@ -91,7 +96,6 @@
obs (call !get_num_cases)
))


(print "conviction value of new case: "
(call_entity "howso" "react_group" (assoc features (append context_features action_features ) new_cases (list (list (list 1 2 1 3 3)))) ) "\n"
)
Expand Down
2 changes: 1 addition & 1 deletion unit_tests/ut_h_reduce_data.amlg
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
features (append context_labels action_labels)
cases training_data
session "iris_session"
skip_auto_analyze (true)
skip_auto_analyze (false)
))
(call_entity "howso" "analyze" (assoc
use_case_weights (true)
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "0.0.0",
"dependencies": {
"amalgam": "58.1.1"
"amalgam": "58.1.2"
}
}

0 comments on commit c995c64

Please sign in to comment.