当前位置: 首页>>代码示例>>Python>>正文


Python Yhat.deploy方法代码示例

本文整理汇总了Python中yhat.Yhat.deploy方法的典型用法代码示例。如果您正苦于以下问题:Python Yhat.deploy方法的具体用法?Python Yhat.deploy怎么用?Python Yhat.deploy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yhat.Yhat的用法示例。


在下文中一共展示了Yhat.deploy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: range

# 需要导入模块: from yhat import Yhat [as 别名]
# 或者: from yhat.Yhat import deploy [as 别名]
from yhat import Yhat, YhatModel , preprocess

x = range(10)
class HelloWorld(YhatModel):
    @preprocess(in_type=dict, out_type=dict)
    def execute(self, data):
        print x[:10]
        me = data['name']
        greeting = "Hello " + str(me) + "!"
        return { "greeting": greeting, "x": x}

# yh = Yhat("greg", "fCVZiLJhS95cnxOrsp5e2VSkk0GfypZqeRCntTD1nHA", "http://cloud.yhathq.com/")
yh = Yhat("greg", "9207b9a2dd9d48848b139b729d4354bc", "http://localhost:8080/")
yh.deploy("NewZippedModel", HelloWorld, globals())
开发者ID:barrosm,项目名称:yhat-client,代码行数:16,代码来源:test.py

示例2: HelloWorld

# 需要导入模块: from yhat import Yhat [as 别名]
# 或者: from yhat.Yhat import deploy [as 别名]
import os

from yhat import Yhat, YhatModel, preprocess
from foo.foo import print_foo
from module import function_in_same_dir

class HelloWorld(YhatModel):
    @preprocess(in_type=dict, out_type=dict)
    def execute(self, data):
        me = data['name']
        greeting = "Hello %s!" % me
        print_foo(me)
        return { "greeting": greeting, "nine": function_in_same_dir() }

username = os.environ["USERNAME"]
apikey = os.environ["APIKEY"]
endpoint = os.environ["OPS_ENDPOINT"]

print "%s:%s:%s" % (username, apikey, endpoint,)

yh = Yhat(
    username,
    apikey,
    endpoint
)
yh.deploy("HelloWorldPkg", HelloWorld, globals(), sure=True, verbose=1)
开发者ID:yhat,项目名称:workload-simulator,代码行数:28,代码来源:hello.py

示例3: HelloWorld

# 需要导入模块: from yhat import Yhat [as 别名]
# 或者: from yhat.Yhat import deploy [as 别名]
import os

from yhat import Yhat, YhatModel, preprocess

class HelloWorld(YhatModel):
	@preprocess(in_type=dict, out_type=dict)
	def execute(self, data):
		me = data['name']
		greeting = "Hello %s!" % me
		return { "greeting": greeting }


username = os.environ["USERNAME"]
apikey = os.environ["APIKEY"]
endpoint = os.environ["OPS_ENDPOINT"]

print "%s:%s:%s" % (username, apikey, endpoint,)

yh = Yhat(
    username,
    apikey,
    endpoint
)
yh.deploy("IndentedModel", HelloWorld, globals(), sure=True)
开发者ID:yhat,项目名称:workload-simulator,代码行数:26,代码来源:indent.py

示例4: execute

# 需要导入模块: from yhat import Yhat [as 别名]
# 或者: from yhat.Yhat import deploy [as 别名]
    @preprocess(in_type=pd.DataFrame,out_type=pd.DataFrame)
    def execute(self,data):
        # Collect customer meta data
        response = data[['Area Code','Phone']]
        charges = ['Day Charge','Eve Charge','Night Charge','Intl Charge']
        response['customer_worth'] = data[charges].sum(axis=1)
        # Convert yes no columns to bool
        data[yes_no_cols] = data[yes_no_cols] == 'yes'
        # Create feature space
        X = data[features].as_matrix().astype(float)
        X = scaler.transform(X)
        # Make prediction
        churn_prob = clf.predict_proba(X)
        response['churn_prob'] = churn_prob[:,1]
        # Calculate expected loss by churn
        response['expected_loss'] = response['churn_prob'] * response['customer_worth']
        response = response.sort('expected_loss',ascending=False)
        # Return response DataFrame
        return response

yh = Yhat(
    "e[at]yhathq.com", 
    " MY APIKEY ", 
    "http://cloud.yhathq.com/" 
)

print "Deploying model"
response = yh.deploy("PythonChurnModel",ChurnModel,globals())

print json.dumps(response,indent=2)
开发者ID:TATABOX42,项目名称:churn,代码行数:32,代码来源:churn_model.py

示例5: hello

# 需要导入模块: from yhat import Yhat [as 别名]
# 或者: from yhat.Yhat import deploy [as 别名]
        {"name": "x", "na_filler": 0},
        {"name": "z", "na_filler": fill_z}
]


class MyOtherClass:
    def hello(self, x):
        return "hello: %s" % str(x)

REQS = open("reqs.txt").read()

### <DEPLOYMENT START> ###
# @preprocess(in_type=dict, out_type=pd.DataFrame, null_handler=features)
class MyModel(YhatModel):
    REQUIREMENTS=REQS
    @preprocess(out_type=pd.DataFrame)
    def execute(self, data):
        return predict(data)

# "push" to server would be here

data = {"x": 1, "z": None}


if __name__ == '__main__':
    creds = credentials.read()
    yh = Yhat(creds['username'], creds['apikey'], "http://localhost:3000/")
    yh.deploy("mynewmodel", MyModel, globals())
    

开发者ID:Lomascolo,项目名称:yhat-client,代码行数:30,代码来源:test_yhatmodel.py

示例6: TravisModel

# 需要导入模块: from yhat import Yhat [as 别名]
# 或者: from yhat.Yhat import deploy [as 别名]

training_val = RFmodel.score(transform_dummies(X_train,False), y_train)
testing_val = RFmodel.score(transform_dummies(X_test,False), y_test)
print "training:", testing_val
print "testing: ", training_val

############ DEPLOYMENT ######################

from yhat import Yhat, YhatModel, preprocess

class TravisModel(YhatModel):
    def fit_val(self):
        testing_val = RFmodel.score(transform_dummies(X_test, False), y_test)
        return testing_val

    def execute(self,data):
        data = transform_dummies(data,False)
        output = RFmodel.predict(data)
        return output.tolist()

########## DEPLOY SET #####################

if __name__ == '__main__':
    yh = Yhat(
        os.environ['YHAT_USERNAME'],
        os.environ['YHAT_APIKEY'],
        os.environ['YHAT_URL'],
    )
    yh.deploy("TravisModel", TravisModel, globals(), True)
开发者ID:coristig,项目名称:travis-model,代码行数:31,代码来源:model.py

示例7: Graphlab_Recommender

# 需要导入模块: from yhat import Yhat [as 别名]
# 或者: from yhat.Yhat import deploy [as 别名]
 yahoo_data = aData
 yahoo_data.sort(columns = 'user_id', ascending = True, inplace = True) # no pass by value
 
 # rating-based CF recommendations
 data = {'user': [15], 'products':[123764, 71142],  'n':10}        
 aGraphlab_Model = Graphlab_Recommender(dataset = yahoo_data)
 print aGraphlab_Model.predict(data)
     
 """ USA TODAY """
 # rating-based CF recommendations
 usaToday_data = aData
 param = {'user_id':'Reviewer', 'product_id':'Id', 'ratings': 'Rating'}
 data = {'user': ['Edna Gundersen'], 'products':[123901],  'n':10}  
 aGraphlab_Model = Graphlab_Recommender(dataset = usaToday_data, needed_param = param)
 print aGraphlab_Model.predict(data)
 
 # textual analytics + CF method
 param = {'comment': 'Brief', 'ratings': 'Rating', 'user_id':'Reviewer', 'product_id':'Id'}
 model, ratings_data = rec.sentiment_analysis_regress(usaToday_data, param)
 ratings_data = ratings_data.sort(columns = 'user_id')
 ratings_data['user_id'] = ratings_data['user_id'].fillna('anonymous')
 print ratings_data
 
 aGraphlab_Model = Graphlab_Recommender(dataset = ratings_data)
 data = {'user': ['Edna Gundersen'], 'products':[123901],  'n':10} 
 print aGraphlab_Model.predict(data)
 '''
 # deployment
 yh = Yhat("[email protected]", "b36b987283a83e5e4d2814af6ef0eda9", "http://cloud.yhathq.com/")
 yh.deploy("Final_Recommender", Final_Recommender, globals()) 
开发者ID:chanhyeoni,项目名称:recommendation_engine,代码行数:32,代码来源:main.py

示例8: test_deployment

# 需要导入模块: from yhat import Yhat [as 别名]
# 或者: from yhat.Yhat import deploy [as 别名]
 def test_deployment(self):
     yh = Yhat("foo",  "bar", "http://api.yhathq.com/")
     _, bundle = yh.deploy("HelloWorld", HelloWorld, globals(), dry_run=True)
     self.assertTrue(True)
开发者ID:rlugojr,项目名称:yhat-client,代码行数:6,代码来源:test_cant_deploy_python3.py

示例9: Yhat

# 需要导入模块: from yhat import Yhat [as 别名]
# 或者: from yhat.Yhat import deploy [as 别名]
from example_app.models.yhat_model import TestModel, Foo
from yhat import Yhat
import json

yh = Yhat(
        "greg",
        "foo",
        "http://api.yhat.com/"
        )
TestModel().execute(1)

# _, bundle = yh.deploy("Foo", TestModel, globals(), dry_run=True)
yh.deploy("Foo", TestModel, globals(), verbose=2)
# print json.dumps(bundle, indent=2)
开发者ID:rlugojr,项目名称:yhat-client,代码行数:16,代码来源:run.py

示例10: make_prediction

# 需要导入模块: from yhat import Yhat [as 别名]
# 或者: from yhat.Yhat import deploy [as 别名]
        texts = data["texts"]
        return make_prediction(texts)

# example handling a single record
example = {
    "texts": {
        "text": "Alpo dog food"
    }
}
pp.pprint(ProductClassifier().execute(example))

# example handling multiple records
example = {
    "texts": [
        {"text": "Alpo dog food" },
        {"text": "Diet Coke"}
    ]
}
pp.pprint(ProductClassifier().execute(example))

YHAT_USERNAME = ""
YHAT_APIKEY = ""

try:
    yh = Yhat(YHAT_USERNAME, YHAT_APIKEY, "http://cloud.yhathq.com/")
except:
    print "Please add in your YHAT_USERNAME and YHAT_APIKEY"
    sys.exit(1)

print yh.deploy("ProductClassifier", ProductClassifier, globals())
开发者ID:pombredanne,项目名称:yhat-elastic-mr,代码行数:32,代码来源:classifier.py

示例11: test_detect_submodule_in_deployment

# 需要导入模块: from yhat import Yhat [as 别名]
# 或者: from yhat.Yhat import deploy [as 别名]
 def test_detect_submodule_in_deployment(self):
     yh = Yhat("greg", "test", "http://api.yhathq.com/")
     _, bundle = yh.deploy("TestModel", TestModel, globals(), sure=True, dry_run=True)
     self.assertEqual(len(bundle['modules']), 8)
开发者ID:rlugojr,项目名称:yhat-client,代码行数:6,代码来源:test_submodules.py

示例12: get_sims

# 需要导入模块: from yhat import Yhat [as 别名]
# 或者: from yhat.Yhat import deploy [as 别名]
    return p[0:n_recs]

get_sims(["Sierra Nevada Pale Ale", "60 Minute IPA"])

from yhat import Yhat, YhatModel, preprocess

class BeerRecommender(YhatModel):
    REQUIREMENTS=['numpy==1.11.3',
                  'pandas==0.19.2',
                  'scikit-learn==0.18.1']
    def execute(self, data):
        beers = data.get("beers")
        n_recs = data.get("n_recs")
        prob = data.get("prob")
        unique = data.get("unique")

        suggested_beers = get_sims(beers, n_recs, prob, unique)
        result = suggested_beers.to_dict(orient='records')
        return result

model = BeerRecommender()
model.execute({'beers':["Sierra Nevada Pale Ale"],'n_recs':10})

yh = Yhat("demo-master", "3b0160e10f6d7a94a2528b11b1c9bca1", "https://sandbox.c.yhat.com/")
print yh.deploy("BeerRecommender", BeerRecommender, globals(), autodetect=False, sure=True)


# print yh.predict("BeerRecommender", {"beers": ["Sierra Nevada Pale Ale",
#                  "120 Minute IPA", "Stone Ruination IPA"]})
开发者ID:yhat,项目名称:demo-beer-rec,代码行数:31,代码来源:rec.py

示例13: calculate_score

# 需要导入模块: from yhat import Yhat [as 别名]
# 或者: from yhat.Yhat import deploy [as 别名]
        data = data[features]
        prob = glm.predict_proba(data)[0][1]
        if prob > 0.3:
            decline_code = "Credit score too low"
        else:
            decline_code = ""
        odds = glm.predict_log_proba(data)[0][1]
        score = calculate_score(odds)

        output = {
            "prob_default": [prob],
            "decline_code": [decline_code],
            "score": [score]
        }

        return output

df_term[features].head()

test = {
    "last_fico_range_low": 705,
    "last_fico_range_high": 732,
    "home_ownership": "MORTGAGE"
}

LoanModel().execute(test)

yh = Yhat("colin", "d325fc5bcb83fc197ee01edb58b4b396",
          "https://sandbox.c.yhat.com/")
yh.deploy("LendingClub", LoanModel, globals(), True)
开发者ID:yhat,项目名称:demo-lending-club,代码行数:32,代码来源:lending_club_model.py

示例14: MarketingSearchAPI

# 需要导入模块: from yhat import Yhat [as 别名]
# 或者: from yhat.Yhat import deploy [as 别名]
import os
from yhat import Yhat, YhatModel
from pricing import Pricing

class MarketingSearchAPI(YhatModel):
    REQUIREMENTS = [
        "pandas==0.15.2",
        "numpy"
        ]
    def execute(self, data):
        result = p.predict(data)
        return result

p = Pricing()

username = os.environ["USERNAME"]
apikey = os.environ["APIKEY"]
endpoint = os.environ["OPS_ENDPOINT"]

print "%s:%s:%s" % (username, apikey, endpoint,)

yh = Yhat(
    username,
    apikey,
    endpoint
)
yh.deploy("RelayRidesPricing", MarketingSearchAPI, globals(), sure=True)
开发者ID:yhat,项目名称:workload-simulator,代码行数:29,代码来源:deploy.py

示例15: predict

# 需要导入模块: from yhat import Yhat [as 别名]
# 或者: from yhat.Yhat import deploy [as 别名]
        return self.dv.transform(doc)

    def predict(self, x):
        """
        Evaluate model on array
        delegates to LinearRegression self.lr
        returns a dict (will be json encoded) suppling 
        "predictedPrice", "suspectedOutlier", "x", "threshold" 
        where "x" is the input vector and "threshold" is determined 
        whether or not a listing is a suspected outlier.
        """
        doc = self.dv.inverse_transform(x)[0]
        predicted = self.lr.predict(x)[0]
        err = abs(predicted - doc["price"])
        return {
            "predictedPrice": predicted,
            "x": doc,
            "suspectedOutlier": 1 if (err > self.threshold) else 0,
            "threshold": self.threshold,
        }


pm = PricingModel(dv=dv, lr=LR, threshold=np.percentile(trainingErrs, 95))
print pm.execute(testing.T.to_dict()[0])

if raw_input("Deploy? (y/N): ").lower() == "y":
    username = "greg"
    apikey = "abcd1234"
    yh = Yhat(username, apikey, "http://cloud.yhathq.com/")
    print yh.deploy(model_name, fitted_model)
开发者ID:ixtel,项目名称:yhat-client,代码行数:32,代码来源:deploy.py


注:本文中的yhat.Yhat.deploy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。