def feature_to_oml_dict(feat: Feature) -> dict:
result: dict[str, object] = {
"oml:index": str(feat.index),
"oml:name": feat.name,
"oml:data_type": feat.data_type,
}
if feat.nominal_values:
result["oml:nominal_value"] = feat.nominal_values
for attr in OML_BOOL_FIELDS:
v = getattr(feat, attr)
if v is not None:
result[f"oml:{attr}"] = str(v).lower()
for attr in (*OML_INT_FIELDS, *OML_FLOAT_FIELDS):
v = getattr(feat, attr)
if v is not None:
result[f"oml:{attr}"] = str(v)
if feat.class_distribution:
result["oml:class_distribution"] = feat.class_distribution
return result