# Clustering
URL: https://docs.datarobot.com/en/docs/classic-ui/modeling/time/ts-clustering.html

> Available for time series projects, clustering groups by similar series across a multiseries dataset for insights or to prepare for segmented modeling.

# Clustering

Time series clustering is an out of the box solution unique to DataRobot that enables you to easily identify and group similar series across a multiseries dataset. Instead of manually running a time series clustering technique outside the platform and then using the cluster assignments as a segmenting feature, this process is entirely contained within the time series workflow. You do not need to be familiar with advanced concepts like Dynamic Time Warping (DTW) or be code-savvy to use the clustering capability as DataRobot builds both DTW and Velocity clustering models (see the detailed descriptions [here](https://docs.datarobot.com/en/docs/reference/pred-ai-ref/ts-reference/clustering-algos.html)).

> [!NOTE] Note
> [Non-time-aware projects clustering](https://docs.datarobot.com/en/docs/classic-ui/modeling/special-workflows/unsupervised/clustering.html) is also available, although segmented modeling is not.

Example: You are predicting shoe sales across your North American stores. With clustering, DataRobot can automatically group all stores in San Francisco and Cleveland into one cluster because the sales profiles for these locations is the same.

Simply put, clustering is a mechanism for grouping the series together. Found clusters can then be used as input to time series [segmented modeling](https://docs.datarobot.com/en/docs/classic-ui/modeling/time/ts-segmented.html). (Additionally, clustering can be used to simply get a better understanding of data.) Without clustering, you define how to group the series together based on a configured segment ID. Clustering, on the other hand, automatically groups series together by looking at the data and determining which series look most similar. Once clusters are established, you can:

- Create a clustering model touse immediatelyas part of a segmented modeling workflow.
- Create a clustering model and save it to theModel Registry to use laterfor segmented modeling.

When you cluster, there is no target ("output") variable. DataRobot groups series together based on their similarity. However, you must think about the target variable you will use in segmented modeling. DataRobot recommends using the variable you plan to select as the target in your segmented modeling project as one of the input/clustering variables for clustering.

See also the [time series clustering considerations](https://docs.datarobot.com/en/docs/reference/pred-ai-ref/ts-reference/ts-consider.html#clustering-considerations).

## Cluster discovery

To allow DataRobot to discover clusters:

1. Upload data, clickNo target?, and selectClusters. Modeling Modedefaults to Comprehensive andOptimization Metricdefaults toSilhouette Score.
2. ClickSet up time-aware modelingand select the primary date/time feature. (Modeling mode switches from Comprehensive to Autopilot.)
3. Set the Series ID. DataRobot launches the time-aware clustering workflow—an unsupervised project with theClustersoption enabled.
4. Set the feature(s) you want to cluster on. Note that only the selected features will be available for modeling. DataRobot automatically adds the date/time feature and series ID. ClickSet Cluster features. InfoDataRobot does not use features created during thefeature derivation processwhen clustering.
5. (Optional) Change the number of clusters that DataRobot discovers. ClickClusteringin the help text to open the advanced optionsClusteringtab. If using Manual mode, you will have an option to set the number from the Repository. Deep dive: Clustering bufferA clustering model has a start and end timestamp. The difference between start and end is the clustering training duration. Any time after the end is considered the holdout buffer.If there is enough data available, DataRobot creates a clustering buffer that can be seen in thePartitioningsection of advanced options. The clustering buffer is a section of data that DataRobot calculates to represent what the holdout would be in a subsequent segmentation project. It then shifts the training data dates back to account for the holdout period, to prevent data leakage and to ensure that you are not training a clustering model into what will be the holdout partition in segmentation.To remove the buffer, toggleInclude clustering bufferto off.
6. ClickStartto begin Autopilot.

You can use the discovered clusters to explore—clusters can capture latent behavior that are not explicitly captured by a column in the dataset. Or, [continue the workflow](https://docs.datarobot.com/en/docs/classic-ui/modeling/time/ts-clustering.html#use-cluster-models-now) to use the clusters in a segmented modeling project or save the model to the Model Registry for [later use](https://docs.datarobot.com/en/docs/classic-ui/modeling/time/ts-clustering.html#use-cluster-models-from-the-model-registry).

## Use cluster models now

Once Autopilot completes, you can view the [Series Insights](https://docs.datarobot.com/en/docs/classic-ui/modeling/analyze-models/evaluate/series-insights-classic.html) tab   for cluster and series distribution information. To create a segmented modeling project that uses the newly found clusters to define the segments:

1. Select a model from the Leaderboard and clickPredict; the tab opens toUse for Segmentation. On this tab, you can:
2. Enter the target feature for the segmented modeling project in theWhat would you like the new project to predict?field:
3. ClickCreate project and save to Model Registry. To save the clustering model and create the project laterInstead of creating a segmentation project now, you can save the clustering model as a model package by selectingSave to Model Registry.Later you canbuild a segmented modeling project using the clustering model.
4. ClickGo to project. Your segmentation method is configured with the clustering model.
5. ClickStartto build your segmented model. At the prompt, confirm that you want to run a segmentation project. After modeling is complete, a Combined Model displays on the Leaderboard where you canexplore the resultsand themodel segments.

> [!TIP] Tip
> This procedure saves the time series clustering model as a model package. You can later [create new segmented modeling projects](https://docs.datarobot.com/en/docs/classic-ui/modeling/time/ts-clustering.html#use-cluster-models-from-the-model-registry) using the saved clustering model package.

## Use cluster models from the Model Registry

After you save a time series clustering model as a model package, you can use it in a new segmented modeling project.

> [!NOTE] Note
> When building segmented modeling project from a clustering project, you must use the same dataset that was used to generate clusters.

1. Use the standard workflow to set up atime series project:
2. Modify window settings as needed and click the pencil next toSegmentation method.
3. Confirm building models per segment. Then, choose to use anExisting clustering modeland click+ Browse model registryin the definitions section.
4. In the resulting popup window, select a time series clustering model package and clickSelect model package.
5. The package is now listed as part of the segmentation definition screen. DataRobot will use the training length window from the clustering project in the segmentation project to ensure the clusters used for the segmentation project were evaluated in the clustering project. ClickSet segmentation method.
6. ClickStartto build your segmented model. At the prompt, confirm that you want to run a segmentation project. After modeling is complete, a Combined Model displays on the Leaderboard. You canexplore the resultsand thesegment models.

---
