admin管理员组文章数量:1122846
Hi- Can you please review the code and let me know where its going wrong? Its not rendering or showing the dashboard in the app Its published in azure webapp,its building the dashboard but not showing anything in the app
from flask import Flask, redirect, url_for, session, request,jsonify,Blueprint,Markup
import json
import requests
import os
from sklearn.model_selection import train_test_split
from explainerdashboard import ClassifierExplainer, ExplainerDashboard
from sklearn.ensemble import RandomForestClassifier
app = Flask(__name__)
dashboard_blueprint = Blueprint('dashboard', __name__)
@dashboard_blueprint.route("/explainer")
# @app.route('/explainer')
def explainer_dashboard():
Master_Data.drop(['date_generated'],axis=1,inplace=True)
Master_Data = Master_Data.loc[:, Master_Data.columns.isin(unique_elements)]
# Step 5: Split the data into train and test sets
X = Master_Data.copy()
y = Master_Data['Target']
X_train, X_test, y_train, y_test = train_test_split(X.drop(['Target','Id','ref'], axis=1), y, test_size=0.2, random_state=42)
# after all the slicing and splitting of DataFrames and Series
X_train = X_train.reset_index(drop=True)
X_test = X_test.reset_index(drop=True)
y_train = y_train.reset_index(drop=True)
y_test = y_test.reset_index(drop=True)
# Train a RandomForest model
model = RandomForestClassifier(n_estimators=50, max_depth=5)
model.fit(X_train, y_train)
# Step 6: Set up the explainer dashboard
explainer = ClassifierExplainer(model, X_test, y_test, labels=['Not Homeless', 'Homeless'], index_name="Id", target="Homelessness")
db= ExplainerDashboard(explainer, title="Homelessness Model Explainer", importances=True,
model_summary=True,
contributions=True,
whatif=False,
shap_dependence=True,
shap_interaction=True,
decision_trees=True)
return db.app.index()
# Register the Blueprint
app.register_blueprint(dashboard_blueprint, url_prefix='/dashboard')
if __name__ == "__main__":
app.run(host='0.0.0.0', port=8000)
本文标签: pythonFlask app not rendering Model Explainer dashboardStack Overflow
版权声明:本文标题:python - Flask app not rendering Model Explainer dashboard - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736311381a1934717.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论