none
Time Series Json Example Help RRS feed

  • Question

  • I have deployed a model that was a regression and using postman have posted to the endpoint using the following Json and I get a response back which works.

    {
        "data": [
            {
                "abc": 100,
                "d45": 3424,
                "g45": 5746
            }
        ]
    }

    I have now deployed the same data into a time series model and deployed it. The time column is called "Week of" and the time value for the next future date would be 2019-11-15T00:00:00.000Z. The other columns are the same as the regression model above.

    Can anyone tell me what the json file should now be formated like to include the time series in it as well as I'm a little stuck here how to post to the endpoint and get a response as my json file is not correctly setup now its a time series...

    Thanks

    Mike

    Tuesday, November 26, 2019 5:28 PM

All replies

  • I should add I'm using AUTO ML
    Tuesday, November 26, 2019 5:30 PM
  • Hello Mike,

    While using the JSON with time series have you converted the datetime to string as timestamps cannot be serialized to string. Here is an example of using JSON with datetime and passed to a web service.

    import json
    # The request data frame needs to have y_query column which corresponds to query.
    X_query = X_test.copy()
    X_query['y_query'] = y_query
    # We have to convert datetime to string, because Timestamps cannot be serialized to JSON.
    X_query[time_column_name] = X_query[time_column_name].astype(str)
    # The Service object accept the complex dictionary, which is internally converted to JSON string.
    # The section 'data' contains the data frame in the form of dictionary.
    test_sample = json.dumps({'data': X_query.to_dict(orient='records')})
    response = aci_service.run(input_data = test_sample)
    # translate from networkese to datascientese
    try: 
        res_dict = json.loads(response)
        y_fcst_all = pd.DataFrame(res_dict['index'])
        y_fcst_all[time_column_name] = pd.to_datetime(y_fcst_all[time_column_name], unit = 'ms')
        y_fcst_all['forecast'] = res_dict['forecast']    
    except:
        print(res_dict)
    

    Here is a sample notebook that uses time series with JSON in the requests.

    -Rohit

    Wednesday, November 27, 2019 10:12 AM
    Moderator
  • Hi Rohit

    Thanks for your reply. Still a little confused. Looking at an Azure demo I used the below but get the following error: If using all scalar values, you must pass an index

    Based on your example how would yours translate from my sample below?

    { "timestamp": "2019-11-15T00:00:00.000Z", "data": { "abc": 100,         "d45": 3424,
    "g45": 5746 } }


    Thanks

    Michael

    Wednesday, November 27, 2019 10:54 AM