|
| 1 | +--- |
| 2 | +title: Transform data |
| 3 | +titleSuffix: Azure Machine Learning |
| 4 | +description: Learn how to transform data in Azure Machine Learning designer to create your own datasets. |
| 5 | +services: machine-learning |
| 6 | +ms.service: machine-learning |
| 7 | +ms.subservice: core |
| 8 | +ms.topic: how-to |
| 9 | + |
| 10 | +author: peterclu |
| 11 | +ms.author: peterlu |
| 12 | +ms.date: 05/04/2020 |
| 13 | +--- |
| 14 | + |
| 15 | +# Transform data in Azure Machine Learning designer (preview) |
| 16 | +[!INCLUDE [applies-to-skus](../../includes/aml-applies-to-enterprise-sku.md)] |
| 17 | + |
| 18 | +In this article, you will learn how to transform and save datasets in the designer so that you can prepare your own data for machine learning. Use the provided [Adult Census Income Binary Classification dataset](sample-designer-datasets.md) to prepare two datasets: one dataset that includes adult census information from only the United States and another dataset that only includes census information from non-US adults. |
| 19 | + |
| 20 | +In this article, you learn how to: |
| 21 | + |
| 22 | +1. Transform a dataset to prepare it for training. |
| 23 | +1. Export the resulting datasets to a datastore. |
| 24 | + |
| 25 | +This how-to is a prerequisite for the [how to retrain designer models](how-to-retrain-designer.md) article. In that article, you will learn how to use the transformed datasets to train multiple models. |
| 26 | + |
| 27 | +## Transform a dataset |
| 28 | + |
| 29 | +In this section, you learn how to import the sample dataset and split the data into US and non-US datasets using the **Split Data** module. For this how to, use **Adult Census Income Binary classification** as your starting point. For more information on how to import your own data into the designer, see [how to import data](how-to-designer-import-data.md). |
| 30 | + |
| 31 | +### Import data |
| 32 | + |
| 33 | +Use the following steps to import the sample dataset. |
| 34 | + |
| 35 | +1. Sign in to <a href="https://ml.azure.com?tabs=jre" target="_blank">ml.azure.com</a>, and select the workspace you want to work with. |
| 36 | + |
| 37 | +1. Go to the designer and create a new pipeline by selecting **Easy-to-use prebuilt modules**. |
| 38 | + |
| 39 | +1. Select a default compute target to run the pipeline. |
| 40 | + |
| 41 | +1. To the left of the pipeline canvas is a palette of datasets and modules. Select **Datasets**, and then view the **Samples** section. |
| 42 | + |
| 43 | +1. Drag and drop the **Adult Census Income Binary classification** dataset onto the canvas. |
| 44 | + |
| 45 | +1. Select the **Adult Census Income** dataset module. |
| 46 | + |
| 47 | +1. In the details pane that appears to the right of the canvas, select **Outputs**. Then select the visualize icon . |
| 48 | + |
| 49 | +1. Use the data preview window to explore the dataset. Take note of the "native-country" column values. |
| 50 | + |
| 51 | +### Split the data |
| 52 | + |
| 53 | +In this section, you use the [Split Data module](algorithm-module-reference/split-data.md) to identify rows that contain "United-States" in the "native-country" column. |
| 54 | + |
| 55 | +1. In the module palette to the left of the canvas, expand the **Data Transformation** section and find the **Split Data** module. |
| 56 | + |
| 57 | +1. Drag the **Split Data** module onto the canvas, and drop the module below the dataset module. |
| 58 | + |
| 59 | +1. Connect the **Adult Census Income Binary classification** dataset to the **Split Data** module. |
| 60 | + |
| 61 | +1. Select the **Split Data** module. |
| 62 | + |
| 63 | +1. In the module details pane to the right of the canvas, set **Splitting mode** to **Regular Expression**. |
| 64 | + |
| 65 | +1. Enter the **Regular Expression**: `\"native-country" United-States`. |
| 66 | + |
| 67 | + The **Regular expression** mode tests a single column for a value. For more information on the Split Data module, see the related [algorithm reference page](algorithm-module-reference/split-data.md). |
| 68 | + |
| 69 | +Your pipeline should look like this: |
| 70 | + |
| 71 | +. |
| 72 | + |
| 73 | + |
| 74 | +## Save the datasets |
| 75 | + |
| 76 | +Now that your pipeline is set up to split the data, you need to specify where to persist the datasets to access them later. For this example, use the **Export Data** module to save your dataset to a datastore. |
| 77 | + |
| 78 | +1. In the module palette to the left of the canvas, expand the **Data Input and Output** section and find the **Export Data** module. |
| 79 | + |
| 80 | +1. Drag and drop two **Export Data** modules below the **Split Data** module. |
| 81 | + |
| 82 | +1. Connect each output port of the **Split Data** module to a different **Export Data** module. |
| 83 | + |
| 84 | + Your pipeline should look something like this: |
| 85 | + |
| 86 | + . |
| 87 | + |
| 88 | +1. Select the **Export Data** module connected to the *left*-most port of the **Split Data** module. |
| 89 | + |
| 90 | + The order of the output ports matter. The first output port (left) contains the rows where the Split Data regular expression is true. In this case, the first port contains rows for the US-based income, and the second port contains rows for the non-US based income. |
| 91 | + |
| 92 | +1. In the module details pane to the right of the canvas, set the following options: |
| 93 | + |
| 94 | + **Datastore type**: Azure Blob Storage |
| 95 | + |
| 96 | + **Datastore**: Select an existing datastore or select "New datastore" to create one now. |
| 97 | + |
| 98 | + **Path**: `/data/us-income` |
| 99 | + |
| 100 | + **File format**: csv |
| 101 | + |
| 102 | + > [!NOTE] |
| 103 | + > This article assumes that you have access to a datastore registered to the current Azure Machine Learning workspace. For instructions on how to setup a datastore, see [Connect to Azure storage services](how-to-access-data.md#azure-machine-learning-studio). |
| 104 | +
|
| 105 | + If you don't have a datastore, you can create one now. For example purposes, this article will save the datasets to the default blob storage account associated with the workspace. It will save the datasets into a new folder called `data`. |
| 106 | + |
| 107 | +1. Select the **Export Data** module connected to the *right*-most port of the **Split Data** module. |
| 108 | + |
| 109 | +1. In the module details pane to the right of the canvas, set the following options: |
| 110 | + |
| 111 | + **Datastore type**: Azure Blob Storage |
| 112 | + |
| 113 | + **Datastore**: Select an existing datastore or select "New datastore" to create one now. |
| 114 | + |
| 115 | + **Path**: `/data/non-us-income` |
| 116 | + |
| 117 | + **File format**: csv |
| 118 | + |
| 119 | +1. Confirm the **Export Data** module connected to the left port of the **Split Data** has the **Path** `/data/us-income`. |
| 120 | + |
| 121 | +1. Confirm the **Export Data** module connected to the right port has the **Path** `/data/non-us-income`. |
| 122 | + |
| 123 | + Your pipeline and settings should look like this: |
| 124 | + |
| 125 | + . |
| 126 | + |
| 127 | +1. At the top of the canvas, select **Submit** to submit the run. |
| 128 | + |
| 129 | +1. In the **Set up pipeline run** dialog, select **Create new**. |
| 130 | + |
| 131 | +1. Provide a descriptive experiment name like "split-census-data". |
| 132 | + |
| 133 | +1. Select **Submit**. |
| 134 | + |
| 135 | +### View results |
| 136 | + |
| 137 | +After the pipeline finishes running, you can view your results by navigating to your blob storage in the Azure portal. You can also view the intermediary results for the **Split Data** module to confirm that your data split correctly. |
| 138 | + |
| 139 | +1. Select the **Split Data** module. |
| 140 | + |
| 141 | +1. In the module details pane to the right of the canvas, select **Outputs + logs**. |
| 142 | + |
| 143 | +1. Select the visualize icon  next to **Results dataset1**. |
| 144 | + |
| 145 | +1. Verify that the "native-country" column only contains the value "United-States". |
| 146 | + |
| 147 | +1. Select the visualize icon  next to **Results dataset2**. |
| 148 | + |
| 149 | +1. Verify that the "native-country" column does not contain the value "United-States". |
| 150 | + |
| 151 | +## Clean up resources |
| 152 | + |
| 153 | +Skip this section if you want to continue on with part 2 of this how to, [Retrain models with Azure Machine Learning designer](how-to-retrain-designer.md). |
| 154 | + |
| 155 | +[!INCLUDE [aml-ui-cleanup](../../includes/aml-ui-cleanup.md)] |
| 156 | + |
| 157 | +## Next steps |
| 158 | + |
| 159 | +In this article, you learned how to transform a dataset and save it to a registered datastore. Continue on with [Retrain models with Azure Machine Learning designer](how-to-retrain-designer.md) to use your transformed datasets and pipeline parameters to train machine learning models. |
0 commit comments