AI-900: Exercise "Explore regression" - Error in Python code

28585744 0 Reputation points
2023-10-31T15:04:11.15+00:00

Hi,

You need to fix the Python code in the exercise below. The job will not run correctly and results in a syntax error.

AI-900:

https://learn.microsoft.com/en-us/training/modules/create-regression-model-azure-machine-learning-designer/6-exercise

Exercise:

https://microsoftlearning.github.io/AI-900-AIFundamentals/instructions/02a-create-regression-model.html

Error in step "Create and run an inference pipeline".

 ---------- Start of error message from Python interpreter ----------
      |        Got exception when invoking script: 'SyntaxError: 'return' outside function (user_script_7f52874cc1094c7a8e8534ef337933f3.py, line 8)'.
      |        ---------- End of error message from Python  interpreter  ----------")

Code from exercise: (With errors)

import pandas as pd

def azureml_main(dataframe1 = None, dataframe2 = None):

     scored_results = dataframe1[['Scored Labels']]
     scored_results.rename(columns={'Scored Labels':'predicted_price'},
                     inplace=True)
return scored_results

Correct code:





Azure | Azure Training
{count} votes

1 answer

Sort by: Most helpful
  1. Rakesh Gurram 15,700 Reputation points Microsoft External Staff Moderator
    2023-11-06T06:24:24.16+00:00

    Hi @28585744,

    Thanks for your patience! Following-up, post my discussion with our MS Learn team, this content will be retired soon. In the meantime, our content team updated the copy and paste in the instructions. There is also a note below the code that indicates what the expected copy and paste should look like. Hope this helps. 

    Exercise:

    https://microsoftlearning.github.io/AI-900-AIFundamentals/instructions/02a-create-regression-model.html

    User's image

    Please Accept the answer if it is helpful.

    Thank you.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.