我已经使用jupyter-notebook创建了一个 Jmeter 板,它当前正在我的本地主机上运行,使用命令
app = xpl.run_app(host="localhost",port=8050)
其中xpl
是Shapash对象。
现在,我想通过公共互联网托管它,以便每个人都可以访问它。谁能帮助我如何将 Jmeter 板公开到互联网或AWS上?
如果有人对如何将场景重现到webapp感兴趣。你可以参考下面的代码:
import pandas as pd
from category_encoders import OrdinalEncoder
from shapash.data.data_loader import data_loading
from shapash.explainer.smart_explainer import SmartExplainer
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import train_test_split
# Read data
house_df, house_dict = data_loading('house_prices')
y_df = house_df['SalePrice'].to_frame()
X_df = house_df[house_df.columns.difference(['SalePrice'])]
# Convert Categorical into numerical
categorical_features = [col for col in X_df.columns if X_df[col].dtype == 'object']
encoder = OrdinalEncoder(cols=categorical_features).fit(X_df)
X_df=encoder.transform(X_df)
# Split data, train model and predict
Xtrain, Xtest, ytrain, ytest = train_test_split(X_df, y_df, train_size=0.75)
reg = RandomForestRegressor(n_estimators=200, min_samples_leaf=2).fit(Xtrain,ytrain)
y_pred = pd.DataFrame(reg.predict(Xtest), columns=['pred'], index=Xtest.index)
xpl = SmartExplainer(
model=reg,
preprocessing=encoder,
features_dict=house_dict
)
xpl.compile(
x=Xtest,
y_pred=y_pred,
y_target=ytest,
)
# To display the webapp locally
app = xpl.run_app(host="localhost", port=8050)
1条答案
按热度按时间ekqde3dh1#
这不像是SageMaker的问题。如果您想在AWS上托管无服务器网站,请参阅:https://aws.amazon.com/getting-started/hands-on/build-serverless-web-app-lambda-apigateway-s3-dynamodb-cognito/。
如果您不需要每次都训练模型,并且只想展示 Jmeter 板,我建议您只托管代码来描述 Jmeter 板。
如果你想在SageMaker上训练和部署模型,我看到模型是SKLearn。请看一下这个链接:https://ram-vegiraju.medium.com/training-and-deploying-custom-scikit-learn-models-on-aws-sagemaker-3de6a2f669f4