from meutils.pipe import * from appzoo.streamlit_app import Page import streamlit as st import m2cgen as m2c class MyPage(Page): def main(self): with st.form("Coding"): file = st.file_uploader('上传默模型文件') if file: estimator = joblib.load(file) else: estimator = joblib.load(get_resolve_path('../data/lr.pkl', __file__)) languages = [ 'python', 'java', 'go', 'c', 'c_sharp', 'r', 'dart', 'elixir', 'f_sharp', 'haskell', 'javascript', 'php', 'powershell', 'ruby', 'rust', 'visual_basic' ] _ = st.selectbox('选择输出语言', languages) if st.form_submit_button('开始转换'): code = m2c.__getattribute__(f'export_to_{_}')(estimator) st.markdown("##### code:") st.code(code) if __name__ == '__main__': app_title = "ModelToCode" app_info = """ 将训练过的统计模型转化为本地代码(`Python, C, Java, Go, JavaScript, Visual Basic, c#, PowerShell, R, PHP, Dart, Haskell, Ruby, f#, Rust, Elixir`)。 """ MyPage( app_title=f"# {app_title}", app_info=f"> {app_info}", ).main()