Feature Attributes#
Understanding and properly utilizing Feature Attributes is the most important step for successful use of Howso™. Feature attributes can be specified manually but are often built using the infer feature attributes (IFA) utility function. This section will answer common questions related to both IFA and the feature attributes in general.
- Related api reference pages for feature attributes:
FeatureAttributestype.infer_feature_attributes()utility function.
How do I use Infer Feature Attributes?#
In general, IFA is an iterative process:
If you’re new to IFA or are not familiar with your data types, just pass-in your data and print the dictionary:
features = infer_feature_attributes(data)
Audit the dictionary to ensure the mapping matches your data. Some common mappings that should be reviewed:
typebeing nominal, ordinal, or continuous.bounds:minandmaxvalues.date_time_formatfor specifying the dates/times correctly.
Pass in any changes as arguments to IFA and run it again. The following are some of the common arguments:
Create a partial feature dictionary and pass it to the argument
features. This is common when specifying thetype, for example when a feature is nominal.Pass in a dictionary that specifies the correct datetime format using
datetime_feature_formats.The exception is specifying the
bounds. Edit the dictionary after it’s been built by IFA.
print the dictionary and audit.
Repeat steps 2 - 3 until the feature mapping is built properly.
What is the difference between nominal, ordinal, and continuous features?#
continuous: A numeric value that can be any value between two arbitrary numbers. e.g. price, date, distance
nominal: An unordered value. e.g. name, phone number, shirt size
ordinal: An ordered value. e.g. priority number, product rating, education degree
How do I map ordinal features?#
If the feature is numeric, all you must do is specify the
typeas ordinal inside IFA.If the feature is ordinal but not numeric, pass a dictionary specifying the order to IFA using the
ordinal_feature_valuesargument. - An example is:{ "size" : [ "small", "medium", "large", "huge" ] }
How do I map cyclic features?#
Cyclic features are set by specifying a cycle_length value in the feature attributes.
cycle_length requires a single value, which is the upper bound of the difference for
the cycle range. For example, if cycle_length is 360, then a value of 1 and 359 will
have a difference of 2. Cyclic features have no restrictions in the input dataset, however,
cyclic features will be output on a scale from 0 to cycle_length. To constrain the output
to a different range, modify the min and max bounds feature attribute.
Specify the
typeas continuous inside IFA.Specify the maximum value (exclusive) as the
cycle_lengthfeature attribute.
How do I specify dates?#
Often, IFA can intuit the proper date format especially if the dates are a Python
datetimeobject.They can also be specified by passing a dictionary to IFA using the
datetime_feature_formatsargument. - An example is:{ "end_date" : "%Y-%m-%d" }
What are partial features?#
Partial features is a term used to describe a partial dictionary from which IFA builds the rest of the feature mapping. It is also a variable-name passed to the
featuresargument inside IFA. Below is an example:# Infer features using DataFrame format partial_features = {'education-num':{'type':'nominal'}, 'age':{'type':'continuous'}} features = infer_feature_attributes(df, features=partial_features)
partial_featuresare important because they allow IFA to correctly specify the bounds. For example, imagine a nominal feature of US zip codes (90016, 91334, etc.). IFA may infer these values to be continuous and the resulting dictionary will includeminandmaxbounds. You can edit thetypeto be nominal post calling IFA, but the continuous bounds may cause an issue when reacting to the model. This is why it’s often better to usepartial_featuresas a core to pass into IFA.
What are dependent features?#
Dependent features are those features which depend on each other. These features are specified using the
dependent_featuresfeature attribute. Common examples include lab results and their units of measure. During synthesis, it’s imperative the lab results match the units of measure like the original dataset.
Derivation Attributes#
Derived during-training features should have a feature attribute of [auto_derive_on_train](howso.openapi.models.FeatureAutoDeriveOnTrain), containing the configuration on how to derive the feature.
A derive_type value is required to define the type of derivation, one of
[custom](howso.openapi.models.FeatureAutoDeriveOnTrainCustom) or
[progress](howso.openapi.models.FeatureAutoDeriveOnTrainProgress) is allowed.
Each type has its own attribute set.
Allowed list of operations for code attributes. All operations use prefix notation:
+ - * / = != < <= > >= number string concat if and or xor not null min max mod sqrt pow abs log exp floor ceil round rand sin cos acos tan atan sinh asinh cosh acosh tanh atanh