I am aware catboost gives nice interactive chart for calculated feature statistics using the api model.cal_feature_statistics
, I was wondering If we can include this chart in streamlit
.
Streamlit has different chart api (https://docs.streamlit.io/en/stable/api.html#display-charts) such as streamlit.plotly_chart
, streamlit.altair_chart
etc, but I was unable to wrap the catboost output plot in streamlit.
Does anybody have idea how to wrap the chart in streamlit.
MWE
%%writefile app.py
# Ref: https://docs.streamlit.io/en/stable/api.html#display-charts
# imports
import numpy as np
import pandas as pd
import seaborn as sns
import sklearn
from sklearn import datasets
import catboost as cb
import streamlit as st
import streamlit.components.v1 as stc
# load the data
data = datasets.load_boston()
X = data.data
y = data.target
features = data.feature_names
# modelling
model = cb.CatBoostRegressor(verbose=0)
model.fit(X,y)
# chart
feature_name = 'sqft_living'
dict_stats = model.calc_feature_statistics(X, y, 0) # 0 means first feature
# streamlit
st.header("catboost feature statistics")
st.plotly_chart(dict_stats)
Run the app
streamlit run app.py