You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Learn how to use the Create Python Model model in Azure Machine Learning to create custom modeling or data processing module.
4
+
description: Learn how to use the Create Python Model module in Azure Machine Learning to create a custom modeling or data processing module.
5
5
services: machine-learning
6
6
ms.service: machine-learning
7
7
ms.subservice: core
@@ -11,104 +11,106 @@ author: likebupt
11
11
ms.author: keli19
12
12
ms.date: 11/19/2019
13
13
---
14
-
# Create Python Model
14
+
# Create Python Model module
15
15
16
16
This article describes a module in Azure Machine Learning designer (preview).
17
17
18
-
Learn how to use the **Create Python Model** module to create an untrained model from a Python script. You can base the model on any learner that is included in a Python package in the Azure Machine Learning designer environment.
18
+
Learn how to use the Create Python Model module to create an untrained model from a Python script. You can base the model on any learner that's included in a Python package in the Azure Machine Learning designer environment.
19
19
20
-
After you create the model, you can use [Train Model](train-model.md) to train the model on a dataset, like any other learner in Azure Machine Learning. The trained model can be passed to [Score Model](score-model.md) to use the model to make predictions. The trained model can then be saved, and the scoring workflow can be published as a web service.
20
+
After you create the model, you can use [Train Model](train-model.md) to train the model on a dataset, like any other learner in Azure Machine Learning. The trained model can be passed to [Score Model](score-model.md) to make predictions. You can then save the trained model and publish the scoring workflow as a web service.
21
21
22
22
> [!WARNING]
23
-
> Currently it is not possible to pass the scored results of a Python model to [Evaluate Model](evaluate-model.md). If you need to evaluate a model, you can write custom Python script and run it using the [Execute Python Script](execute-python-script.md) module.
23
+
> Currently, it's not possible to pass the scored results of a Python model to [Evaluate Model](evaluate-model.md). If you need to evaluate a model, you can write a custom Python script and run it by using the [Execute Python Script](execute-python-script.md) module.
24
24
25
25
26
-
## How to configure Create Python Model
26
+
## Configure the module
27
27
28
-
Use of this module requires intermediate or expert knowledge of Python. The module supports use of any learner that is included in the Python packages already installed in Azure Machine Learning. See pre-installed Python package list in [Execute Python Script](execute-python-script.md).
28
+
Use of this module requires intermediate or expert knowledge of Python. The module supports use of any learner that's included in the Python packages already installed in Azure Machine Learning. See the preinstalled Python package list in [Execute Python Script](execute-python-script.md).
29
29
30
30
31
-
This article will show how to use the **Create Python Model** with a simple pipeline. Below is the graph of the pipeline.
31
+
This article shows how to use Create Python Model with a simple pipeline. Here's a diagram of the pipeline:

34
34
35
-
1. Click **Create Python Model**, edit the script to implement your modeling or data management process. You can base the model on any learner that is included in a Python package in the Azure Machine Learning environment.
35
+
1.Select **Create Python Model**, and edit the script to implement your modeling or data management process. You can base the model on any learner that's included in a Python package in the Azure Machine Learning environment.
36
36
37
+
The following sample code of the two-class Naive Bayes classifier uses the popular *sklearn* package:
37
38
38
-
Below is a sample code of two-class Naive Bayes classifier by using the popular *sklearn* package.
39
+
```Python
39
40
40
-
```Python
41
+
# The script MUST define a class named AzureMLModel.
42
+
# This class MUST at least define the following three methods:
43
+
# __init__: in which self.model must be assigned,
44
+
# train: which trains self.model, the two input arguments must be pandas DataFrame,
45
+
# predict: which generates prediction result, the input argument and the prediction result MUST be pandas DataFrame.
46
+
# The signatures (method names and argument names) of all these methods MUST be exactly the same as the following example.
41
47
42
-
# The script MUST define a class named AzureMLModel.
43
-
# This class MUST at least define the following three methods:
44
-
# __init__: in which self.model must be assigned,
45
-
# train: which trains self.model, the two input arguments must be pandas DataFrame,
46
-
# predict: which generates prediction result, the input argument and the prediction result MUST be pandas DataFrame.
47
-
# The signatures (method names and argument names) of all these methods MUST be exactly the same as the following example.
description: Learn how to use the Enter Data Manually module in Azure Machine Learning to create a small dataset by typing values. The dataset can have multiple columns.
5
5
services: machine-learning
@@ -15,84 +15,80 @@ ms.date: 02/22/2020
15
15
16
16
This article describes a module in Azure Machine Learning designer (preview).
17
17
18
-
Use this module to create a small dataset by typing values. The dataset can have multiple columns.
18
+
Use the Enter Data Manually module to create a small dataset by typing values. The dataset can have multiple columns.
19
19
20
-
This module can be helpful in scenarios such as these:
20
+
This module can be helpful in scenarios such as:
21
21
22
-
- Generating a small set of values for testing
23
-
24
-
- Creating a short list of labels
25
-
26
-
- Typing a list of column names to insert in a dataset
22
+
- Generating a small set of values for testing.
23
+
- Creating a short list of labels.
24
+
- Typing a list of column names to insert in a dataset.
27
25
28
-
## Enter Data Manually
29
-
30
-
1. Add the [Enter Data Manually](./enter-data-manually.md) module to your pipeline. You can find this module in the **Data Input and Output** category in Azure Machine Learning.
31
-
32
-
2. For **DataFormat**, select one of the following options. These options determine how the data that you provide should be parsed. The requirements for each format differ greatly, so be sure to read the related topics.
26
+
## Create a dataset
33
27
34
-
-**ARFF**: The attribute-relation file format, used by Weka.
28
+
1. Add the [Enter Data Manually](./enter-data-manually.md) module to your pipeline. You can find this module in the **Data Input and Output** category in Azure Machine Learning.
35
29
36
-
-**CSV**: Comma-separated values format. For more information, see [Convert to CSV](./convert-to-csv.md).
30
+
1. For **DataFormat**, select one of the following options. These options determine how the data that you provide should be parsed. The requirements for each format differ greatly, so be sure to read the related topics.
37
31
38
-
-**SVMLight**: A format used by Vowpal Wabbit and other machine learning frameworks.
39
-
40
-
-**TSV**: Tab-separated values format.
32
+
-**ARFF**: Attribute-relation file format used by Weka.
33
+
-**CSV**: Comma-separated values format. For more information, see [Convert to CSV](./convert-to-csv.md).
34
+
-**SVMLight**: Format used by Vowpal Wabbit and other machine learning frameworks.
35
+
-**TSV**: Tab-separated values format.
41
36
42
-
If you choose a format and do not provide data that meets the format specifications, a run-time error occurs.
37
+
If you choose a format and do not provide data that meets the format specifications, a runtime error occurs.
43
38
44
-
3. Click inside the **Data** text box to start entering data. The following formats require special attention:
39
+
1. Click inside the **Data** text box to start entering data. The following formats require special attention:
45
40
46
-
-**CSV**: To create multiple columns, paste in comma-separated text, or type multiple columns using commas between fields.
41
+
-**CSV**: To create multiple columns, paste in comma-separated text, or type multiple columns by using commas between fields.
47
42
48
-
If you select the **HasHeader** option, you can use the first row of values as the column heading.
43
+
If you select the **HasHeader** option, you can use the first row of values as the column heading.
49
44
50
-
If you deselect this option, the columns names, Col1, Col2, and so forth, are used. You can add or change columns names later using [Edit Metadata](./edit-metadata.md).
45
+
If you deselect this option, the column names (Col1, Col2, and so forth) are used. You can add or change columns names later by using [Edit Metadata](./edit-metadata.md).
51
46
52
-
-**TSV**: To create multiple columns, paste in tab-separated text, or type multiple columns using tabs between fields.
47
+
-**TSV**: To create multiple columns, paste in tab-separated text, or type multiple columns by using tabs between fields.
53
48
54
-
If you select the **HasHeader** option, you can use the first row of values as the column heading.
49
+
If you select the **HasHeader** option, you can use the first row of values as the column heading.
55
50
56
-
If you deselect this option, the columns names, Col1, Col2, and so forth, are used. You can add or change columns names later using [Edit Metadata](./edit-metadata.md).
51
+
If you deselect this option, the column names (Col1, Col2, and so forth) are used. You can add or change columns names later by using [Edit Metadata](./edit-metadata.md).
57
52
58
-
-**ARFF**: Paste in an existing ARFF format file. If you are typing values directly, be sure to add the optional header and required attribute fields at the beginning of the data.
59
-
60
-
For example, the following header and attribute rows could be added to a simple list. The column heading would be `SampleText`. Note that String type is not supported.
53
+
-**ARFF**: Paste in an existing ARFF format file. If you're typing values directly, be sure to add the optional header and required attribute fields at the beginning of the data.
54
+
55
+
For example, the following header and attribute rows can be added to a simple list. The column heading would be `SampleText`. Note that the String type is not supported.
61
56
62
-
```text
63
-
% Title: SampleText.ARFF
64
-
% Source: Enter Data module
65
-
@ATTRIBUTE SampleText NUMERIC
66
-
@DATA
67
-
\<type first data row here>
68
-
```
57
+
```text
58
+
% Title: SampleText.ARFF
59
+
% Source: Enter Data module
60
+
@ATTRIBUTE SampleText NUMERIC
61
+
@DATA
62
+
\<type first data row here>
63
+
```
69
64
70
-
- **SVMLight**: Type or paste in values using the SVMLight format.
65
+
- **SVMLight**: Type or paste in values by using the SVMLight format.
71
66
72
-
For example, the following sample represents the first couple lines of the Blood Donation dataset, in SVMight format:
67
+
For example, the following sample represents the first couple of lines of the Blood Donation dataset, in SVMLight format:
73
68
74
-
```text
75
-
# features are [Recency], [Frequency], [Monetary], [Time]
76
-
1 1:2 2:50 3:12500 4:98
77
-
1 1:0 2:13 3:3250 4:28
78
-
```
69
+
```text
70
+
# features are [Recency], [Frequency], [Monetary], [Time]
71
+
1 1:2 2:50 3:12500 4:98
72
+
1 1:0 2:13 3:3250 4:28
73
+
```
79
74
80
-
When you run the [Enter Data Manually](./enter-data-manually.md) module, these lines are converted to a dataset of columns and index values as follows:
75
+
When you run the [Enter Data Manually](./enter-data-manually.md) module, these lines are converted to a dataset of columns and index values as follows:
81
76
82
-
|Col1|Col2|Col3|Col4|Labels|
83
-
|-|-|-|-|-|
84
-
|0.00016|0.004|0.999961|0.00784|1|
85
-
|0|0.004|0.999955|0.008615|1|
77
+
|Col1|Col2|Col3|Col4|Labels|
78
+
|-|-|-|-|-|
79
+
|0.00016|0.004|0.999961|0.00784|1|
80
+
|0|0.004|0.999955|0.008615|1|
86
81
87
-
4. Press ENTER after each row, to start a new line.
82
+
1. Select the Enter key after each row, to start a new line.
88
83
89
-
If you press ENTER multiple times to add multiple empty trailing rows, the empty rows will be removed trimmed.
84
+
If you select Enter multiple times to add multiple empty trailing rows, the empty rows will be removed or trimmed.
90
85
91
-
If you create rows with missing values, you can always filter them out later.
86
+
If you create rows with missing values, you can always filter them out later.
92
87
93
-
5. Connect the output port to other modules, and run the pipeline.
88
+
1. Connect the output port to other modules, and run the pipeline.
94
89
95
-
To view the dataset, right-click the module and select **Visualize**.
90
+
To view the dataset, right-click the module and select **Visualize**.
91
+
96
92
## Next steps
97
93
98
94
See the [set of modules available](module-reference.md) to Azure Machine Learning.
0 commit comments