运行 Streamlit 应用程序中的 ExplainerDashboard
Run ExplainerDashboard inside a streamlit application
我想 运行 Streamlit 应用程序中的 ExplainerDashboard。有什么办法可以做到吗?我已经尝试了 ExplainerDashboard run()
功能的所有模式,但它仍然不适合我。
这是我到目前为止所做的,但它不起作用。
from sklearn.model_selection import train_test_split
import streamlit as st
import pandas as pd
from explainerdashboard import ClassifierExplainer, ExplainerDashboard
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
def app():
st.title("This is the machine learning page")
st.markdown("redirect to my [app](https://github.com/prakharrathi25/data-storyteller/blob/main/app.py)")
st.write("This is an example of a Streamlit app - machine learning")
# show the same data in the machine learning page
data = pd.read_csv('data/iris.csv')
st.dataframe(data)
# Divide X and y
X = data[['A', 'B', 'C', 'D']]
y = data['E']
# Convert y to labels
y = y.map({'Iris-setosa': 0, 'Iris-versicolor': 1, 'Iris-virginica': 2})
X_train, X_test, y_train, y_test = train_test_split(X, y, train_size=0.8)
model = LogisticRegression()
model.fit(X_train, y_train)
st.write(model) # the code only runs till here
explainer = ClassifierExplainer(model, X_test, y_test)
ExplainerDashboard(explainer).run(mode='external')
st.markdown("Check out the [explainer dashboard](http://192.168.1.3:8050/)")
运行 仪表板正常,运行 streamlit 将仪表板的 url 加载为 iframe in streamlit 应用程序。
- 运行 仪表板
- 获取本地仪表板url
- 运行 streamlit
Streamlit 代码
def app():
"""
Set appearance to wide mode.
"""
st.title("This is the machine learning page")
dashboardurl = 'http://127.0.0.1:8050/'
st.components.v1.iframe(dashboardurl, width=None, height=900, scrolling=True)
图片
我想 运行 Streamlit 应用程序中的 ExplainerDashboard。有什么办法可以做到吗?我已经尝试了 ExplainerDashboard run()
功能的所有模式,但它仍然不适合我。
这是我到目前为止所做的,但它不起作用。
from sklearn.model_selection import train_test_split
import streamlit as st
import pandas as pd
from explainerdashboard import ClassifierExplainer, ExplainerDashboard
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
def app():
st.title("This is the machine learning page")
st.markdown("redirect to my [app](https://github.com/prakharrathi25/data-storyteller/blob/main/app.py)")
st.write("This is an example of a Streamlit app - machine learning")
# show the same data in the machine learning page
data = pd.read_csv('data/iris.csv')
st.dataframe(data)
# Divide X and y
X = data[['A', 'B', 'C', 'D']]
y = data['E']
# Convert y to labels
y = y.map({'Iris-setosa': 0, 'Iris-versicolor': 1, 'Iris-virginica': 2})
X_train, X_test, y_train, y_test = train_test_split(X, y, train_size=0.8)
model = LogisticRegression()
model.fit(X_train, y_train)
st.write(model) # the code only runs till here
explainer = ClassifierExplainer(model, X_test, y_test)
ExplainerDashboard(explainer).run(mode='external')
st.markdown("Check out the [explainer dashboard](http://192.168.1.3:8050/)")
运行 仪表板正常,运行 streamlit 将仪表板的 url 加载为 iframe in streamlit 应用程序。
- 运行 仪表板
- 获取本地仪表板url
- 运行 streamlit
Streamlit 代码
def app():
"""
Set appearance to wide mode.
"""
st.title("This is the machine learning page")
dashboardurl = 'http://127.0.0.1:8050/'
st.components.v1.iframe(dashboardurl, width=None, height=900, scrolling=True)