How To Consume Python Azure Machine Learning Service From C#
In this article, we'll acquire on step-by-step process to write python script in Notebook offered in the Azure Car Learning Studio. This will come handy when we want to piece of work on Car Learning Projects. This article is a part of the Azure Car Learning Serial.
- Azure Machine Learning - Create Workspace for Auto Learning
- Azure Machine Learning – Create Compute Instance and Compute Cluster
- Azure Car Learning - Writing Python Script in Notebook
- Azure Machine Learning - Model Training
Microsoft AI
Microsoft AI is a powerful framework that enables organizations, researchers, and non-profits to utilize AI technologies with its powerful framework which offers services and features across domains of Automobile Learning, Robotics, Data Scientific discipline, IoT, and many more. Learn more about Microsoft AI from this article.
Azure Auto Learning
The Azure Machine Learning enriches and consolidates the functionalities to back up model training and deployment which transitions from Machine Learning Studio. It provides tools for Machine Learning works for all skill levels, provides an open up and interoperable framework with support to unlike languages, and enables robust terminate-to-end MLOps. It as well supports Automatic Machine Learning. Read this article Auto ML to acquire more than about it.
So, where and how do we start if we desire to create and deploy a Machine Learning project? Azure Motorcar Learning provides all the tools through its portal to create the resources and set up the infrastructure that is needed for any kind of motorcar learning works.
Pre-requisite
Before nosotros start with the tutorial of this article, you showtime need to create Machine Learning Workspace in Azure and create compute case along with compute cluster. Follow up the Azure Motorcar Learning - Create Workspace for Machine Learning and Azure Automobile Learning – Create Compute Example and Compute Cluster respectively.
At present, every bit the in a higher place resources have been created, we can now focus on writing the Python script on Notebook in Azure.
Step one
Open up the Azure Machine Learning Studio.
Select the Notebooks from the left-hand side. Y'all'll run into the user listed there.
Step 2
Next, nether the Files, Click on the + Push and Select Create new folder.
Step 3
You'll be asked to name the new folder.
I'm naming learn-ml. You can follow it too. Side by side, Click on Create
Step 4
Now, under learn-ml, you'll see three … on the right-manus side. Click information technology and you'll be listed with the options.
Select, Create new folder again.
Step 5
We proper name this folder, src.
Click on Create and the new binder src will be created within acquire-ml.
Step 6
Now, on the correct-hand side, click the … option on src and select Create new file.
Step 7
At present, we'll exist provided with the details to fill upwardly for the file proper noun and file type.
The default pick will be .ipynb. This will exist for juypter notebook creation. Nosotros are instead writing a python script file instead.
For this, select .py under the file blazon.
Name your file as trial.py and then click on Create.
Step 8
Notification pops up with the confirmation of the file cosmos.
Footstep 9
Now, visit the file. You'll see the empty file every bit of now.
You can run into, the file is running under the compute instance, ojashshrestha11 that I created.
You'll sometimes exist asked to authenticate the Azure SDK. Click on the Authenticate button and once done y'all'll be shown with the confirmation.
Writing Python Script
Stride 10
Now, let united states of america write some code on the trial.py file.
# src/trial.py print("This is our starting time feel with ML Notebook in Azure")
Here, I've written simply a lawmaking to print the text, "This is our first experience with ML Notebook in Azure."
Step 11
At present, to run this, click on the Side by side icon on top which will save and run the lawmaking.
Pace 12
We are now directed to the final to print the output of the file.
You lot tin see this is running on the compute case we had created from the before article.
Step xiii
At present, let us close this terminal. Click on View Active Sessions to click the agile sessions.
Simply Click on the X button and you'll exist asked for confirmation to Cease the Process.
Footstep 14
Now, under the acquire-ml binder, permit's create another file and name it run-trial.py
Equally the file is successfully created, we are updated with a notification.
Writing Control Script
Footstep 15
Now, Copy & paste the post-obit code to the file.
# get-started/run-trial.py from azureml.core import Workspace, Experiment, Environment, ScriptRunConfig ws = Workspace.from_config() experiment = Experiment(workspace=ws, proper name='day1-experiment-try1') config = ScriptRunConfig(source_directory='./src', script='trial.py', compute_target='cpu-cluster') run = experiment.submit(config) aml_url = run.get_portal_url() impress(aml_url)
Here, we are creating the experiment day1-experiment-try1. This code will help run the script trial.py under the src folder using the cpu-cluster.
Here, I've named my cpu-cluster is named as ojashshrestha11 and then, I'll name the compute_target as that.
Step 16
Now, as we click on the salve and run button, the terminal will open up executing the script.
Yous tin can see the link of the experiment in the workspace in the terminal. Click on it.
Step 17
You can see the status of the experiment is Preparing.
As it is successfully run, click on refresh and we can run into the condition Completed. Hither, the initial run can take anywhere between five to 10 minutes equally the docker prototype is built in the deject with compute cluster existence resized and downloaded to the compute. Later on runs will exist run within thirty seconds.
Step 18
Now, Visit the Experiments and under the Outputs + Logs we can find azureml-logs. Open the file 70_driver_log.txt
This file consists of all the logs of the process. Information technology is extremely helpful when we need to debug remote runs in the cloud every bit we go deeper.
Stride nineteen
On line 16, we tin can encounter your printed output, "This is our starting time experience with ML Notebook in Azure".
This shows that our output tin also be viewed on the log which was successfully run. During error cases, we can detect out the reasons here which volition make information technology convenient for us to debug.
Deletion and Removal of Resources
Step 20
As we are washed using the resource, information technology is essential to shut downwardly the resources and even amend deletion of the resources for a lot of these services incur charges as they are running even if we are not using it. Hence, to relieve from information technology, it's better to delete all the resources created.
To perform this, we accept ii means. One is deleting each service in the Azure Machine Learning Studio and some other is simply deleting the resource group which consists of the workspace and other resources such equally Container Registry, Storage Account, Key Vault and Application Insight which was created in society to access all these ML Services to us.
Visit the Azure Portal and Click on Delete resource group selecting the resource group yous set up the workspace.
Conclusion
Thus, in this article, we learned in step-by-step process to run python scripts in Notebook using the Car Learning Studio in Azure. And then we explored writing a command script to run our trial.py on diverse compute resources every bit nosotros choose. We also then learned to explore the log of the processes. Hence, we learned to connect our Motorcar Learning workspace and write python scripts and even control scripts on it to create experiments and submit our code in Azure.
How To Consume Python Azure Machine Learning Service From C#,
Source: https://www.c-sharpcorner.com/article/azure-machine-learning-writing-python-script-in-notebook/
Posted by: changthatera1965.blogspot.com
0 Response to "How To Consume Python Azure Machine Learning Service From C#"
Post a Comment