title | titleSuffix | description | services | ms.service | ms.subservice | author | ms.author | ms.date | ms.topic | ms.custom |
---|---|---|---|---|---|---|---|---|---|---|
Transform data in the designer |
Azure Machine Learning |
Learn how to import and transform data in Azure Machine Learning designer to create your own datasets. |
machine-learning |
machine-learning |
mldata |
lgayhardt |
lagayhar |
10/21/2021 |
how-to |
designer |
In this article, you learn how to transform and save datasets in Azure Machine Learning designer so that you can prepare your own data for machine learning.
You will use the sample Adult Census Income Binary Classification dataset to prepare two datasets: one dataset that includes adult census information from only the United States and another dataset that includes census information from non-US adults.
In this article, you learn how to:
- Transform a dataset to prepare it for training.
- Export the resulting datasets to a datastore.
- View results.
This how-to is a prerequisite for the how to retrain designer models article. In that article, you will learn how to use the transformed datasets to train multiple models with pipeline parameters.
[!INCLUDE machine-learning-missing-ui]
In this section, you learn how to import the sample dataset and split the data into US and non-US datasets. For more information on how to import your own data into the designer, see how to import data.
Use the following steps to import the sample dataset.
-
Sign in to ml.azure.com, and select the workspace you want to work with.
-
Go to the designer. Select Easy-to-use-prebuild components to create a new pipeline.
-
Select a default compute target to run the pipeline.
-
To the left of the pipeline canvas is a palette of datasets and components. Select Datasets. Then view the Samples section.
-
Drag and drop the Adult Census Income Binary classification dataset onto the canvas.
-
Right-click the Adult Census Income dataset component, and select Visualize > Dataset output
-
Use the data preview window to explore the dataset. Take special note of the "native-country" column values.
In this section, you use the Split Data component to identify and split rows that contain "United-States" in the "native-country" column.
-
In the component palette to the left of the canvas, expand the Data Transformation section and find the Split Data component.
-
Drag the Split Data component onto the canvas, and drop the component below the dataset component.
-
Connect the dataset component to the Split Data component.
-
Select the Split Data component.
-
In the component details pane to the right of the canvas, set Splitting mode to Regular Expression.
-
Enter the Regular Expression:
\"native-country" United-States
.The Regular expression mode tests a single column for a value. For more information on the Split Data component, see the related algorithm component reference page.
Your pipeline should look like this:
:::image type="content" source="./media/how-to-designer-transform-data/split-data.png" alt-text="Screenshot showing how to configure the pipeline and the Split Data component":::
Now that your pipeline is set up to split the data, you need to specify where to persist the datasets. For this example, use the Export Data component to save your dataset to a datastore. For more information on datastores, see Connect to Azure storage services
-
In the component palette to the left of the canvas, expand the Data Input and Output section and find the Export Data component.
-
Drag and drop two Export Data components below the Split Data component.
-
Connect each output port of the Split Data component to a different Export Data component.
Your pipeline should look something like this:
-
Select the Export Data component that is connected to the left-most port of the Split Data component.
The order of the output ports matter for the Split Data component. The first output port contains the rows where the regular expression is true. In this case, the first port contains rows for US-based income, and the second port contains rows for non-US based income.
-
In the component details pane to the right of the canvas, set the following options:
Datastore type: Azure Blob Storage
Datastore: Select an existing datastore or select "New datastore" to create one now.
Path:
/data/us-income
File format: csv
[!NOTE] 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.
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 the
azureml
container in a new folder calleddata
. -
Select the Export Data component connected to the right-most port of the Split Data component.
-
In the component details pane to the right of the canvas, set the following options:
Datastore type: Azure Blob Storage
Datastore: Select the same datastore as above
Path:
/data/non-us-income
File format: csv
-
Confirm the Export Data component connected to the left port of the Split Data has the Path
/data/us-income
. -
Confirm the Export Data component connected to the right port has the Path
/data/non-us-income
.Your pipeline and settings should look like this:
Now that your pipeline is setup to split and export the data, submit a pipeline run.
-
At the top of the canvas, select Submit.
-
In the Set up pipeline run dialog, select Create new to create an experiment.
Experiments logically group together related pipeline runs. If you run this pipeline in the future, you should use the same experiment for logging and tracking purposes.
-
Provide a descriptive experiment name like "split-census-data".
-
Select Submit.
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 of the Split Data component to confirm that your data has been split correctly.
-
Select the Split Data component.
-
In the component details pane to the right of the canvas, select Outputs + logs.
-
Verify that the "native-country" column only contains the value "United-States".
-
Verify that the "native-country" column does not contain the value "United-States".
Skip this section if you want to continue on with part 2 of this how to, Retrain models with Azure Machine Learning designer.
[!INCLUDE aml-ui-cleanup]
In this article, you learned how to transform a dataset and save it to a registered datastore.
Continue to the next part of this how-to series with Retrain models with Azure Machine Learning designer to use your transformed datasets and pipeline parameters to train machine learning models.