Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 10 additions & 6 deletions module/attributes.amlg
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@
; 'value_evaluation_code': string, custom Amalgam code that is called to return the value used for the feature in distance computations.
; The code should either be a singular (call_on_entity) or (call_entity) with the entity specified as .null.
;
; 'computed': boolean, automatically set to true for any internally computed feature that was not trained from the original dataset
;
; 'non_sensitive': boolean, flag a categorical nominal feature as non-sensitive. It is recommended that
; all nominal features be represented with either an 'int-id' subtype or another
; available nominal subtype using the 'subtype' attribute. However, if the nominal
Expand Down Expand Up @@ -583,18 +585,20 @@
(modify
(current_value)
["auto_derive_on_train" "code_features"]
(call !FeaturesInCustomCode (assoc
code_string (get (current_value 1) ["auto_derive_on_train" "code"])
))
(call !FeaturesInCustomCode (assoc
code_string (get (current_value 1) ["auto_derive_on_train" "code"])
))
["computed"]
.true
)

(contains_index (current_value) "derived_feature_code")
(modify
(current_value)
"code_features"
(call !FeaturesInCustomCode (assoc
code_string (get (current_value 1) "derived_feature_code")
))
(call !FeaturesInCustomCode (assoc
code_string (get (current_value 1) "derived_feature_code")
))
)
)
(current_value)
Expand Down
6 changes: 3 additions & 3 deletions module/conviction.amlg
Original file line number Diff line number Diff line change
Expand Up @@ -260,17 +260,17 @@
(map
(lambda
(if (or (= "p_value_of_addition" (current_value)) (= "p_value_of_removal" (current_value)))
{"type" "continuous" "data_type" "number" "bounds" {"min" 0 "max" 1} }
{"type" "continuous" "data_type" "number" "bounds" {"min" 0 "max" 1} "computed" .true }

;else convictions, entropy and distance contribution ranges are 0 to infinity
{"type" "continuous" "data_type" "number" "bounds" {"min" 0 "max" .infinity} }
{"type" "continuous" "data_type" "number" "bounds" {"min" 0 "max" .infinity} "computed" .true }
)
)
(indices computed_map)
)
)
(if clustering
(associate clustering {"type" "nominal" "data_type" "number" })
(associate clustering {"type" "nominal" "data_type" "number" "computed" .true })
{}
)
)
Expand Down
8 changes: 8 additions & 0 deletions module/generate_features.amlg
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,7 @@
"bounds" (assoc "min" 0.0 "allow_null" .false)
"decimal_places" 0
"original_type" {"data_type" "integer" "size" 8}
"computed" .true
)
".synchronous_counter_lag_1"
(assoc
Expand All @@ -795,6 +796,7 @@
"derived_feature_code" "(call value {feature \".synchronous_counter\" lag 1})"
"ts_type" "lag"
"parent" ".synchronous_counter"
"computed" .true
)
".series_index"
(assoc
Expand All @@ -803,13 +805,15 @@
"original_type" {"data_type" "integer" "size" 8}
"derived_feature_code" "(+ 1 (call value {feature \".series_index\" lag 1}))"
"bounds" (assoc "min" 0.0 "allow_null" .false)
"computed" .true
)
".reverse_series_index"
(assoc
"type" "continuous"
"decimal_places" 0
"original_type" {"data_type" "integer" "size" 8}
"bounds" (assoc "min" 0.0 "allow_null" .false)
"computed" .true
)
)
))
Expand All @@ -824,6 +828,7 @@
"derived_feature_code" "(call value {feature \".time_to_horizon\" lag 1})"
"bounds" (assoc "min" 0.0 "allow_null" .false)
"original_type" {"data_type" "numeric" "size" 8}
"computed" .true
)
)
))
Expand Down Expand Up @@ -922,6 +927,7 @@
;internal sub-attributed used to identify time series type of parent feature
"parent_type" (get attributes (list "time_series" "type"))
"parent" feature
"computed" .true
)
(if date_time_format
(assoc "date_time_format" date_time_format)
Expand Down Expand Up @@ -982,6 +988,7 @@
"ts_order" (current_index 1)
"parent" feature
"original_type" {"data_type" "numeric" "size" 8}
"computed" .true
)

;if order <= derived_orders, set the derived_feature_code property
Expand Down Expand Up @@ -1035,6 +1042,7 @@
"ts_order" (current_index 1)
"parent" feature
"original_type" {"data_type" "numeric" "size" 8}
"computed" .true
)

;if order <= derived_orders, set the derived_feature_code property
Expand Down
5 changes: 5 additions & 0 deletions module/types.amlg
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@
values "string"
description "A list of features needed to derive code"
)
computed
(assoc
type "boolean"
description "Flag, set to true if this feature was computed internally and not explicitly trained with the original dataset."
)
post_process
(assoc
type "string"
Expand Down
14 changes: 7 additions & 7 deletions unit_tests/ut_h_react_into_features.amlg
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@
exp
{
color {type "nominal"}
".distance_contribution" { bounds {max .infinity min 0} data_type "number" type "continuous" }
dc { bounds {max .infinity min 0} data_type "number" type "continuous" }
fc { bounds {max .infinity min 0} data_type "number" type "continuous" }
if { bounds {max .infinity min 0} data_type "number" type "continuous" }
sc { bounds {max .infinity min 0} data_type "number" type "continuous" }
rc { bounds {max .infinity min 0} data_type "number" type "continuous" }
".similarity_conviction" { bounds {max .infinity min 0} data_type "number" type "continuous" }
".distance_contribution" { bounds {max .infinity min 0} data_type "number" type "continuous" computed .true}
dc { bounds {max .infinity min 0} data_type "number" type "continuous" computed .true}
fc { bounds {max .infinity min 0} data_type "number" type "continuous" computed .true}
if { bounds {max .infinity min 0} data_type "number" type "continuous" computed .true}
sc { bounds {max .infinity min 0} data_type "number" type "continuous" computed .true}
rc { bounds {max .infinity min 0} data_type "number" type "continuous" computed .true}
".similarity_conviction" { bounds {max .infinity min 0} data_type "number" type "continuous" computed .true}
x { bounds {allow_null .true} type "continuous" }
y { bounds {allow_null .true} type "continuous" }
}
Expand Down
29 changes: 29 additions & 0 deletions unit_tests/ut_h_time_series_stock.amlg
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,35 @@
start_index 20
))

(assign (assoc
result (call_entity "howso" "get_feature_attributes")
))
(call keep_result_payload)
(print "Computed flag set for all computed features only: ")
(call assert_same (assoc
exp [.true]
obs
(values
(map
(lambda
;all the built-in ts features are computed
(if (= "." (first (current_index)))
(get (current_value) "computed")

;the custom defined feature is computed
(= "over106" (current_index))
(get (current_value) "computed")

;trained features are not computed
(not (contains_index (current_value) "computed"))
)
)
result
)
.true
)
))

(print "specified start_index on second train batch works:\n")
;the 17th case should have training index 20
(call assert_same (assoc
Expand Down