---
title: Segmented modeling
description: Describes segmented modeling for multiseries projects in DataRobot.

---

# Segmented modeling for multiseries {: #segmented-modeling-for-multiseries }

Complex and accurate demand forecasting typically requires deep statistical know-how and lengthy development projects around big data architectures. DataRobot's multiseries with segmented modeling automates this requirement by creating multiple projects&mdash;"under the hood." Once the segments are identified and built, they are merged to make a single-object&mdash;the Combined Model. This leads to improved model performance and decreased time to deployment.

When using segmented modeling, DataRobot creates a full project for each segment&mdash;running Autopilot (full or quick) then selecting (and preparing) a recommended model for deployment. (See the note on using segmented modeling in [Manual](#manual-mode-in-segmented-modeling) mode.) DataRobot also marks the recommended model as "segment champion," although you can [reassign the champion](#reassign-the-champion-model) at any time.

!!! note
	Although DataRobot creates a project for each segment, these projects are _not_ available from the [**Project Control Center**](manage-projects). Instead, they are investigated and managed from within the Combined Model, which _is_ available in the **Project Control Center**.

DataRobot incorporates each segment champion to create the _Combined Model_&mdash;a main umbrella project that acts as a collection point for all the segments. The result is a “one-model" deployment&mdash;the segmented project&mdash;while each segment has its own model running in the deployment behind the scenes.

![](images/ts-segmented-deploy.png)

It is important to remember that while segmented modeling solves some problems (model factories, multiple deployments), it cannot know which segments you care most about or which have the highest ROI. To be successful, you must correctly define the use case, set up the dataset, and define the segments.

See the [segmented modeling FAQ](segmented-faq) for more detailed information. See the [visual overview](segmented-qs) for a quick representation of why to use segmented modeling.

Modeling with segmentation is available for multiseries regression projects.

## Segmented modeling workflow {: #segmented-modeling-workflow }

Time series segmented modeling requires, first, defining segments that divide the dataset. To define segments, you can allow DataRobot to:

* Discover [clusters](#ts-clustering#use-cluster-models-from-the-model-registry) in your data and then use those clusters as segments.
* Assign segments for you based on the configured segment ID.

To build a segmented modeling project:

1. Follow the standard [time series workflow](ts-flow-overview)&mdash;set the target and turn on time-aware modeling. Choose **Automated time series forecasting** as the modeling method.

2. Enable multiseries modeling by [setting the series identifier](multiseries#set-the-series-id).

3. Set the segmentation method by clicking the pencil:

	![](images/ts-segment-2.png)

4. Set whether to enable segmented modeling:

	![](images/ts-segment-3.png)

	* Select _Yes, build models per segment_ to enable segmented modeling. When selected, you must also set how segments are defined.
	* Select _No, build models without segmenting_ to return to the previous **Time Series Forecasting** window. If you choose not to do segmented modeling, DataRobot builds one model for all detected series (regular [multiseries](multiseries)).

5. Set how segments are defined. The table below describes each option:

	![](images/ts-segment-18.png)

	Option | Description
	------ | -----------
	ID column | Select a column from the training dataset that DataRobot will use as the segment ID. Start to type a column name and see matching auto-complete selections or select from the identifiers that DataRobot identified. Segment ID must be different than series ID (see note below).
	Existing clustering model | Use a [clustering model previously saved](ts-clustering#use-cluster-models-from-the-model-registry) to the Model Registry.
	New clustering model | Start a new clustering project, with results later applied via the **Existing clustering model** option, by clicking **time series clustering** link in the help text.


	??? faq "What if I want to have one series per segment?"
	    The columns specified for segment ID and series ID cannot be the same; however, you can duplicate the series ID column and give it a new name. Then, set the segment ID to the new column name (using the **How are the segments defined** section). DataRobot will generate the segments using the series ID.

5. Once the method is selected&mdash;either the ID is set or an existing clustering model is selected&mdash;click **Set segmentation method**. The **Time Series Forecasting** window returns, where you can then [continue the configuration](ts-flow-overview)&mdash;training windows, duration, [KA](ts-adv-opt#set-known-in-advance-ka), and calendar selection&mdash;including changing the selected series and segment.

	??? faq "How are the training periods determined if clustering was used?"
	    When building a segmented model using [found clusters](ts-clustering) to split the dataset into the child projects (segments), DataRobot applies the training window settings from the clustering project to the segmented modeling project. This protects the holdout in segmented modeling and prevents data leakage from the clustering model when splitting the segmented dataset into child projects. Using the start and end dates of each series, the general scenarios that affect the methodology:


	    * If the series data contains the time window needed (as defined in the clustering project), DataRobot simply passes the series data along.
	    * _Series data before the clustering training end_: If there is a series that is shorter than the full training window and extends past holdout, DataRobot only uses data points before the clustering end that is the size of the training duration (only the portions that exist within the training boundary).
	    * _Series data has only data older in time than the clustering training end_: If there is a legacy series in which its data does not fall into the training window, DataRobot "slides back" and gathers data for the _duration_ of the training window so it can be used in segmentation and not lost.
	    * _Series data only exists "newer" in time than the clustering training end_: If a series only exists in holdout, DataRobot slides the window forward but does not select any data that was used in training. In this way, the data is not dropped, but it is only used for examining the holdout of a child project.

	![](images/ts-segment-4.png)

6. When the configuration is ready, select Quick or full Autopilot, or [Manual](#manual-mode-in-segmented-modeling) mode, and click **Start**. DataRobot prompts to remind you that because it builds a complete project for each segment, the time required to finish modeling could be quite long. Confirm you want to proceed by clicking **Start modeling**. (You can set DataRobot to proceed without approval for future segmented projects.)

7. After [EDA2](eda-explained#eda2) completes, DataRobot immediately creates the Combined Model. Because the "child" models (the independent segment models) are still building, the Combined Model is not complete. However, you can [control building and worker assignment](#worker-control) from the Combined Model.

	![](images/ts-segment-5.png)

8. When modeling completes, use the Combined Model to explore segments.

## Explore results {: #explore-results }

Once modeling has finished, the **Model** tab indicates that one model has built. (See the [note](#manual-mode-in-segmented-modeling) regarding outcome when using Manual mode.) This is the completed Combined Model.

![](images/ts-segment-7.png)

The charts and graphs available for segmented modeling are dependent on the model type:

* For the Combined Model, you can access the [**Segmentation**](#segmentation-tab), a model blueprint, the modeling log, **Make Predictions**, and **Comments**.

* For the models available in the individual segments, the visualizations and modeling tabs (Repository, Compare Models, etc.) appropriate to a multiseries regression project are available.  

### Segmentation tab {: #segmentation-tab }

Click to expand the Combined Model and expose the **Segmentation** tab.

![](images/ts-segment-8.png)

The following table describes components of the **Segmentation** tab:

Component | Description
--------- | -----------
Search | Use search to change the display so that it only includes segments that match the entered string.
Download CSV | Download a spreadsheet containing the metadata associated with the Combined Model project, including metric scores, champion history, IDs, and project history.
Segment | Lists the segment values, found in the training data by DataRobot, in the specified segment ID.
Rows | Displays segment statistics from the training data&mdash;the raw number of rows and the percentage of the dataset that those rows represent.
Total models | Indicates the number of models DataRobot built for that segment during the build process.
Champion last updated | Indicates the time and the responsible party for the last segment champion assignment. The entry also provides an [icon indicating the champion model type](leaderboard-ref#model-icons). Initially, all rows will list **by DataRobot**. Segments are listed by the "All backtests" scores; click the column header to re-sort.
Backtest 1 | Indicates the champion model's Backtest 1 score for the selected metric.
All backtests | Indicates the average score for all backtests run for the champion model.
Holdout | Provides an icon that indicates whether Holdout has been [unlocked](#unlock-holdout).

## Explore segments {: #explore-segments }

The Combined Model is comprised of one model per segment&mdash;the segment champion. The individual segments, on the other hand, comprise a complete project. You can investigate the project from the segment's Leaderboard and even deploy a segment model, independent of the Combined Model.

### Access a segment's Leaderboard {: #access-a-segments-leaderboard }

There are multiple ways to access a segment's Leaderboard.

#### From the Combined Model {: #from-the-combined-model }

Expand the Combined Model and click the segment name in the **Segmentation** tab list.

![](images/ts-segment-9.png)

Once clicked, the segment's Leaderboard opens. Notice that:

Indicator | Description
--------- | -----------
![](images/icon-1.png) | A full set of models has been built.
![](images/icon-2.png) | DataRobot has [recommended a model for deployment](model-rec-process) and marked a model as champion.
![](images/icon-3.png) | Regular Worker Queue controls are available.

![](images/ts-segment-10.png)

#### From the Segment dropdown {: #from-the-segment-dropdown }

Use the **Segment** dropdown to change your view.

![](images/ts-segment-11.png)

* From a segment:
       * Select an alternate segment. The segment's Leaderboard displays.
       * Select **View all segments** to return to the Combined Model.
* From the Combined Model, select a segment to open the segment's Leaderboard.

### Reassign the champion model {: #reassign-the-champion-model }

While DataRobot initially assigns a segment champion, you may want to change the designation. This could be the case, for example, if it were important to you that all segments provide the same model type to the Combined Model. Identify the segment champion from a segment's Leaderboard, where it is marked with the champion badge:

![](images/ts-segment-12.png)

To reassign the champion, from the segment Leaderboard, select the model you want as champion. Then, from the menu select **Leaderboard options > Mark model as champion**.

![](images/ts-segment-13.png)

The badge moves to the new model:

![](images/ts-segment-14.png)

And the Combined Model's **Segmentation** tab shows when the champion was last updated and who assigned the new champion.

## Control across projects {: #control-across-projects }

Because DataRobot treats each segment as an individual project, completing the Combined Model can take significantly longer than a regular multiseries project. The exact time is dependent on the number of segments and size of your dataset. You can use the controls described below to set workers (1) and to stop and start modeling (2). All actions are performed from the Worker Queue of the Combined Model and apply to all segment projects. You can also use it to [unlock Holdout](#global-holdout-unlock) (3).

![](images/ts-segment-6.png)


### Worker control {: #worker-control }

From the Combined Model, you can control the number of modeling workers across all segment projects. DataRobot automatically re-balances workers between segments, distributing available workers between running segments as each segment completes modeling. When changing the worker count, DataRobot ignores any projects not in the modeling stage.

### Pause/Start/Stop child modeling {: #pause-start-stop-child-modeling }

From the Worker Queue of the parent segmented project, you can control modeling actions of the child projects. Use the stop/start/cancel buttons in the sidebar, and the selected action is applied to all child projects simultaneously. Specifically:

- At the start of a segmented project, no queue actions are available.

- When all segments have reached the [EDA2](eda-explained#eda2) stage, the Pause and Start buttons become available.

- The Cancel button becomes available when child projects are in the modeling stage and have at least one job running.

### Unlock Holdout {: #unlock-holdout }

You can [unlock Holdout](unlocking-holdout) for an entire project or for each segment.

* To unlock the entire project&mdash;all models in all segments&mdash;choose **Unlock Holdout** from the Combined Model's Worker Queue.

* To unlock Holdout for all models in a segment, (open the segment's Leaderboard) and choose **Unlock project Holdout for all models** in the Worker Queue.

### Leaderboard model scores {: #leaderboard-model-scores }

Scores for the Combined Model are updated when a model completes building (champions are assigned in all segments). Scores are recalculated any time a segment's champion is replaced. For efficiency, it is calculated by aggregating individual champion scores. Metrics that support this method of calculation are: MAD, MAE, MAPE, MASE, RMSE, RMSLE, SMAPE, and Theil’s U.

When one or more champions are prepared for deployment, the scores shown reflect the parent scores. (The parent of the champion/recommended model is the model the champion is trained _from_.) 

??? tip "How are metric scores weighted based on number of series?"
	The evaluation metric for a combined model is an average based on the number of rows in a particular partition (training, validation, holdout). Because each segment can have a different number of series to predict, DataRobot weights the value to account for the model count for each series. In the case of MAE/MAD/MAPE/SMAPE, it is calculated as:

	`MAE_X = MAE1 * w_1 + MAE2 * w2 + ...`

	For RMSE/RMSLE, as:

	`RMSE_X = sqrt(RMSE_1**2 * w1 + RMSE_2**2 * w2 + ...)`

	MASE/Theil’s U are calculated using champion metrics and champion base metrics in two steps&mdash;calculate naive model scores in all segments, then calculate final combined model score.

	`naive_X = base_X / score_X`
	`SCORE = (base_1 + base_2 + ... ) / (naive_1 + naive_2 + ...)`

	The score weight for a segment is essentially the number of rows in a particular partition of the segment in relation to the total number of holdout rows in all segments. There are explicit tests for calculating score consistency. The score is calculated for the full dataset and then split into segments&mdash;scores are calculated individually for each segment and then combined and compared with the full dataset score.

When looking at the Combined Model on the Leaderboard, you may notice that the model has no score (only N/A), which indicates:

* The model is not yet complete.
* All backtests have not yet completed for one or more segment champions (the All Backtests score is N/A).
* The selected metric does not support score aggregation (for example, FVE Poisson, Gamma Deviance, etc.). For example:

	![](images/ts-segment-16.png)

	Change the metric to a supported metric, for example MAE, and an aggregated score from the Combined Model becomes available. 

To see the individual champion scores, expand the Combined Model to display the **Segmentation** tab.

![](images/ts-segment-17.png)

Individual champion scores are reported there. Note that:

* Both the Backtest 1 and All Backtests scores are N/A if the champion is not assigned.
* An asterisk indicates that the champion model has been [prepared for deployment](ts-date-time#recommended-time-series-models) (retrained as a start/end model into the most recent data) and thus the scores of it's parent model are used.

If you change the champion, DataRobot passes the scores from the new champion (or its parent) to the Combined Model.

## Manual mode in segmented modeling {: #manual-mode-in-segmented-modeling }

When using Manual mode with segmented modeling, DataRobot creates individual projects per segment and completes preparation _as far as the modeling stage_. However, DataRobot does not create per-project models. It does create the Combined Model (as a placeholder), but does not select a champion. Using Manual mode is a technique you can use to have full manual control over which models are trained in each segment and selected as champions, without taking the time to build the models.

## Deploy a Combined Model {: #deploy-a-combined-model }

To fully leverage the value of segmented modeling, you can deploy Combined Models like any other time series model. After selecting the champion model for each included project, you can deploy the Combined Model to create a "one-model" deployment for multiple segments; however, the individual segments in the deployed Combined Model still have their own segment champion models running in the deployment behind the scenes. Creating a deployment allows you to use [DataRobot MLOps](mlops/index) for accuracy monitoring, prediction intervals, challenger models, and retraining.
	
When segmented modeling completes, you can deploy the resulting Combined Model:

1. Once Autopilot has finished, the **Model** tab contains one model. This model is the completed Combined Model.

2. Click the **Combined Model**, and then click **Predict > Deploy**.

3. On the **Deploy** tab, click **Register to deploy**.

    ![](images/ts-segmented-deploy-2.png)

4. Configure the [model registration settings](dr-model-reg) and then click **Add to registry**. The model opens on the **Model Registry > Registered Models** tab.

5. While the registered model builds, click **Deploy** and then [configure the deployment settings](add-deploy-info).

    ![](images/register-combined-model-building.png)

6. Monitor, manage, and govern the deployed model in [DataRobot MLOps](mlops/index). Set up [retraining policies](set-up-auto-retraining) to maintain model performance post-deployment. 

### Combined Model deployment considerations {: #combined-model-deployment-considerations }

{% include 'includes/deploy-combined-model-include.md' %}


## Modify and clone a deployed Combined Model {: #modify-and-clone-a-deployed-model-combined-model }

After deploying a Combined Model, you can change the segment champion for a segment by cloning the deployed Combined Model and modifying the cloned model. This process is automatic and occurs when you attempt to change a segment's champion within a deployed Combined Model. The cloned model you can modify becomes the **Active Combined Model**. This process ensures stability in the deployed model while allowing you to test changes within the same segmented project.

!!! note
    Only one Combined Model on a project's Leaderboard can be the **Active Combined Model** (marked with a badge).

To modify and clone a deployed Combined Model, take the following steps:

1. Once a Combined Model is deployed, it is labeled **Prediction API Enabled**.

2. Click the active and deployed **Combined Model**, and then in the **Segments** tab, click the segment you want to modify.

   	![](images/ts-segmented-deploy-3.png)

3. [Reassign the segment champion](ts-segmented#reassign-the-champion-model).

4. In the dialog box that appears, click **Yes, create new combined model**.

   	![](images/ts-segmented-deploy-4.png)

5. On the project's **Leaderboard**, you can access and modify the **Active Combined Model**.

   	![](images/ts-segmented-deploy-5.png)

	!!! tip
		While the **Combined Model updated** notification is visible, you can click **Go to Combined Model** to return to the segment's Combined Model in the **Leaderboard**.

		![](images/ts-segmented-deploy-6.png)
