Skip to main content

Attribute Weights

HierarchicalAttributeWeightsComponent writes <oem>/<market>/output/attribute_weights, with one weight per base model and attribute type. Each base model's weights sum to target_weight_total. DemandSupplyGapScorer and AttributeTurnScorer multiply each attribute type's gap or penalty by its weight; see Scoring and Selection.

Fitting the weights​

The weights measure how strongly each attribute type affects how fast a vehicle sells. The component reads from the pre-computed attribute_stats table (at the aggregation level named by attribute_stats_aggregation, default country_by_country_base_model) rather than from vehicle-level data. The weight_statistic (default sales) and weight_metric (default abnormal_days_on_lot) select which statistic to use as the signal.

  • The fit leaves out the attribute types of exclude_types and the attribute types that binary_representation leaves out. These attribute types get no weight.
  • For each base model, the fit reads the {statistic}_{metric}_z column from attribute stats. This column is each value's z-score: its mean metric deviation from the group mean, divided by the group's standard deviation, already within-model-year when the statistic's diff_center_by includes model_year. The z-score normalizes across groups with different baseline variability, so a type's spread is scale-invariant. The fit leaves out every value whose z-score is null or non-finite.
  • The standard deviation of the z-scores across a type's values is the attribute type's raw spread. A type with fewer than two values gets no weight.
  • The raw spread is multiplied by a logistic cardinality factor that increases with the number of attribute values and approaches cardinality_cap. This gives attribute types with more values a proportionally larger weight.
  • A base model whose {statistic}_group_nobs is below min_observations gets no base-model-level fit.
  • For a hierarchy level above base model (e.g. model_group), the importances are an average of the base-model-level fits whose group_nobs reaches min_aggregation_observations. Each fit's importances are first scaled to sum to 1, and each fit counts in proportion to group_nobs.
  • The fit does not run for a level without group_cols when the previous level with group_cols produced at least one fit. The importances of the level without group_cols are instead an average of the previous level's fits.
  • Each base model's importances are a blend of its hierarchy levels' fits. Each level's fit counts in proportion to group_nobs, divided by that level's kappa. The blended importances are scaled to sum to target_weight_total.

The fits column of a row lists the fits of the blend, one per hierarchy level, with each fit's credibility, importances and value statistics. attribute_weight is the weight after the weight bounds. The fits do not include the bounds.

Binary representation​

binary_representation decides how the fit reads a binary attribute, such as TRAILER_HITCH. HierarchicalAttributeWeightsComponent and ProjectedDemandComponent each set binary_representation to the binary_representation template variable of the market's template_vars.py. The project test test_the_components_of_each_market_read_one_binary_representation fails when two components of a market read different values.

  • SET: the fit weighs each <GROUP>_SET attribute type, whose values list the binary attributes of a category, such as TOWING_SET. The binary attribute types get no weight.
  • INDIVIDUAL: the fit weighs each binary attribute type, with its values TRUE and FALSE. The <GROUP>_SET attribute types get no weight.

Under INDIVIDUAL, a binary attribute type has two values, TRUE and FALSE. Its raw spread is half the difference between their z-scores. Its cardinality factor is that of two values, about 2.2 at the default cardinality_cap and cardinality_rate, while a <GROUP>_SET type with many values approaches cardinality_cap.

Weight bounds​

weight_bounds sets a minimum and a maximum share for each attribute type.

weight_bounds:
default: {min: 0.0005, max: 0.10}
attribute_types:
PAINT_COLOR: {min: 0.07, max: 0.40}
model_groups:
q5:
TOWING_SET: {min: 0.02, max: 0.10}
base_models:
# RS 3
"6527dd7ce758dc0c850bb82620593db2":
MIRROR_CAP_FINISH: {min: 0.01, max: 0.30}
  • min and max are shares of target_weight_total.
  • Each attribute type of a base model takes the most specific entry that names it:
    • an entry in base_models under the base model's base_model_id;
    • otherwise, an entry in model_groups under the base model's model_group, which the asset reads from consolidated/models;
    • otherwise, its entry in attribute_types;
    • otherwise, default. A binary attribute type takes only the maximum of default, and its minimum is 0.
  • The asset multiplies a base model's fitted weights by one factor and clips each product to its bounds. The asset chooses the factor at which the clipped weights sum to target_weight_total. The attribute types that no bound clips keep the ratios of their fitted weights.
  • For example, a base model whose fitted weights are 60% CHASSIS_SET, 30% POWER_LUMBAR and 10% PAINT_COLOR gets 40%, 20% and 40% when PAINT_COLOR has a 40% minimum and the other attribute types are unbounded.
  • A bound applies only to the attribute types that the fit wrote a weight for in that base model.
  • The asset raises when, for a base model:
    • the minima of its attribute types sum to 1 or more;
    • the maxima of its attribute types with a fitted weight above 0, plus the minima of those with a fitted weight of 0, sum to 1 or less.
  • The asset warns when an entry names an attribute type that none of the base models it covers has a weight for.

HierarchicalAttributeWeightsComponent raises when it loads weight_bounds that name an attribute type that binary_representation leaves out. Under SET, an entry names the <GROUP>_SET attribute type that lists a binary attribute, such as TOWING_SET for TRAILER_HITCH. Under INDIVIDUAL, it names the binary attribute type.

Several attribute types can describe the same choice. Paint color is part of PAINT_COLOR and PAINT_COLOR_X_UPHOLSTERY_COLOR, so a paint gap counts once in each of them. The minima of such attribute types add up to a minimum weight for the choice.