Skip to content

Latest commit

 

History

History
41 lines (34 loc) · 1.06 KB

aml-create-script-pi.md

File metadata and controls

41 lines (34 loc) · 1.06 KB
title description services author ms.service ms.author manager ms.custom ms.topic ms.date
include file
include file
machine-learning
sdgilley
machine-learning
sgilley
cgronlund
include file
include
07/27/2018

In the same directory as aml_config/config.json, create a script and name it pi.py.

Copy the following code into that script:

import random, math
from azureml.core import Run
 
run = Run.get_submitted_run()
 
pi_counter = 0
n_iter = 100000
run.log("Number of iterations",n_iter)
 
for i in range(1,n_iter):
    x = random.random()
    y = random.random()
    if x*x + y*y < 1.0:
        pi_counter += 1
    pi_value = 4.0*pi_counter / i
    if i%10000==0:
        error = math.pi-pi_value
        print(i, pi_value, error)
        run.log_row("Pi estimate",iteration=i,pi_value=pi_value)
        run.log_row("Error",iteration=i,error=error)

Notice the log_row calls at the end. After running this script, you will see these values in your workspace.