> For the complete documentation index, see [llms.txt](https://docs.predicthq.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.predicthq.com/getting-started/data-science-notebooks.md).

# Data science notebooks

PredictHQ features exist to make forecasts more accurate. Adding event features to a demand forecasting model reduces forecast error in a way you can measure and attribute - and what a point of accuracy is worth is relative to your business: at enterprise scale, even a fraction of a percent less forecast error can mean millions of dollars in better staffing, inventory, and pricing decisions. These Jupyter notebooks show how to capture that lift in your own models: calibrating with Beam, retrieving model-ready features, and training and forecasting with them.

If you're new, work through the forecasting workflow notebooks in order - they follow the recommended path: Beam identifies which event categories drive demand at each location, the Features API turns them into model-ready signals, and your model (or the Forecasts API) does the rest. Before you backtest, read [Data Leakage in Backtesting](/getting-started/core-concepts/data-leakage-in-backtesting.md) so historical evaluation reflects what the model sees in production.

## The forecasting workflow

Work through these in order.

1. [**ML features by location with Beam**](https://github.com/predicthq/phq-data-science-docs/blob/master/demand-forecasting-with-events/identify-location-level-features-with-beam-api.ipynb) - run Beam per location and use Feature Importance to identify the relevant, forecast-ready features.
2. [**ML features by group with Beam Analysis Groups**](https://github.com/predicthq/phq-data-science-docs/blob/master/demand-forecasting-with-events/identify-group-level-features-with-beam-api.ipynb) - an aggregated feature set across several locations, for a single shared model.
3. [**Get features with the Features API**](https://github.com/predicthq/phq-data-science-docs/blob/master/demand-forecasting-with-events/get-features-with-features-api.ipynb) - retrieve model-ready features at scale, keyed by your Beam Analysis. If your data lives in Snowflake, the [Snowflake data science guide](/integrations/third-party-integrations/snowflake/snowflake-data-science-guide.md) covers building features there instead.
4. [**Demand forecasting with event features**](https://github.com/predicthq/phq-data-science-docs/blob/master/demand-forecasting-with-events/demand-forecasting-with-event-features.ipynb) - incorporate the features into a demand forecasting model. Self-contained: it can be run independently of the notebooks above.
5. [**Forecasts API**](https://github.com/predicthq/phq-data-science-docs/blob/master/forecasts-api/demand_forecasting_with_phq_forecasts_api.ipynb) - the managed alternative: train a model and get event-driven forecasts without building your own, with a baseline comparison to measure the lift.

## Exploring event categories

Per-category notebook series for exploring the data itself. Each series has three parts: data engineering (extract to a DataFrame), data exploration, and feature engineering.

### Attendance-based events

Conferences, expos, concerts, festivals, performing arts, sports, and community events - see [Attendance-based events](/getting-started/predicthq-data/event-categories/attendance-based-events.md) for the category reference.

* [Part 1: Data Engineering](https://github.com/predicthq/phq-data-science-docs/blob/master/attended-events/part_1_data_engineering.ipynb)
* [Part 2: Data Exploration](https://github.com/predicthq/phq-data-science-docs/blob/master/attended-events/part_2_data_exploration.ipynb)
* [Part 3: Feature Engineering](https://github.com/predicthq/phq-data-science-docs/blob/master/attended-events/part_3_feature_engineering.ipynb)

### Non-attendance-based events

Observances, public holidays, and school holidays - see [Non-Attendance-based events](/getting-started/predicthq-data/event-categories/non-attendance-based-events.md).

* [Part 1: Data Engineering](https://github.com/predicthq/phq-data-science-docs/blob/master/unattended-events/part_1_data_engineering.ipynb)
* [Part 2: Data Exploration](https://github.com/predicthq/phq-data-science-docs/blob/master/unattended-events/part_2_data_exploration.ipynb)
* [Part 3: Feature Engineering](https://github.com/predicthq/phq-data-science-docs/blob/master/unattended-events/part_3_feature_engineering.ipynb)

### Severe weather events

See [Severe Weather](/getting-started/predicthq-data/event-categories/unscheduled-events.md#severe-weather) for the category reference.

* [Part 1: Data Engineering](https://github.com/predicthq/phq-data-science-docs/blob/master/severe-weather-events/part_1_data_engineering.ipynb)
* [Part 2: Data Exploration](https://github.com/predicthq/phq-data-science-docs/blob/master/severe-weather-events/part_2_data_exploration.ipynb)
* [Part 3: Feature Engineering](https://github.com/predicthq/phq-data-science-docs/blob/master/severe-weather-events/part_3_feature_engineering.ipynb)

### Academic events

* [Part 1: Data Engineering](https://github.com/predicthq/phq-data-science-docs/blob/master/academic-events/part_1_data_engineering.ipynb)
* [Part 2: Data Exploration](https://github.com/predicthq/phq-data-science-docs/blob/master/academic-events/part_2_data_exploration.ipynb)
* [Part 3: Feature Engineering](https://github.com/predicthq/phq-data-science-docs/blob/master/academic-events/part_3_feature_engineering.ipynb)

### Live TV events

Broadcast sports viewership by county in the United States - see [Live TV events](/getting-started/predicthq-data/event-categories/live-tv-events.md).

* [Part 1: Data Engineering](https://github.com/predicthq/phq-data-science-docs/blob/master/live-tv-events/part_1_data_engineering.ipynb)
* [Part 2: Data Exploration](https://github.com/predicthq/phq-data-science-docs/blob/master/live-tv-events/part_2_data_exploration.ipynb)
* [Part 3: Feature Engineering](https://github.com/predicthq/phq-data-science-docs/blob/master/live-tv-events/part_3_feature_engineering.ipynb)

### Venues

Events are linked to the venues they occur at - stadiums, conference centers, concert halls - stored as [entities](/getting-started/predicthq-data/entities.md). A major venue near your location is often a key source of demand. The [venues notebook](https://github.com/predicthq/phq-data-science-docs/blob/master/venues/venues-example.ipynb) covers extracting venue information, mapping venues, event types by venue, and estimated capacities.

All our Data Science Notebooks can be found in our [GitHub repo](https://github.com/predicthq/phq-data-science-docs/tree/master).

For the concepts behind the workflow, see [Which API should I use?](/getting-started/core-concepts/which-api-should-i-use.md) Using a pre-trained forecasting model instead of training your own? See [Using event features with time series foundation models](/getting-started/guides/features-api-guides/using-event-features-with-time-series-foundation-models.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.predicthq.com/getting-started/data-science-notebooks.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
