Sagemaker, тестирование развернутой модели, когда невидимые данные находятся в формате CSV - PullRequest
0 голосов
/ 02 апреля 2020

Как проверить невидимые данные на развернутой модели?

Невидимые данные имеют около 20 функций и имеют формат csv.

В большинстве учебных пособий, которые я нахожу, используется анализ настроений или mov ie заголовков, чтобы продемонстрировать это, которое в основном состоит из одного предложения.

пример этого:

test_review = "Nothing but a disgusting materialistic pageant of glistening abed remote control greed zombies, totally devoid of any heart or heat. A romantic comedy that has zero romantic chemestry and zero laughs!"


test_words = review_to_words(test_review)
print(test_words)

def bow_encoding(words, vocabulary):
    bow = [0] * len(vocabulary) # Start by setting the count for each word in the vocabulary to zero.
    for word in words.split():  # For each word in the string
        if word in vocabulary:  # If the word is one that occurs in the vocabulary, increase its count.
            bow[vocabulary[word]] += 1
    return bow

test_bow = bow_encoding(test_words, vocabulary)
print(test_bow)


len(test_bow)

xgb_predictor = xgb.deploy(initial_instance_count = 1, instance_type = 'ml.m4.xlarge')


import boto3

runtime = boto3.Session().client('sagemaker-runtime')

xgb_predictor.endpoint

response = runtime.invoke_endpoint(EndpointName = xgb_predictor.endpoint
                                       ContentType = 'text/csv',                     
                                       Body = test_bow)

response = runtime.invoke_endpoint(EndpointName = xgb_predictor.endpoint, 
                                       ContentType = 'text/csv',                     
                                       Body = ','.join([str(val) for val in test_bow]).encode('utf-8'))

print(response)


response = response['Body'].read().decode('utf-8')
print(response)

Как бы я подошел к тестированию, когда данные, которые я хочу протестировать это больше, чем просто предложение и несколько функций?

спасибо

...