# Get ML Features

Access prebuilt event-based Machine Learning features that will take your forecast models and results to the next level, fast.&#x20;

We've built up years of expertise in transforming raw event data into meaningful demand signals. Across industries, we’ve consistently seen that naïve aggregation produces noise rather than uplift. The Features API encapsulates that experience - delivering proven, engineered signals that improve forecast accuracy without the heavy lifting.

## POST /v1/features/

> Get ML Features

````json
{"openapi":"3.1.0","info":{"title":"PredictHQ Features API","version":"1.0.0"},"tags":[{"name":"Features API"}],"servers":[{"url":"https://api.predicthq.com"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"$API_KEY","description":"Enter your PredictHQ API key. The Bearer prefix is added automatically.\n\nWhen calling the API directly, send: `Authorization: Bearer <YOUR_API_KEY>` as documented at [https://docs.predicthq.com/api/overview/authenticating](https://docs.predicthq.com/api/overview/authenticating)\n"}},"parameters":{"OffsetParam":{"name":"offset","in":"query","description":"Offset the results.","required":false,"schema":{"type":"integer","default":0}},"LimitParam":{"name":"limit","in":"query","description":"Limit the number of results.","required":false,"schema":{"type":"integer","default":10}}},"schemas":{"FeaturesRequestModel":{"type":"object","properties":{"active":{"description":"The date range to calculate features for. This is named `active` because it includes events that are active within the date range. A multi-day event might start or end outside the specified date range - the days the event is active within the specified range will be included in the calculations.\n\n**Supports the following fields:**\n- `gt` - greater than\n- `gte` - greater than or equal\n- `lt` - less than\n- `lte` - less than or equal\n\nNote that all dates here are in local time (not UTC). Features API works on specific locations.\n\n\n**E.g.**\n```json\n{\n  \"active\": {\n    \"gte\": \"2019-11-28\",\n    \"lte\": \"2019-11-29\"\n  }\n}\n","$ref":"#/components/schemas/ActiveDateRange"},"beam":{"description":"An optional beam analysis object which if provided will calculate the `location`, `interval`, `week_start_day`, `phq_*` features and `stats`, and `phq_rank` from the Beam analysis (and optionally its group).\n\n**Fields:**\n- `analysis_id` (required if `beam` is present): Beam analysis ID\n- `group_id` (optional): Beam analysis group ID\n\nIf beam.analysis_id is provided, the `location`, `interval`, `week_start_day` , `phq_*` features including `stats` and `phq_rank` will be calculated from the Beam analysis.\n\n**E.g.**\n```json\n{\n  \"beam\": {\n    \"analysis_id\": \"0SXAmHsoZo0\"\n  }\n}\n```\nIf both `beam.analysis_id` and `beam.group_id` are provided, all the above fields will be calculated from the Beam analysis but the `phq_*` features will be calculated from the Beam analysis Group.\n\nNote: This is useful for when you want to request features for a variety of locations while maintaining feature consistency by limiting the returned features to those of the group's feature importance results.\n\nE.g.\n```json\n    {\n  \"beam\": {\n    \"analysis_id\": \"0SXaMHsoYo0\",\n    \"group_id\": \"QxE9BcLq7ZY\"\n  }\n}\n```","$ref":"#/components/schemas/Beam"},"hour_of_day_start":{"description":"Time range (per day) to calculate features for.\n\nNote: This field is currently only supported on `phq_viewership_*` features.\n\nIf your location only operates within certain hours of the day you can use this filter to only include records that are happening within those hours.\n\nSupports the following fields:\n**Fields:**\n- `gt` - greater than\n- `gte` - greater than or equal\n- `lt` - less than\n- `lte` - less than or equal\n\nThe values are hours between 0 and 23 (i.e. 24h format).\n\nE.g. only include events happening between 1pm and 3pm each day.\n\n**E.g.**\n```json\n{\n  \"hour_of_day_start\": {\n    \"gte\": 13,\n    \"lte\": 15\n  }\n}\n```\n","$ref":"#/components/schemas/HourOfDayRange"},"location":{"description":"Location to calculate features for. You can specify the location as a latitude/longitude (with radius), Place ID(s) or [Saved Location IDs](https://docs.predicthq.com/api/saved-locations/overview). \n\nWe recommend using a lat/lon+radius or a saved location id (for a point and radius location) as they could define the location of your interest more accurately. To work out a suitable radius around your location we strongly recommend using our [Suggested Radius API](https://docs.predicthq.com/api/suggested-radius/get-suggested-radius).\n\nNote: When using Place IDs or Saved Location IDs a maximum of 3 IDs may be used.\n\nNote: When using lat/lon+radius, the radius must be in the format `<radius><radius_unit>`, where `<radius>` is an integer or a float number up to 2 decimal places and `<radius_unit>` is one of:\n- `m` - meters\n- `km` - kilometers\n- `ft` - feet\n- `mi` - miles\nE.g. using Place IDs:\n```json\n    {\n      \"location\": {\n        \"place_id\": [\n          5224323,\n          5811704,\n          4887398\n        ]\n      }\n    }\n```\nE.g. using Saved Location IDs:\n```json\n    {\n      \"location\": {\n        \"saved_location_id\": [\n          \"BN7ZSw8xza9FviPVfyCycd\",\n          \"X3uyTFbDOUaX2q_Qh5i31b\",\n          \"X3uyTFbDOUhrfq_Qh5i31A\"\n        ]\n      }\n    }\n```\nE.g. using a latitude/longitude and radius:\n```json\n    {\n      \"location\": {\n        \"geo\": {\n          \"lat\": 41.75038,\n          \"lon\": -71.49978,\n          \"radius\": \"2.62mi\"\n        }\n      }\n    }\n```\n","$ref":"#/components/schemas/Location"},"interval":{"description":"Aggregation interval.\n\nPossible values:\n    **Fields:**\n- `day` (default) for daily aggregation\n- `week` for weekly aggregation\n","$ref":"#/components/schemas/Interval"},"week_start_day":{"description":"The weekday to be treated as the start of the week.\n\nPossible values:\n- `monday` (default)\n- `tuesday`\n- `wednesday`\n- `thursday`\n- `friday`\n- `saturday`\n- `sunday`\n\nOnly applicable when interval is set to week.\n","$ref":"#/components/schemas/Weekday"},"predicted_events":{"description":"Include or Exclude predicted events.","$ref":"#/components/schemas/PredictedEvents"},"phq_attendance_academic_graduation":{"description":"Academic - Graduation","$ref":"#/components/schemas/StatsField"},"phq_attendance_academic_social":{"description":"Academic - Social","$ref":"#/components/schemas/StatsField"},"phq_attendance_community":{"description":"Community","$ref":"#/components/schemas/StatsField"},"phq_attendance_concerts":{"description":"Concerts","$ref":"#/components/schemas/StatsField"},"phq_attendance_conferences":{"description":"Conferences","$ref":"#/components/schemas/StatsField"},"phq_attendance_expos":{"description":"Expos","$ref":"#/components/schemas/StatsField"},"phq_attendance_festivals":{"description":"Festivals","$ref":"#/components/schemas/StatsField"},"phq_attendance_performing_arts":{"description":"Performing Arts","$ref":"#/components/schemas/StatsField"},"phq_attendance_sports":{"description":"Sports","$ref":"#/components/schemas/StatsField"},"phq_attendance_school_holidays":{"description":"School Holidays","$ref":"#/components/schemas/StatsField"},"phq_attendance_community_accommodation":{"description":"Community accommodation impact","$ref":"#/components/schemas/StatsField"},"phq_attendance_concerts_accommodation":{"description":"Concerts accommodation impact","$ref":"#/components/schemas/StatsField"},"phq_attendance_conferences_accommodation":{"description":"Conferences accommodation impact","$ref":"#/components/schemas/StatsField"},"phq_attendance_expos_accommodation":{"description":"Expos accommodation impact","$ref":"#/components/schemas/StatsField"},"phq_attendance_festivals_accommodation":{"description":"Festivals accommodation impact","$ref":"#/components/schemas/StatsField"},"phq_attendance_performing_arts_accommodation":{"description":"Performing Arts accommodation impact","$ref":"#/components/schemas/StatsField"},"phq_attendance_sports_accommodation":{"description":"Sports accommodation impact","$ref":"#/components/schemas/StatsField"},"phq_attendance_community_hospitality":{"description":"Community hospitality impact","$ref":"#/components/schemas/StatsField"},"phq_attendance_concerts_hospitality":{"description":"Concerts hospitality impact","$ref":"#/components/schemas/StatsField"},"phq_attendance_conferences_hospitality":{"description":"Conferences hospitality impact","$ref":"#/components/schemas/StatsField"},"phq_attendance_expos_hospitality":{"description":"Expos hospitality impact","$ref":"#/components/schemas/StatsField"},"phq_attendance_festivals_hospitality":{"description":"Festivals hospitality impact","$ref":"#/components/schemas/StatsField"},"phq_attendance_performing_arts_hospitality":{"description":"Performing Arts hospitality impact","$ref":"#/components/schemas/StatsField"},"phq_attendance_sports_hospitality":{"description":"Sports hospitality impact","$ref":"#/components/schemas/StatsField"},"phq_attendance_community_retail":{"description":"Community Retail impact","$ref":"#/components/schemas/StatsField"},"phq_attendance_concerts_retail":{"description":"Concerts Retail impact","$ref":"#/components/schemas/StatsField"},"phq_attendance_conferences_retail":{"description":"Conferences Retail impact","$ref":"#/components/schemas/StatsField"},"phq_attendance_expos_retail":{"description":"Expos Retail impact","$ref":"#/components/schemas/StatsField"},"phq_attendance_festivals_retail":{"description":"Festivals Retail impact","$ref":"#/components/schemas/StatsField"},"phq_attendance_performing_arts_retail":{"description":"Performing Arts Retail impact","$ref":"#/components/schemas/StatsField"},"phq_attendance_sports_retail":{"description":"Sports Retail impact","$ref":"#/components/schemas/StatsField"},"phq_rank_daylight_savings":{"description":"Daylight Savings  \n_Default: False_","type":"boolean","title":"Phq Rank Daylight Savings"},"phq_rank_health_warnings":{"description":"Health Warnings  \n_Default: False_","type":"boolean","title":"Phq Rank Health Warnings"},"phq_rank_observances":{"description":"Observances  \n_Default: False_","type":"boolean","title":"Phq Rank Observances"},"phq_rank_public_holidays":{"description":"Public Holidays  \n_Default: False_","type":"boolean","title":"Phq Rank Public Holidays"},"phq_rank_school_holidays":{"description":"School Holidays  \n_Default: False_","type":"boolean","title":"Phq Rank School Holidays"},"phq_rank_politics":{"description":"Politics  \n_Default: False_","type":"boolean","title":"Phq Rank Politics"},"phq_rank_academic_session":{"description":"Academic - Session  \n_Default: False_","type":"boolean","title":"Phq Rank Academic Session"},"phq_rank_academic_exam":{"description":"Academic - Exam  \n_Default: False_","type":"boolean","title":"Phq Rank Academic Exam"},"phq_rank_academic_holiday":{"description":"Academic - Holiday  \n_Default: False_","type":"boolean","title":"Phq Rank Academic Holiday"},"phq_impact_observances":{"description":"Observances","$ref":"#/components/schemas/StatsField"},"phq_impact_public_holidays":{"description":"Public Holidays","$ref":"#/components/schemas/StatsField"},"phq_impact_school_holidays":{"description":"School Holidays","$ref":"#/components/schemas/StatsField"},"phq_impact_academic_exam":{"description":"Academic","$ref":"#/components/schemas/StatsField"},"phq_impact_academic_holiday":{"description":"Academic","$ref":"#/components/schemas/StatsField"},"phq_impact_academic_session":{"description":"Academic","$ref":"#/components/schemas/StatsField"},"phq_impact_observances_accommodation":{"description":"Observances (Industry: Accommodation)","$ref":"#/components/schemas/StatsField"},"phq_impact_observances_hospitality":{"description":"Observances (Industry: Hospitality/Food & Beverage)","$ref":"#/components/schemas/StatsField"},"phq_impact_observances_retail":{"description":"Observances (Industry: Retail)","$ref":"#/components/schemas/StatsField"},"phq_impact_public_holidays_accommodation":{"description":"Public Holidays (Industry: Accommodation)","$ref":"#/components/schemas/StatsField"},"phq_impact_public_holidays_hospitality":{"description":"Public Holidays (Industry: Hospitality/Food & Beverage*)","$ref":"#/components/schemas/StatsField"},"phq_impact_public_holidays_retail":{"description":"Public Holidays (Industry: Retail)","$ref":"#/components/schemas/StatsField"},"phq_impact_school_holidays_retail":{"description":"School Holidays (Industry: Retail)","$ref":"#/components/schemas/StatsField"},"phq_impact_severe_weather_air_quality_retail":{"description":"Severe Weather - Air Quality (Industry: Retail)","$ref":"#/components/schemas/StatsField"},"phq_impact_severe_weather_blizzard_retail":{"description":"Severe Weather - Blizzard (Industry: Retail)","$ref":"#/components/schemas/StatsField"},"phq_impact_severe_weather_cold_wave_retail":{"description":"Severe Weather - Cold Wave - (All) (Industry: Retail)","$ref":"#/components/schemas/StatsField"},"phq_impact_severe_weather_cold_wave_snow_retail":{"description":"Severe Weather - Cold Wave - Snow (Industry: Retail)","$ref":"#/components/schemas/StatsField"},"phq_impact_severe_weather_cold_wave_storm_retail":{"description":"Severe Weather - Cold Wave - Storm (Industry: Retail)","$ref":"#/components/schemas/StatsField"},"phq_impact_severe_weather_dust_retail":{"description":"Severe Weather - Dust - (All) (Industry: Retail)","$ref":"#/components/schemas/StatsField"},"phq_impact_severe_weather_dust_storm_retail":{"description":"Severe Weather - Dust - Storm (Industry: Retail)","$ref":"#/components/schemas/StatsField"},"phq_impact_severe_weather_flood_retail":{"description":"Severe Weather - Flood (Industry: Retail)","$ref":"#/components/schemas/StatsField"},"phq_impact_severe_weather_heat_wave_retail":{"description":"Severe Weather - Heat Wave (Industry: Retail)","$ref":"#/components/schemas/StatsField"},"phq_impact_severe_weather_hurricane_retail":{"description":"Severe Weather - Hurricane (Industry: Retail)","$ref":"#/components/schemas/StatsField"},"phq_impact_severe_weather_thunderstorm_retail":{"description":"Severe Weather - Thunderstorm (Industry: Retail)","$ref":"#/components/schemas/StatsField"},"phq_impact_severe_weather_tornado_retail":{"description":"Severe Weather - Tornado (Industry: Severe Weather - Tornado) (Industry: Retail)","$ref":"#/components/schemas/StatsField"},"phq_impact_severe_weather_tropical_storm_retail":{"description":"Severe Weather - Tropical Storm (Industry: Retail)","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports":{"description":"Sports - (All)","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_american_football":{"description":"American Football - (All)","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_american_football_ncaa_men":{"description":"American Football - NCAA Men's","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_american_football_nfl":{"description":"American Football - NFL","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_auto_racing":{"description":"Automotive Racing - All","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_auto_racing_indy_car":{"description":"Automotive Racing - Indy Car","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_auto_racing_nascar":{"description":"Automotive Racing - NASCAR","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_baseball":{"description":"Baseball - (All)","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_baseball_mlb":{"description":"Baseball - MLB","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_baseball_ncaa_men":{"description":"Baseball - NCAA Men's","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_basketball":{"description":"Basketball - (All)","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_basketball_nba":{"description":"Basketball - NBA","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_basketball_ncaa_men":{"description":"Basketball - NCAA Men's","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_basketball_ncaa_women":{"description":"Basketball - NCAA Women's","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_boxing":{"description":"Boxing - (All)","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_golf":{"description":"Golf - (All)","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_golf_masters":{"description":"Golf - Masters","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_golf_pga_championship":{"description":"Golf - PGA Championships","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_golf_pga_tour":{"description":"Golf - PGA Tours","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_golf_us_open":{"description":"Golf - US Open","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_horse_racing":{"description":"Horse Racing - (All)","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_horse_racing_belmont_stakes":{"description":"Horse Racing - Belmont Stakes","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_horse_racing_kentucky_derby":{"description":"Horse Racing - Kentucky Derby","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_horse_racing_preakness_stakes":{"description":"Horse Racing - Preakness Stakes","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_ice_hockey":{"description":"Ice Hockey - (All)","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_ice_hockey_nhl":{"description":"Ice Hockey - NHL","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_mma":{"description":"Mixed Martial Arts - (All)","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_mma_ufc":{"description":"Mixed Martial Arts - UFC","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_soccer":{"description":"Soccer - (All)","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_soccer_concacaf_champions_league":{"description":"Soccer - CONCACAF Champions League","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_soccer_concacaf_gold_cup":{"description":"Soccer - CONCACAF Gold Cup","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_soccer_copa_america_men":{"description":"Soccer - COPA America Men's","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_soccer_fifa_world_cup_women":{"description":"Soccer - FIFA World Cup Women's","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_soccer_fifa_world_cup_men":{"description":"Soccer - FIFA World Cup Men's","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_soccer_mls":{"description":"Soccer - MLS","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_soccer_uefa_champions_league_men":{"description":"Soccer - UEFA Champions League Men's","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_softball":{"description":"Softball - (All)","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_softball_ncaa_women":{"description":"Softball - NCAA Women's","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_tennis":{"description":"Tennis - (All)","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_tennis_us_open":{"description":"Tennis - US Open","$ref":"#/components/schemas/StatsField"},"phq_viewership_sports_tennis_wimbledon":{"description":"Tennis - Wimbledon","$ref":"#/components/schemas/StatsField"},"phq_spend_conferences":{"description":"Conferences","$ref":"#/components/schemas/StatsField"},"phq_spend_expos":{"description":"Expos","$ref":"#/components/schemas/StatsField"},"phq_spend_sports":{"description":"Sports","$ref":"#/components/schemas/StatsField"},"phq_spend_community":{"description":"Community","$ref":"#/components/schemas/StatsField"},"phq_spend_concerts":{"description":"Concerts","$ref":"#/components/schemas/StatsField"},"phq_spend_festivals":{"description":"Festivals","$ref":"#/components/schemas/StatsField"},"phq_spend_performing_arts":{"description":"Performing Arts","$ref":"#/components/schemas/StatsField"},"phq_spend_conferences_accommodation":{"description":"Conferences - Accommodation","$ref":"#/components/schemas/StatsField"},"phq_spend_expos_accommodation":{"description":"Expos - Accommodation","$ref":"#/components/schemas/StatsField"},"phq_spend_sports_accommodation":{"description":"Sports - Accommodation","$ref":"#/components/schemas/StatsField"},"phq_spend_community_accommodation":{"description":"Community - Accommodation","$ref":"#/components/schemas/StatsField"},"phq_spend_concerts_accommodation":{"description":"Concerts - Accommodation","$ref":"#/components/schemas/StatsField"},"phq_spend_festivals_accommodation":{"description":"Festivals - Accommodation","$ref":"#/components/schemas/StatsField"},"phq_spend_performing_arts_accommodation":{"description":"Performing Arts - Accommodation","$ref":"#/components/schemas/StatsField"},"phq_spend_conferences_hospitality":{"description":"Conferences - Hospitality","$ref":"#/components/schemas/StatsField"},"phq_spend_expos_hospitality":{"description":"Expos - Hospitality","$ref":"#/components/schemas/StatsField"},"phq_spend_sports_hospitality":{"description":"Sports - Hospitality","$ref":"#/components/schemas/StatsField"},"phq_spend_community_hospitality":{"description":"Community - Hospitality","$ref":"#/components/schemas/StatsField"},"phq_spend_concerts_hospitality":{"description":"Concerts - Hospitality","$ref":"#/components/schemas/StatsField"},"phq_spend_festivals_hospitality":{"description":"Festivals - Hospitality","$ref":"#/components/schemas/StatsField"},"phq_spend_performing_arts_hospitality":{"description":"Performing Arts - Hospitality","$ref":"#/components/schemas/StatsField"},"phq_spend_conferences_transportation":{"description":"Conferences - Transportation","$ref":"#/components/schemas/StatsField"},"phq_spend_expos_transportation":{"description":"Expos - Transportation","$ref":"#/components/schemas/StatsField"},"phq_spend_sports_transportation":{"description":"Sports - Transportation","$ref":"#/components/schemas/StatsField"},"phq_spend_community_transportation":{"description":"Community - Transportation","$ref":"#/components/schemas/StatsField"},"phq_spend_concerts_transportation":{"description":"Concerts - Transportation","$ref":"#/components/schemas/StatsField"},"phq_spend_festivals_transportation":{"description":"Festivals - Transportation","$ref":"#/components/schemas/StatsField"},"phq_spend_performing_arts_transportation":{"description":"Performing Arts - Transportation","$ref":"#/components/schemas/StatsField"}},"required":["active"],"title":"FeaturesRequestModel"},"ActiveDateRange":{"type":"object","properties":{"gt":{"type":"string","format":"date","title":"Gt"},"gte":{"type":"string","format":"date","title":"Gte"},"lt":{"type":"string","format":"date","title":"Lt"},"lte":{"type":"string","format":"date","title":"Lte"}},"title":"ActiveDateRange"},"Beam":{"type":"object","properties":{"analysis_id":{"description":"Beam analysis ID","type":"string","minLength":1,"title":"Analysis Id"},"group_id":{"description":"Beam analysis group ID","type":"string","minLength":1,"title":"Group Id"}},"required":["analysis_id"],"title":"Beam"},"HourOfDayRange":{"type":"object","properties":{"gt":{"type":"integer","exclusiveMaximum":23,"minimum":0,"title":"Gt"},"gte":{"type":"integer","maximum":23,"minimum":0,"title":"Gte"},"lt":{"type":"integer","exclusiveMinimum":0,"maximum":23,"title":"Lt"},"lte":{"type":"integer","maximum":23,"minimum":0,"title":"Lte"}},"title":"HourOfDayRange"},"Location":{"type":"object","properties":{"place_id":{"description":"Place IDs to aggregate across","type":"array","items":{"type":"integer"},"title":"Place Id"},"geo":{"$ref":"#/components/schemas/GeoDistancePoint"},"saved_location_id":{"description":"Saved location IDs to aggregate across","type":"array","items":{"type":"string"},"title":"Saved Location Id"}},"title":"Location"},"GeoDistancePoint":{"type":"object","properties":{"lon":{"description":"Longitude float value for geo-point","type":"number","title":"Lon"},"lat":{"description":"Latitude float value for geo-point","type":"number","title":"Lat"},"radius":{"description":"Radius value for defining the bounds from geo-point","type":"string","title":"Radius"}},"required":["lon","lat"],"title":"GeoDistancePoint"},"Interval":{"type":"string","default":"day","enum":["day","week"],"title":"Interval"},"Weekday":{"type":"string","default":"monday","enum":["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],"title":"Weekday"},"PredictedEvents":{"type":"object","properties":{"exclude":{"description":"Exclude predicted events","type":"boolean","default":false,"title":"Exclude"}},"title":"PredictedEvents"},"StatsField":{"anyOf":[{"type":"boolean"},{"$ref":"#/components/schemas/PhqStatisticsFeatureCriteria"}]},"PhqStatisticsFeatureCriteria":{"type":"object","properties":{"stats":{"description":"Selection of statistics to process","type":"array","items":{"type":"string","enum":["avg","count","max","median","min","sum","std_dev"],"title":"StatsFieldTypes"},"default":["sum","count"],"maxItems":7,"title":"Stats"},"phq_rank":{"description":"PHQ Rank range filter","type":"object","properties":{"gt":{"type":"integer","exclusiveMaximum":100,"minimum":0,"title":"Gt"},"gte":{"type":"integer","maximum":100,"minimum":0,"title":"Gte"},"lt":{"type":"integer","exclusiveMinimum":0,"maximum":100,"title":"Lt"},"lte":{"type":"integer","maximum":100,"minimum":0,"title":"Lte"}},"title":"RankRange"},"local_rank":{"description":"Local Rank range filter","type":"object","properties":{"gt":{"type":"integer","exclusiveMaximum":100,"minimum":0,"title":"Gt"},"gte":{"type":"integer","maximum":100,"minimum":0,"title":"Gte"},"lt":{"type":"integer","exclusiveMinimum":0,"maximum":100,"title":"Lt"},"lte":{"type":"integer","maximum":100,"minimum":0,"title":"Lte"}},"title":"RankRange"}},"title":"PhqStatisticsFeatureCriteria"},"PhqFeaturesResponse":{"type":"object","properties":{"results":{"type":"array","items":{"$ref":"#/components/schemas/PhqFeatureSet"},"title":"Results"},"count":{"description":"Total number of results","type":"integer"},"next":{"description":"URL to next page","anyof":[{"type":"string"},{"type":"null"}]},"previous":{"description":"URL to previous page","anyof":[{"type":"string"},{"type":"null"}]}},"required":["results"],"title":"PhqFeaturesResponse"},"PhqFeatureSet":{"type":"object","properties":{"date":{"description":"Date in local time.\n\n\nE.g. `2023-10-01`","type":"string","format":"date","title":"Date"},"phq_attendance_academic_graduation":{"$ref":"#/components/schemas/PhqAttendanceFeature"},"phq_attendance_academic_social":{"$ref":"#/components/schemas/PhqAttendanceFeature"},"phq_attendance_community":{"$ref":"#/components/schemas/PhqAttendanceFeature"},"phq_attendance_concerts":{"$ref":"#/components/schemas/PhqAttendanceFeature"},"phq_attendance_conferences":{"$ref":"#/components/schemas/PhqAttendanceFeature"},"phq_attendance_expos":{"$ref":"#/components/schemas/PhqAttendanceFeature"},"phq_attendance_festivals":{"$ref":"#/components/schemas/PhqAttendanceFeature"},"phq_attendance_performing_arts":{"$ref":"#/components/schemas/PhqAttendanceFeature"},"phq_attendance_sports":{"$ref":"#/components/schemas/PhqAttendanceFeature"},"phq_attendance_school_holidays":{"$ref":"#/components/schemas/PhqAttendanceFeature"},"phq_rank_daylight_savings":{"$ref":"#/components/schemas/PhqRankFeature"},"phq_rank_health_warnings":{"$ref":"#/components/schemas/PhqRankFeature"},"phq_rank_observances":{"$ref":"#/components/schemas/PhqRankFeature"},"phq_rank_public_holidays":{"$ref":"#/components/schemas/PhqRankFeature"},"phq_rank_school_holidays":{"$ref":"#/components/schemas/PhqRankFeature"},"phq_rank_politics":{"$ref":"#/components/schemas/PhqRankFeature"},"phq_rank_academic_session":{"$ref":"#/components/schemas/PhqRankFeature"},"phq_rank_academic_exam":{"$ref":"#/components/schemas/PhqRankFeature"},"phq_rank_academic_holiday":{"$ref":"#/components/schemas/PhqRankFeature"},"phq_viewership_sports_american_football":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_auto_racing":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_baseball":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_basketball":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_boxing":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_golf":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_horse_racing":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_ice_hockey":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_mma":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_soccer":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_softball":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_tennis":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_american_football_ncaa":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_american_football_nfl":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_auto_racing_nascar":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_auto_racing_indy_car":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_baseball_ncaa":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_baseball_mlb":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_basketball_ncaa":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_basketball_nba":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_basketball_ncaa_women":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_golf_masters":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_golf_pga_championship":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_golf_us_open":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_golf_pga_tour":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_horse_racing_kentucky_derby":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_horse_racing_preakness_stakes":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_horse_racing_belmont_stakes":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_ice_hockey_nhl":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_mma_ufc":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_soccer_mls":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_soccer_fifa_world_cup_women":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_soccer_fifa_world_cup":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_soccer_uefa_champions_league":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_soccer_concacaf_champions_league":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_soccer_concacaf_gold_cup":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_soccer_copa_america":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_softball_ncaa_women":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_tennis_wimbledon":{"$ref":"#/components/schemas/PhqViewershipFeature"},"phq_viewership_sports_tennis_us_open":{"$ref":"#/components/schemas/PhqViewershipFeature"}},"required":["date"],"title":"PhqFeatureSet"},"PhqAttendanceFeature":{"type":"object","properties":{"stats":{"$ref":"#/components/schemas/FeatureStats"}},"required":["stats"],"title":"PhqAttendanceFeature"},"FeatureStats":{"type":"object","properties":{"count":{"type":"integer","title":"Count"},"sum":{"type":"integer","title":"Sum"},"min":{"type":"integer","title":"Min"},"max":{"type":"integer","title":"Max"},"avg":{"type":"integer","title":"Avg"},"median":{"type":"integer","title":"Median"},"std_dev":{"type":"integer","title":"Std Dev"}},"title":"FeatureStats"},"PhqRankFeature":{"type":"object","properties":{"rank_levels":{"$ref":"#/components/schemas/RankStats"}},"required":["rank_levels"],"title":"PhqRankFeature"},"RankStats":{"type":"object","properties":{"1":{"type":"integer","default":0,"title":"1"},"2":{"type":"integer","default":0,"title":"2"},"3":{"type":"integer","default":0,"title":"3"},"4":{"type":"integer","default":0,"title":"4"},"5":{"type":"integer","default":0,"title":"5"}},"title":"RankStats"},"PhqViewershipFeature":{"type":"object","properties":{"stats":{"$ref":"#/components/schemas/FeatureStats"}},"required":["stats"],"title":"PhqViewershipFeature"},"HTTPValidationError":{"type":"object","properties":{"detail":{"type":"array","items":{"$ref":"#/components/schemas/ValidationError"},"title":"Detail"}},"title":"HTTPValidationError"},"ValidationError":{"type":"object","properties":{"loc":{"type":"array","items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"required":["loc","msg","type"],"title":"ValidationError"}}},"paths":{"/v1/features/":{"post":{"operationId":"obtain_features_given_criteria_features__post","summary":"Get ML Features","parameters":[{"$ref":"#/components/parameters/OffsetParam"},{"$ref":"#/components/parameters/LimitParam"},{"name":"accept","in":"header","description":"Receive results in JSON or CSV by specifying the appropriate Accept header.\n            Supported values:\n\n            - application/json\n\n            - text/csv","required":false,"schema":{"type":"string","default":"application/json","enum":["application/json","text/csv"],"title":"Accept"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FeaturesRequestModel"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PhqFeaturesResponse"}},"text/csv":{"schema":{"description":"CSV export of results","type":"string"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"tags":["Features API"]}}}}
````

## Available Features

{% tabs %}
{% tab title="PHQ Attendance Features" %}
PHQ Attendance features provide daily-level aggregated stats based on the number of people who we predict will attend events on a given day. This takes into account complications like distributing attendance across multi-day events.

{% hint style="success" %}
We recommend using impact pattern features instead of generic features if you are in one of the supported industries. See [#attended-events-impact-patterns](#attended-events-impact-patterns "mention").
{% endhint %}

**Attended Events Generic Features**

Use the generic features in this table if you are not in one of the industries covered by the impact pattern features listed below.

<table><thead><tr><th width="431">Feature</th><th>Description</th></tr></thead><tbody><tr><td><code>phq_attendance_academic_graduation</code></td><td>Academic - Graduation</td></tr><tr><td><code>phq_attendance_academic_social</code></td><td>Academic - Social</td></tr><tr><td><code>phq_attendance_community</code></td><td>Community</td></tr><tr><td><code>phq_attendance_concerts</code></td><td>Concerts</td></tr><tr><td><code>phq_attendance_conferences</code></td><td>Conferences</td></tr><tr><td><code>phq_attendance_expos</code></td><td>Expos</td></tr><tr><td><code>phq_attendance_festivals</code></td><td>Festivals</td></tr><tr><td><code>phq_attendance_performing_arts</code></td><td>Performing Arts</td></tr><tr><td><code>phq_attendance_sports</code></td><td>Sports</td></tr><tr><td><code>phq_attendance_school_holidays</code></td><td>School Holidays</td></tr></tbody></table>

**Attended Events Impact Pattern Features**

Predicted Impact Patterns model the impact of leading days (days before the event), lagging days (days after an event), and the days the event occurs. In the Features API, Impact Patterns are provided as different features with a feature per industry. We have impact pattern features for the accommodation, hospitality (which covers food & beverage including restaurants), and retail industries.

The features above are generic features and the features in the table below are the impact pattern features per industry. For example, if you were in the accommodation industry and wanted a feature for the conferences category you'd use `phq_attendance_conferences_accommodation`.

{% hint style="success" %}
We recommend using impact pattern features instead of generic features if you are in one of the supported industries. See [Predicted Impact Patterns](https://app.gitbook.com/s/tNhzHETmXsrWeVBndqqJ/getting-started/predicthq-data/impact-patterns)
{% endhint %}

<table><thead><tr><th width="462">Feature</th><th>Description</th></tr></thead><tbody><tr><td><code>phq_attendance_community_accommodation</code></td><td>Community accommodation impact</td></tr><tr><td><code>phq_attendance_concerts_accommodation</code></td><td>Concerts accommodation impact</td></tr><tr><td><code>phq_attendance_conferences_accommodation</code></td><td>Conferences accommodation impact</td></tr><tr><td><code>phq_attendance_expos_accommodation</code></td><td>Expos accommodation impact</td></tr><tr><td><code>phq_attendance_festivals_accommodation</code></td><td>Festivals accommodation impact</td></tr><tr><td><code>phq_attendance_performing_arts_accommodation</code></td><td>Performing Arts accommodation impact</td></tr><tr><td><code>phq_attendance_sports_accommodation</code></td><td>Sports accommodation impact</td></tr><tr><td><code>phq_attendance_community_hospitality</code></td><td>Community hospitality impact</td></tr><tr><td><code>phq_attendance_concerts_hospitality</code></td><td>Concerts hospitality impact</td></tr><tr><td><code>phq_attendance_conferences_hospitality</code></td><td>Conferences hospitality impact</td></tr><tr><td><code>phq_attendance_expos_hospitality</code></td><td>Expos hospitality impact</td></tr><tr><td><code>phq_attendance_festivals_hospitality</code></td><td>Festivals hospitality impact</td></tr><tr><td><code>phq_attendance_performing_arts_hospitality</code></td><td>Performing Arts hospitality impact</td></tr><tr><td><code>phq_attendance_sports_hospitality</code></td><td>Sports hospitality impact</td></tr><tr><td><code>phq_attendance_community_retail</code></td><td>Community Retail impact</td></tr><tr><td><code>phq_attendance_concerts_retail</code></td><td>Concerts Retail impact</td></tr><tr><td><code>phq_attendance_conferences_retail</code></td><td>Conferences Retail impact</td></tr><tr><td><code>phq_attendance_expos_retail</code></td><td>Expos Retail impact</td></tr><tr><td><code>phq_attendance_festivals_retail</code></td><td>Festivals Retail impact</td></tr><tr><td><code>phq_attendance_performing_arts_retail</code></td><td>Performing Arts Retail impact</td></tr><tr><td><code>phq_attendance_sports_retail</code></td><td>Sports Retail impact</td></tr></tbody></table>

**Configuration**

You can configure PHQ Attendance features using the options below.

<table><thead><tr><th width="184">Field</th><th>Description</th></tr></thead><tbody><tr><td><code>stats</code><br>object<br>optional</td><td><p>You can optionally configure which fields are calculated for each of these features by providing the list of <code>stats</code> fields you would like.</p><p>Default fields are <code>count</code> and <code>sum</code>.</p><p>Supported fields are:</p><ul><li><code>count</code></li><li><code>sum</code></li><li><code>min</code></li><li><code>max</code></li><li><code>avg</code></li><li><code>median</code></li><li><code>std_dev</code></li></ul><p>E.g.</p><pre class="language-json"><code class="lang-json">{
  "stats": [
    "count",
    "std_dev",
    "median"
  ]
}
</code></pre></td></tr><tr><td><code>phq_rank</code><br>object<br>optional</td><td><p>Filter for events with a PHQ Rank within a certain range.<br></p><p>Supports the following fields:</p><ul><li><code>gt</code> - greater than</li><li><code>gte</code> - greater than or equal</li><li><code>lt</code> - less than</li><li><code>lte</code> - less than or equal</li></ul><p>E.g.</p><pre class="language-json"><code class="lang-json">{
  "phq_rank": {
    "gt": 50,
    "lt": 80
  }
}
</code></pre></td></tr><tr><td><code>local_rank</code><br>object<br>optional</td><td><p>Filter for events with a Local Rank within a certain range.<br></p><p>Supports the following fields:</p><ul><li><code>gt</code> - greater than</li><li><code>gte</code> - greater than or equal</li><li><code>lt</code> - less than</li><li><code>lte</code> - less than or equal</li></ul><p>E.g.</p><pre class="language-json"><code class="lang-json">{
  "local_rank": {
    "gt": 50,
    "lt": 80
  }
}
</code></pre></td></tr></tbody></table>
{% endtab %}

{% tab title="PHQ Impact Features" %}
PHQ Impact features provide daily-level aggregated stats based on the predicted impact of an event. This takes into account complications like Impact Patterns (leading and lagging effects of an event).

**Holidays and Observances Impact Pattern Features**

These features include the Predicted Impact Patterns for public holidays and observances. For example, these features will show when people typically arrive and book accommodation before a holiday and if they tend to leave after the holiday. See [Predicted Impact Patterns](https://app.gitbook.com/s/tNhzHETmXsrWeVBndqqJ/getting-started/predicthq-data/impact-patterns)

{% hint style="success" %}
We recommend that if you operate in the industries listed below you use the demand impact features for holidays and observances instead of the generic features as these will result in greater forecast accuracy as they include the impact before an event starts and after it finishes.
{% endhint %}

<table><thead><tr><th width="375">Feature</th><th width="149">Category</th><th>Industry</th></tr></thead><tbody><tr><td><code>phq_impact_public_holidays</code></td><td>Public Holidays</td><td>N/A</td></tr><tr><td><code>phq_impact_public_holidays_accommodation</code></td><td>Public Holidays</td><td>Accomodation</td></tr><tr><td><code>phq_impact_public_holidays_hospitality</code></td><td>Public Holidays</td><td>Hospitality/Food &#x26; Beverage*</td></tr><tr><td><code>phq_impact_public_holidays_retail</code></td><td>Public Holidays</td><td>Retail</td></tr><tr><td><code>phq_impact_observances</code></td><td>Observances</td><td>N/A</td></tr><tr><td><code>phq_impact_observances_accommodation</code></td><td>Observances</td><td>Accomodation</td></tr><tr><td><code>phq_impact_observances_retail</code></td><td>Observances</td><td>Retail</td></tr><tr><td><code>phq_impact_observances_hospitality</code></td><td>Observances</td><td>Hospitality/Food &#x26; Beverage</td></tr><tr><td><code>phq_impact_school_holidays</code></td><td>School Holidays</td><td>N/A</td></tr><tr><td><code>phq_impact_school_holidays_retail</code></td><td>School Holidays</td><td>Retail</td></tr><tr><td><code>phq_impact_academic_exam</code></td><td>Academic</td><td>N/A</td></tr><tr><td><code>phq_impact_academic_holiday</code></td><td>Academic</td><td>N/A</td></tr><tr><td><code>phq_impact_academic_session</code></td><td>Academic</td><td>N/A</td></tr></tbody></table>

**Severe Weather Impact Features**

Currently supported industries are: Retail.

<table><thead><tr><th width="560">Feature</th><th width="352">Description</th><th>Industry</th></tr></thead><tbody><tr><td><code>phq_impact_severe_weather_air_quality_retail</code></td><td>Severe Weather - Air Quality</td><td>Retail</td></tr><tr><td><code>phq_impact_severe_weather_blizzard_retail</code></td><td>Severe Weather - Blizzard</td><td>Retail</td></tr><tr><td><code>phq_impact_severe_weather_cold_wave_retail</code></td><td>Severe Weather - Cold Wave - (All)</td><td>Retail</td></tr><tr><td><code>phq_impact_severe_weather_cold_wave_snow_retail</code></td><td>Severe Weather - Cold Wave - Snow</td><td>Retail</td></tr><tr><td><code>phq_impact_severe_weather_cold_wave_storm_retail</code></td><td>Severe Weather - Cold Wave - Storm</td><td>Retail</td></tr><tr><td><code>phq_impact_severe_weather_dust_retail</code></td><td>Severe Weather - Dust - (All)</td><td>Retail</td></tr><tr><td><code>phq_impact_severe_weather_dust_storm_retail</code></td><td>Severe Weather - Dust - Storm</td><td>Retail</td></tr><tr><td><code>phq_impact_severe_weather_flood_retail</code></td><td>Severe Weather - Flood</td><td>Retail</td></tr><tr><td><code>phq_impact_severe_weather_heat_wave_retail</code></td><td>Severe Weather - Heat Wave</td><td>Retail</td></tr><tr><td><code>phq_impact_severe_weather_hurricane_retail</code></td><td>Severe Weather - Hurricane</td><td>Retail</td></tr><tr><td><code>phq_impact_severe_weather_thunderstorm_retail</code></td><td>Severe Weather - Thunderstorm</td><td>Retail</td></tr><tr><td><code>phq_impact_severe_weather_tornado_retail</code></td><td>Severe Weather - Tornado</td><td>Retail</td></tr><tr><td><code>phq_impact_severe_weather_tropical_storm_retail</code></td><td>Severe Weather - Tropical Storm</td><td>Retail</td></tr></tbody></table>

**Attended Events Impact Features**

See [#attended-events-impact-pattern-features](#attended-events-impact-pattern-features "mention")

**Configuration**

You can configure PHQ Impact features using the options below.

<table><thead><tr><th width="184">Field</th><th>Description</th></tr></thead><tbody><tr><td><code>stats</code><br>object<br>optional</td><td><p>You can optionally configure which fields are calculated for each of these features by providing the list of <code>stats</code> fields you would like.</p><p>Default fields are <code>count</code> and <code>sum</code>.</p><p>Supported fields are:</p><ul><li><code>count</code></li><li><code>sum</code></li><li><code>min</code></li><li><code>max</code></li><li><code>avg</code></li><li><code>median</code></li><li><code>std_dev</code></li></ul><p>E.g.</p><pre class="language-json"><code class="lang-json">{
  "stats": [
    "count",
    "std_dev",
    "median"
  ]
}
</code></pre></td></tr><tr><td><code>phq_rank</code><br>object<br>optional</td><td><p>Filter for events with a PHQ Rank within a certain range.<br></p><p>Supports the following fields:</p><ul><li><code>gt</code> - greater than</li><li><code>gte</code> - greater than or equal</li><li><code>lt</code> - less than</li><li><code>lte</code> - less than or equal</li></ul><p>E.g.</p><pre class="language-json"><code class="lang-json">{
  "phq_rank": {
    "gt": 50,
    "lt": 80
  }
}
</code></pre></td></tr><tr><td><code>local_rank</code><br>object<br>optional</td><td><p>Filter for events with a Local Rank within a certain range.<br></p><p>Supports the following fields:</p><ul><li><code>gt</code> - greater than</li><li><code>gte</code> - greater than or equal</li><li><code>lt</code> - less than</li><li><code>lte</code> - less than or equal</li></ul><p>E.g.</p><pre class="language-json"><code class="lang-json">{
  "local_rank": {
    "gt": 50,
    "lt": 80
  }
</code></pre></td></tr></tbody></table>
{% endtab %}

{% tab title="PHQ Spend Features" %}
PHQ Spend features provide daily-level aggregated stats based on total USD we predict will be spent during events on a given day. This takes into account complications like distributing attendance across multi-day events.

You can request industry-specific features which are tuned to one of three potential industries:

* Accommodation: Event spend relating to hotels and hosts for the purposes of staying at during events. Spend can extend before and after an event actually starts/ends.
* Hospitality: Event spend on restaurants, food and drinks. Hotel restaurants are included in this industry.
* Transportation: Ground-based transportation for the purposes of getting to and from an event. Includes public and private transport, such as taxis, rails, busses and rideshares.

<table><thead><tr><th width="440">Feature</th><th>Description</th></tr></thead><tbody><tr><td><code>phq_spend_conferences</code></td><td>Conferences</td></tr><tr><td><code>phq_spend_expos</code></td><td>Expos</td></tr><tr><td><code>phq_spend_sports</code></td><td>Sports</td></tr><tr><td><code>phq_spend_community</code></td><td>Community</td></tr><tr><td><code>phq_spend_concerts</code></td><td>Concerts</td></tr><tr><td><code>phq_spend_festivals</code></td><td>Festivals</td></tr><tr><td><code>phq_spend_performing_arts</code></td><td>Performing Arts</td></tr><tr><td><code>phq_spend_conferences_accommodation</code></td><td>Conferences - Accommodation</td></tr><tr><td><code>phq_spend_expos_accommodation</code></td><td>Expos - Accommodation</td></tr><tr><td><code>phq_spend_sports_accommodation</code></td><td>Sports - Accommodation</td></tr><tr><td><code>phq_spend_community_accommodation</code></td><td>Community - Accommodation</td></tr><tr><td><code>phq_spend_concerts_accommodation</code></td><td>Concerts - Accommodation</td></tr><tr><td><code>phq_spend_festivals_accommodation</code></td><td>Festivals - Accommodation</td></tr><tr><td><code>phq_spend_performing_arts_accommodation</code></td><td>Performing Arts - Accommodation</td></tr><tr><td><code>phq_spend_conferences_hospitality</code></td><td>Conferences - Hospitality</td></tr><tr><td><code>phq_spend_expos_hospitality</code></td><td>Expos - Hospitality</td></tr><tr><td><code>phq_spend_sports_hospitality</code></td><td>Sports - Hospitality</td></tr><tr><td><code>phq_spend_community_hospitality</code></td><td>Community - Hospitality</td></tr><tr><td><code>phq_spend_concerts_hospitality</code></td><td>Concerts - Hospitality</td></tr><tr><td><code>phq_spend_festivals_hospitality</code></td><td>Festivals - Hospitality</td></tr><tr><td><code>phq_spend_performing_arts_hospitality</code></td><td>Performing Arts - Hospitality</td></tr><tr><td><code>phq_spend_conferences_transportation</code></td><td>Conferences - Transportation</td></tr><tr><td><code>phq_spend_expos_transportation</code></td><td>Expos - Transportation</td></tr><tr><td><code>phq_spend_sports_transportation</code></td><td>Sports - Transportation</td></tr><tr><td><code>phq_spend_community_transportation</code></td><td>Community - Transportation</td></tr><tr><td><code>phq_spend_concerts_transportation</code></td><td>Concerts - Transportation</td></tr><tr><td><code>phq_spend_festivals_transportation</code></td><td>Festivals - Transportation</td></tr><tr><td><code>phq_spend_performing_arts_transportation</code></td><td>Performing Arts - Transportation</td></tr></tbody></table>

**Configuration**

You can configure PHQ Spend features using the options below.

<table><thead><tr><th width="184">Field</th><th>Description</th></tr></thead><tbody><tr><td><code>stats</code><br>object<br>optional</td><td><p>You can optionally configure which fields are calculated for each of these features by providing the list of <code>stats</code> fields you would like.</p><p>Default fields are <code>count</code> and <code>sum</code>.</p><p>Supported fields are:</p><ul><li><code>count</code></li><li><code>sum</code></li><li><code>min</code></li><li><code>max</code></li><li><code>avg</code></li><li><code>median</code></li><li><code>std_dev</code></li></ul><p>E.g.</p><pre class="language-json"><code class="lang-json">{
  "stats": [
    "count",
    "std_dev",
    "median"
  ]
}
</code></pre></td></tr><tr><td><code>phq_rank</code><br>object<br>optional</td><td><p>Filter for events with a PHQ Rank within a certain range.<br></p><p>Supports the following fields:</p><ul><li><code>gt</code> - greater than</li><li><code>gte</code> - greater than or equal</li><li><code>lt</code> - less than</li><li><code>lte</code> - less than or equal</li></ul><p>E.g.</p><pre class="language-json"><code class="lang-json">{
  "phq_rank": {
    "gt": 50,
    "lt": 80
  }
}
</code></pre></td></tr><tr><td><code>local_rank</code><br>object<br>optional</td><td><p>Filter for events with a Local Rank within a certain range.<br></p><p>Supports the following fields:</p><ul><li><code>gt</code> - greater than</li><li><code>gte</code> - greater than or equal</li><li><code>lt</code> - less than</li><li><code>lte</code> - less than or equal</li></ul><p>E.g.</p><pre class="language-json"><code class="lang-json">{
  "local_rank": {
    "gt": 50,
    "lt": 80
  }
}
</code></pre></td></tr></tbody></table>
{% endtab %}

{% tab title="PHQ Viewership Features" %}
PHQ Viewership features provide daily-level aggregated stats based on the number of people who we predict will view broadcasts on a given day.

<table><thead><tr><th width="596">Feature</th><th width="385">Description</th></tr></thead><tbody><tr><td><code>phq_viewership_sports</code></td><td>Sports - (All)</td></tr><tr><td><code>phq_viewership_sports_american_football</code></td><td>American Football - (All)</td></tr><tr><td><code>phq_viewership_sports_american_football_ncaa_men</code></td><td>American Footbal - NCAA Men's</td></tr><tr><td><code>phq_viewership_sports_american_football_nfl</code></td><td>American Football - NFL</td></tr><tr><td><code>phq_viewership_sports_auto_racing</code></td><td>Automotive Racing - All</td></tr><tr><td><code>phq_viewership_sports_auto_racing_indy_car</code></td><td>Automotive Racing - Indy Car</td></tr><tr><td><code>phq_viewership_sports_auto_racing_nascar</code></td><td>Automotive Racing - NASCAR</td></tr><tr><td><code>phq_viewership_sports_baseball</code></td><td>Baseball - (All)</td></tr><tr><td><code>phq_viewership_sports_baseball_mlb</code></td><td>Baseball - MLB</td></tr><tr><td><code>phq_viewership_sports_baseball_ncaa_men</code></td><td>Baseball - NCAA Men's</td></tr><tr><td><code>phq_viewership_sports_basketball</code></td><td>Basketball - (All)</td></tr><tr><td><code>phq_viewership_sports_basketball_nba</code></td><td>Basketball - NBA</td></tr><tr><td><code>phq_viewership_sports_basketball_ncaa_men</code></td><td>Basketball - NCAA Men's</td></tr><tr><td><code>phq_viewership_sports_basketball_ncaa_women</code></td><td>Basketball - NCAA Women's</td></tr><tr><td><code>phq_viewership_sports_boxing</code></td><td>Boxing - (All)</td></tr><tr><td><code>phq_viewership_sports_golf</code></td><td>Golf - (All)</td></tr><tr><td><code>phq_viewership_sports_golf_masters</code></td><td>Golf - Masters</td></tr><tr><td><code>phq_viewership_sports_golf_pga_championship</code></td><td>Golf - PGA Championships</td></tr><tr><td><code>phq_viewership_sports_golf_pga_tour</code></td><td>Golf - PGA Tours</td></tr><tr><td><code>phq_viewership_sports_golf_us_open</code></td><td>Golf - US Open</td></tr><tr><td><code>phq_viewership_sports_horse_racing</code></td><td>Horse Racing - (All)</td></tr><tr><td><code>phq_viewership_sports_horse_racing_belmont_stakes</code></td><td>Horse Racing - Belmont Stakes</td></tr><tr><td><code>phq_viewership_sports_horse_racing_kentucky_derby</code></td><td>Horse Racing - Kentucky Derby</td></tr><tr><td><code>phq_viewership_sports_horse_racing_preakness_stakes</code></td><td>Horse Racing - Preakness Stakes</td></tr><tr><td><code>phq_viewership_sports_ice_hockey</code></td><td>Ice Hockey - (All)</td></tr><tr><td><code>phq_viewership_sports_ice_hockey_nhl</code></td><td>Ice Hockey - NHL</td></tr><tr><td><code>phq_viewership_sports_mma</code></td><td>Mixed Martial Arts - (All)</td></tr><tr><td><code>phq_viewership_sports_mma_ufc</code></td><td>Mixed Martial Arts - UFC</td></tr><tr><td><code>phq_viewership_sports_soccer</code></td><td>Soccer - (All)</td></tr><tr><td><code>phq_viewership_sports_soccer_concacaf_champions_league</code></td><td>Soccer - CONCACAF Champions League</td></tr><tr><td><code>phq_viewership_sports_soccer_concacaf_gold_cup</code></td><td>Soccer - CONCACAF Gold Cup</td></tr><tr><td><code>phq_viewership_sports_soccer_copa_america_men</code></td><td>Soccer - COPA America Men's</td></tr><tr><td><code>phq_viewership_sports_soccer_fifa_world_cup_women</code></td><td>Soccer - FIFA World Cup Women's</td></tr><tr><td><code>phq_viewership_sports_soccer_fifa_world_cup_men</code></td><td>Soccer - FIFA World Cup Men's</td></tr><tr><td><code>phq_viewership_sports_soccer_mls</code></td><td>Soccer - MLS</td></tr><tr><td><code>phq_viewership_sports_soccer_uefa_champions_league_men</code></td><td>Soccer - UEFA Champions League Men's</td></tr><tr><td><code>phq_viewership_sports_softball</code></td><td>Softball - (All)</td></tr><tr><td><code>phq_viewership_sports_softball_ncaa_women</code></td><td>Softball - NCAA Women's</td></tr><tr><td><code>phq_viewership_sports_tennis</code></td><td>Tennis - (All)</td></tr><tr><td><code>phq_viewership_sports_tennis_us_open</code></td><td>Tennis - US Open</td></tr><tr><td><code>phq_viewership_sports_tennis_wimbledon</code></td><td>Tennis - Wimbledon</td></tr></tbody></table>

**Configuration**

You can configure PHQ Attendance features using the options below.

<table data-full-width="true"><thead><tr><th width="184">Field</th><th>Description</th></tr></thead><tbody><tr><td><code>stats</code><br>object<br>optional</td><td><p>You can optionally configure which fields are calculated for each of these features by providing the list of <code>stats</code> fields you would like.</p><p>Default fields are <code>count</code> and <code>sum</code>.</p><p>Supported fields are:</p><ul><li><code>count</code></li><li><code>sum</code></li><li><code>min</code></li><li><code>max</code></li><li><code>avg</code></li><li><code>median</code></li><li><code>std_dev</code></li></ul><p>E.g.</p><pre class="language-json"><code class="lang-json">{
  "stats": [
    "count",
    "std_dev",
    "median"
  ]
}
</code></pre></td></tr><tr><td><code>phq_rank</code><br>object<br>optional</td><td><p>Filter for events with a PHQ Rank within a certain range.<br></p><p>Supports the following fields:</p><ul><li><code>gt</code> - greater than</li><li><code>gte</code> - greater than or equal</li><li><code>lt</code> - less than</li><li><code>lte</code> - less than or equal</li></ul><p>E.g.</p><pre class="language-json"><code class="lang-json">{
  "phq_rank": {
    "gt": 50,
    "lt": 80
  }
}
</code></pre></td></tr><tr><td><code>local_rank</code><br>object<br>optiona</td><td><p>Filter for events with a Local Rank within a certain range.<br></p><p>Supports the following fields:</p><ul><li><code>gt</code> - greater than</li><li><code>gte</code> - greater than or equal</li><li><code>lt</code> - less than</li><li><code>lte</code> - less than or equal</li></ul><p>E.g.</p><pre class="language-json"><code class="lang-json">{
  "local_rank": {
    "gt": 50,
    "lt": 80
  }
}
</code></pre></td></tr></tbody></table>
{% endtab %}

{% tab title="PHQ Rank Features" %}
PHQ Rank features provide the daily-level aggregated sum of events bucketed by PHQ Rank level (1-5).

**PHQ Rank Impact Pattern Features**

See the "Holidays and Observances Impact Pattern Features" under PHQ Impact in the tab above. These features cover the Accommodation, Retail, and Hospitality (Food & Beverage) industries.

{% hint style="success" %}
We recommend that if you operate in the supported industries you use the demand impact features for holidays and observances instead of the generic features as these will result in greater forecast accuracy as they include the impact before an event starts and after it finishes.
{% endhint %}

**PHQ Rank Generic Features**

These are generic features that do not include Predicted Impact Patterns and should be used if you are *not* in one of the industries that we have impact patterns for.

<table><thead><tr><th width="369">Feature</th><th>Description</th></tr></thead><tbody><tr><td><code>phq_rank_observances</code></td><td>Observances</td></tr><tr><td><code>phq_rank_public_holidays</code></td><td>Public Holidays</td></tr><tr><td><code>phq_rank_school_holidays</code></td><td>School Holidays</td></tr><tr><td><code>phq_rank_academic_session</code></td><td>Academic - Session</td></tr><tr><td><code>phq_rank_academic_exam</code></td><td>Academic - Exam</td></tr><tr><td><code>phq_rank_academic_holiday</code></td><td>Academic - Holiday</td></tr><tr><td><code>phq_rank_daylight_savings</code></td><td>Daylight savings</td></tr><tr><td><code>phq_rank_health_warnings</code></td><td>Health Warnings</td></tr><tr><td><code>phq_rank_politics</code></td><td>Politics</td></tr></tbody></table>

**Configuration**

PHQ Rank features cannot currently be configured further. When requesting `phq_rank_*` features set the value as `true` indicating you require the default calculations.
{% endtab %}
{% endtabs %}

## Feature Response Fields

Other than the date, the structure of each result here will depend on how you configured the feature in your request and the type of feature.

{% tabs %}
{% tab title="PHQ Attendance Features" %}

<table><thead><tr><th width="221">Field</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code><br>string</td><td>Date in local time.<br><br>E.g. <code>2023-10-01</code></td></tr><tr><td><code>&#x3C;phq_attendance_*></code><br>object</td><td><p>Daily-level feature result. The structure of the result here will depend on how you configured the feature in your request.</p><p>PHQ Attendance features are stats-based.</p><p>Default fields are <code>count</code> and <code>sum</code>.</p><p>E.g.</p><pre class="language-json"><code class="lang-json">{
  "stats": {
    "count": 5,
    "sum": 17307,
    "min": 1000,
    "max": 9215,
    "avg": 3461.4,
    "median": 2620.0,
    "std_dev": 2978.810473997968
  }
}
</code></pre></td></tr></tbody></table>
{% endtab %}

{% tab title="PHQ Impact Features" %}

<table><thead><tr><th width="235">Field</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code><br>string</td><td>Date in local time.<br><br>E.g. <code>2023-10-01</code></td></tr><tr><td><code>&#x3C;phq_impact_*></code><br>object</td><td><p>Daily-level feature result. The structure of the result here will depend on how you configured the feature in your request.</p><p>PHQ Impact features are stats-based.</p><p>Default fields are <code>count</code> and <code>sum</code>.</p><p>E.g.</p><pre class="language-json"><code class="lang-json">{
  "stats": {
    "count": 5,
    "sum": 17307,
    "min": 1000,
    "max": 9215,
    "avg": 3461.4,
    "median": 2620.0,
    "std_dev": 2978.810473997968
  }
}
</code></pre></td></tr></tbody></table>
{% endtab %}

{% tab title="PHQ Rank Features" %}

<table><thead><tr><th width="196">Field</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code><br>string</td><td>Date in local time.<br><br>E.g. <code>2023-10-01</code></td></tr><tr><td><code>&#x3C;phq_rank_*></code><br>object</td><td><p>Daily-level feature result. The structure of the result here is always the same as PHQ Rank features cannot currently be configured.</p><p>Will contain a <code>rank_levels</code> field which indicates the sum of matching events active on the date at each PHQ Rank level.</p><p>PHQ Rank is on a scale of 0 to 100 and the levels are bucketed as:</p><ul><li><code>1</code> - Minor (rank between 0 and 20).</li><li><code>2</code> - Moderate (rank between 21 and 40).</li><li><code>3</code> - Important (rank between 41 and 60).</li><li><code>4</code> - Significant (rank between 61 and 80).</li><li><code>5</code> - Major (rank between 81 and 100).</li></ul><p>E.g.</p><pre class="language-json"><code class="lang-json">{
  "rank_levels": {
    "1": 0,
    "2": 0,
    "3": 0,
    "4": 2,
    "5": 0
  }
}
</code></pre></td></tr></tbody></table>
{% endtab %}

{% tab title="PHQ Spend Features" %}

<table><thead><tr><th width="221">Field</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code><br>string</td><td>Date in local time.<br><br>E.g. <code>2023-10-01</code></td></tr><tr><td><code>&#x3C;phq_spend_*></code><br>object</td><td><p>Daily-level feature result. The structure of the result here will depend on how you configured the feature in your request.</p><p>PHQ Spend features are stats-based.</p><p>Default fields are <code>count</code> and <code>sum</code>.</p><p>E.g.</p><pre class="language-json"><code class="lang-json">{
  "stats": {
    "count": 5,
    "sum": 17307,
    "min": 1000,
    "max": 9215,
    "avg": 3461.4,
    "median": 2620.0,
    "std_dev": 2978.810473997968
  }
}
</code></pre></td></tr></tbody></table>
{% endtab %}

{% tab title="PHQ Viewership Features" %}

<table><thead><tr><th width="235">Field</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code><br>string</td><td>Date in local time.<br><br>E.g. <code>2023-10-01</code></td></tr><tr><td><code>&#x3C;phq_viewership_*></code><br>object</td><td><p>Daily-level feature result. The structure of the result here will depend on how you configured the feature in your request.</p><p>PHQ Viewership features are stats-based.</p><p>Default fields are <code>count</code> and <code>sum</code>.</p><p>E.g.</p><pre class="language-json"><code class="lang-json">{
  "stats": {
    "count": 5,
    "sum": 17307,
    "min": 1000,
    "max": 9215,
    "avg": 3461.4,
    "median": 2620.0,
    "std_dev": 2978.810473997968
  }
}
</code></pre></td></tr></tbody></table>
{% endtab %}
{% endtabs %}

## Examples

{% tabs %}
{% tab title="curl" %}

```bash
curl -X POST "https://api.predicthq.com/v1/features/?offset=0&limit=100" \
     -H "Accept: application/json" \
     -H "Authorization: Bearer $ACCESS_TOKEN" \
     --data @<(cat <<EOF
    {
        "active": {
            "gte": "2019-11-16",
            "lte": "2019-11-17"
        },
        "location": {
            "geo": {
                "lat": "37.78428",
                "lon": "-122.40075",
                "radius": "2.6mi"
            }
        },
        "phq_attendance_conferences": {
            "stats": [
                "min",
                "max"
            ]
        },
        "phq_attendance_sports": {
            "stats": ["count", "std_dev", "median"],
            "phq_rank": { 
                "gt": 50
            }    
        },
        "phq_attendance_concerts": true,
        "phq_rank_public_holidays": true
    }
    EOF
    )
```

{% endtab %}

{% tab title="python" %}

```python
import requests

data = {
    "active": {
        "gte": "2019-11-16",
        "lte": "2019-11-27"
    },
    "location": {
        "geo": {
            "lat": "37.78428",
            "lon": "-122.40075",
            "radius": "2.6mi"
        }
    },
    "phq_attendance_conferences": {
        "stats": [
            "min",
            "max"
        ]
    },
    "phq_attendance_sports": {
        "stats": ["count", "std_dev", "median"],
        "phq_rank": { 
            "gt": 50
        }    
    },
    "phq_attendance_concerts": True,
    "phq_rank_public_holidays": True
}

response = requests.post(
    url="https://api.predicthq.com/v1/features/",
    headers={
      "Authorization": "Bearer $ACCESS_TOKEN",
      "Accept": "application/json"
    },
    params={
      "offset": 0,
      "limit": 100
    },
    json=data
)

print(response.json())
```

{% endtab %}

{% tab title="python sdk" %}

```python
from predicthq import Client

phq = Client(access_token="$ACCESS_TOKEN")

for feature in phq.features.obtain_features(
        active__gte="2019-11-16",
        active__lte="2019-11-27",
        location__geo={
            "lat": "37.78428",
            "lon": "-122.40075",
            "radius": "2.6mi"
        },
        phq_attendance_conferences__stats=["min", "max"],
        phq_attendance_sports__stats=["count", "std_dev", "median"],
        phq_attendance_sports__phq_rank={
            "gt": 50
        },
        phq_attendance_concerts=True,
        phq_rank_public_holidays=True
):
    print(feature.date, feature.phq_attendance_conferences.stats.min, 
        feature.phq_attendance_conferences.stats.max,
        feature.phq_attendance_sports.stats.count,
        feature.phq_attendance_sports.stats.std_dev,
        feature.phq_attendance_sports.stats.median,
        feature.phq_attendance_concerts.stats.count,
        feature.phq_attendance_concerts.stats.sum,
        feature.phq_rank_public_holidays.rank_levels)
```

{% endtab %}
{% endtabs %}

## OpenAPI Spec

The OpenAPI spec for Features API can be [found here](https://api.predicthq.com/docs/?urls.primaryName=Features+API).

## Guides

Below are some guides relevant to this API:

* [Increase Accuracy with the Features API](https://app.gitbook.com/s/tNhzHETmXsrWeVBndqqJ/getting-started/guides/features-api-guides/increase-accuracy-with-the-features-api)
* [Get ML Features](https://app.gitbook.com/s/tNhzHETmXsrWeVBndqqJ/getting-started/guides/features-api-guides/feature-engineering-guide)
* [Demand Forecasting with Event Features](https://app.gitbook.com/s/tNhzHETmXsrWeVBndqqJ/getting-started/guides/features-api-guides/demand-forecasting-data-science-guides)
* [Aggregating Live TV Events](https://app.gitbook.com/s/tNhzHETmXsrWeVBndqqJ/getting-started/guides/live-tv-event-guides/aggregating-live-tv-events)
