Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
in Azure by (45.3k points)

The same input is used in two cases, but the different result is returned from a python module.

here is the python script that returns the result to the web service:

import pandas as pd

import sys

  def get_segments(dataframe):


     segments = dataframe.loc[~dataframe['segment'].duplicated()]['segment']

     return segments

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

   df = dataframe1

   segments = get_segments(df)

   segmentCount =segments.size

   if (segmentCount > 0) :

      res = pd.DataFrame(columns=['segmentId','recommendation'],index=[range(segmentCount)])


    for seg in segments:

        d= df.query('segment ==["{}"]'.format(seg)).sort(['count'],ascending=[0])



        for index, x in d.iterrows():


            recommendation = recommendation + item + ','

        recommendation = recommendation[:-1] + ']'

        res['recommendation'][i]= recommendation



      res = pd.DataFrame(columns=[seg,pdver],index=[range(segmentCount)])

return res,

When in an experiment it returned the actual itemIds, when in webservice it returns some numbers, the purpose of this code is to pivot some table by segment column for the recommendation.

1 Answer

0 votes
by (16.8k points)
edited by

After the product team rolled out an update for this web service, my issue was being fixed with the categorical attributes in the "Execute Python Script", this issue basically was in an earlier stage of the flow and has nothing to do with the python code which you have mentioned.

Are you interested in learning Azure from basics! Here's the right video for you on Azure provided by Intellipaat:

Browse Categories