當前位置: 首頁>>代碼示例>>Python>>正文


Python Yhat.raw_predict方法代碼示例

本文整理匯總了Python中yhat.Yhat.raw_predict方法的典型用法代碼示例。如果您正苦於以下問題:Python Yhat.raw_predict方法的具體用法?Python Yhat.raw_predict怎麽用?Python Yhat.raw_predict使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在yhat.Yhat的用法示例。


在下文中一共展示了Yhat.raw_predict方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1:

# 需要導入模塊: from yhat import Yhat [as 別名]
# 或者: from yhat.Yhat import raw_predict [as 別名]
    print "Uploading to yhat"
    upload_status = yh.upload(model_name,tweet_clf)
    model_version = upload_status['version'] 

    print "'%s':'%s' uploaded to yhat" % (model_name,model_version)

    # Sanity check uploaded classifier by comparing remote against local scores

    print "Preforming sanity check"
    print "Predicting local scores"
    local_sanity = tweet_clf.predict(tweet_clf.transform(sanity_raw))['scores']
    local_sanity = np.array(local_sanity)

    print "Getting scores from server"
    results_from_server = yh.raw_predict(model_name,model_version,sanity_raw)
    try:
        server_sanity = results_from_server['prediction']['scores']
    except:
        print results_from_server
        sys.exit(3)
    server_sanity = np.array(server_sanity)

    # Because of float point scores compare difference of scores to some level
    # of tolerance rather than checking equality
    score_diff = np.abs(local_sanity - server_sanity)

    sanity_tolerance = 1e-3
    sanity_status = np.alltrue(score_diff < sanity_tolerance)

    if not sanity_status:
開發者ID:2dpodcast,項目名稱:cloudy-tweets,代碼行數:32,代碼來源:upload.py

示例2: Exception

# 需要導入模塊: from yhat import Yhat [as 別名]
# 或者: from yhat.Yhat import raw_predict [as 別名]
    "k11": 1,
    "k12": 1,
    "k13": 1,
    "k14": 1,
    "k15": 1,
}

test_data = pd.read_csv(open("data/test.csv", "r"), quotechar='"')

sub_data = pd.read_csv(open("data/sampleSubmission.csv", "r"), quotechar='"')

if not np.alltrue(test_data["id"] == sub_data["id"]):
    raise Exception("IDs do not match")

yh = Yhat(username, apikey)

variabless = sub_data.columns[1:]
raw_tweets = test_data["tweet"].tolist()

for variable in variables:
    model_version = best_model[variable]
    model_name = "TweetClassifier_%s" % (variable,)
    results_from_server = yh.raw_predict(model_name, model_version, raw_tweets)
    pred = results_from_server["prediction"]["scores"]
    sub_data[variable] = pred

try:
    sub_data.to_csv(open(sub_file, "w"), index=False)
except IOError:
    sys.stderr.write("IO error: could not write data to file")
開發者ID:2dpodcast,項目名稱:cloudy-tweets,代碼行數:32,代碼來源:score.py

示例3: Yhat

# 需要導入模塊: from yhat import Yhat [as 別名]
# 或者: from yhat.Yhat import raw_predict [as 別名]
# <codecell>

yh = Yhat("YOUR USERNAME", "YOUR API KEY")

# <codecell>

print yh.upload("NamedEntityFindr", clf)

# <codecell>

[model for model in yh.show_models()['models'] if model['name'] == "NamedEntityFindr"]

# <codecell>

results_from_server = yh.raw_predict("NamedEntityFindr", 1, data)
results_from_server

# <codecell>

print 'sanity check.'
print 'results all match => %s' \
    % np.all(np.array(results['entities']) == np.array(results_from_server['prediction']['entities']))

# <markdowncell>

# <h2>Final Thoughts</h2>
# <ul>
#     <li><a href="http://nltk.googlecode.com/svn/trunk/doc/book/ch05.html" title="Categorizing and Tagging Words - NLTK docs" target="_blank">Categorizing and Tagging Words with NLTK</a> (NLTK docs)</li>
#     <li><a href="http://pixelmonkey.org/pub/nlp-training/" title="Just Enough NLP with Python" target="_blank">Just Enough NLP with Python</a> (slides)</li>
#     <li><a href="http://cdn.preterhuman.net/texts/science_and_technology/artificial_intelligence/Foundations%20of%20Statistical%20Natural%20Language%20Processing%20-%20Christopher%20D.%20Manning.pdf" title="Foundations of Statistical Natural Language Processing by Christopher Manning &amp; Hinrich Schiitze" target="_blank">Foundations of Statistical Natural Language Processing</a> by Christopher Manning &amp; Hinrich Schiitze (PDF)</li>
開發者ID:guruscott,項目名稱:yhat-client,代碼行數:32,代碼來源:Entity_Finder.py


注:本文中的yhat.Yhat.raw_predict方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。