Share via

Model predictions

NAW123 16 Reputation points
2021-10-19T15:38:09.403+00:00

Hi,
I build a Bagged GLM model on azure studio with tons of data split 50/50 as training and testing input. Mow I am trying to deploy it as web service, it wont let me to input from the start point.

1) Where should I input a simple data to the model? Before the loop for bagging when I got a single request? Would the result same for fast requests/input?
beggin<-function(trainx,testx,length_divisor=4,iterations=100)
prediction<-foreach(m=1:iterations, .combine=rbind) %dopar% {
predict(glm,newdata=testx, na.action=na.omit)
}
data.set<-rowMeans(prediction)
2) Another model built using use r-script modules. Each time it predicts almost the same value using our algorithm not from the studio, the variation of the result was trivial to the .0xx

Thanks
N.A.W.

Azure Machine Learning
0 comments No comments

1 answer

Sort by: Most helpful
  1. YutongTie-9091 54,026 Reputation points Moderator
    2021-10-20T10:38:50.637+00:00

    Hello,

    After you creating your web service, you need to call it as below.

    I am giving Python as an example: https://learn.microsoft.com/en-us/azure/machine-learning/how-to-consume-web-service?tabs=python#call-the-service-python

    import requests  
    import json  
      
    # URL for the web service  
    scoring_uri = '<your web service URI>'  
    # If the service is authenticated, set the key or token  
    key = '<your key or token>'  
      
    # Two sets of data to score, so we get two results back  
    data = {"data":  
            [  
                [  
                    0.0199132141783263,  
                    0.0506801187398187,  
                    0.104808689473925,  
                    0.0700725447072635,  
                    -0.0359677812752396,  
                    -0.0266789028311707,  
                    -0.0249926566315915,  
                    -0.00259226199818282,  
                    0.00371173823343597,  
                    0.0403433716478807  
                ],  
                [  
                    -0.0127796318808497,  
                    -0.044641636506989,  
                    0.0606183944448076,  
                    0.0528581912385822,  
                    0.0479653430750293,  
                    0.0293746718291555,  
                    -0.0176293810234174,  
                    0.0343088588777263,  
                    0.0702112981933102,  
                    0.00720651632920303]  
            ]  
            }  
    # Convert to JSON string  
    input_data = json.dumps(data)  
      
    # Set the content type  
    headers = {'Content-Type': 'application/json'}  
    # If authentication is enabled, set the authorization header  
    headers['Authorization'] = f'Bearer {key}'  
      
    # Make the request and display the response  
    resp = requests.post(scoring_uri, input_data, headers=headers)  
    print(resp.text)  
    

    More information please refer to the documentation. Please let me know if you need more details.

    Regards,
    Yutong

    Was this answer helpful?


Your answer

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