python taipy庫輕松地將數(shù)據(jù)和機器學習模型轉(zhuǎn)為功能性Web應用
神奇的python庫taipy
taipy 是一個開源的 Python 庫,任何具有基本 Python 技能的人都可以使用。對于數(shù)據(jù)科學家、機器學習工程師和 Python 程序員來說,它是一個方便的工具。借助 Taipy,你可以輕松地將數(shù)據(jù)和機器學習模型轉(zhuǎn)變?yōu)楣δ苄缘?Web 應用程序。
Taipy 的核心理念
Taipy GUI
Taipy 庫提供了 GUI 類,可以在幾分鐘內(nèi)輕松創(chuàng)建強大的 Web 應用程序。
當你調(diào)用 GUI 的 run() 方法時,它會啟動一個 Web 服務器。Taipy 將創(chuàng)建的頁面轉(zhuǎn)換為 HTML 內(nèi)容發(fā)送回客戶端,使用戶能夠查看應用程序界面并與之交互。
場景和數(shù)據(jù)管理
讓我們在 Taipy 中創(chuàng)建一個場景,以根據(jù)你選擇的類型過濾電影數(shù)據(jù)。
此場景模擬了一個簡單的管道。每次類型選擇發(fā)生變化時都會提交,并輸出該類型的七部最受歡迎的電影。
def filter_genre(initial_dataset: pd.DataFrame, selected_genre): filtered_dataset = initial_dataset[initial_dataset['genres'].str.contains(selected_genre)] filtered_data = filtered_dataset.nlargest(7, 'Popularity %') return filtered_data
Taipy Studio
你可以使用 Visual Studio Code 中的 Taipy Studio 擴展來配置你的場景,無需任何代碼。
你的配置會自動保存為 TOML 文件。
庫的安裝
可以直接使用 pip 來進行安裝。
pip install taipy
GUI 案例
from taipy import Gui excitement_page = """ # Welcome to Taipy ### How excited are you to try Taipy? <|{excitement}|slider|min=1|max=100|> My excitement level: <|{excitement}|> """ excitement = 100 Gui(page=excitement_page).run()
用戶界面生成+場景和數(shù)據(jù)管理
現(xiàn)在,讓我們加載此配置并在頂部添加一個用戶界面以實現(xiàn)完整的應用程序。
import taipy as tp import pandas as pd from taipy import Config, Scope, Gui # Taipy Scenario & Data Management # Filtering function - task def filter_genre(initial_dataset: pd.DataFrame, selected_genre): filtered_dataset = initial_dataset[initial_dataset["genres"].str.contains(selected_genre)] filtered_data = filtered_dataset.nlargest(7, "Popularity %") return filtered_data # Load the configuration made with Taipy Studio Config.load("config.toml") scenario_cfg = Config.scenarios["scenario"] # Start Taipy Core service tp.Core().run() # Create a scenario scenario = tp.create_scenario(scenario_cfg) # Taipy User Interface # Let's add a GUI to our Scenario Management for a full application # Callback definition - submits scenario with genre selection def on_genre_selected(state): scenario.selected_genre_node.write(state.selected_genre) tp.submit(scenario) state.df = scenario.filtered_data.read() # Get list of genres genres = [ "Action", "Adventure", "Animation", "Children", "Comedy", "Fantasy", "IMAX" "Romance","Sci-FI", "Western", "Crime", "Mystery", "Drama", "Horror", "Thriller", "Film-Noir","War", "Musical", "Documentary" ] # Initialization of variables df = pd.DataFrame(columns=["Title", "Popularity %"]) selected_genre = "Action" ## Set initial value to Action def on_init(state): on_genre_selected(state) # User interface definition my_page = """ # Film recommendation ## Choose your favorite genre <|{selected_genre}|selector|lov={genres}|on_change=on_genre_selected|dropdown|> ## Here are the top seven picks by popularity <|{df}|chart|x=Title|y=Popularity %|type=bar|title=Film Popularity|> """ Gui(page=my_page).run()
以上就是python taipy庫輕松地將數(shù)據(jù)和機器學習模型轉(zhuǎn)為功能性Web應用的詳細內(nèi)容,更多關(guān)于python taipy庫的資料請關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
Python調(diào)用訊飛語音合成API接口來實現(xiàn)文字轉(zhuǎn)語音
這篇文章主要為大家介紹了Python調(diào)用訊飛語音合成API接口來實現(xiàn)文字轉(zhuǎn)語音方法示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-04-04Python 隨機生成測試數(shù)據(jù)的模塊:faker基本使用方法詳解
這篇文章主要介紹了Python 隨機生成測試數(shù)據(jù)的模塊:faker基本使用方法,結(jié)合實例形式詳細分析了Python 隨機生成測試數(shù)據(jù)的模塊faker基本功能、原理、使用方法及操作注意事項,需要的朋友可以參考下2020-04-04python用for循環(huán)求和的方法總結(jié)
在本篇文章里小編給各位分享了關(guān)于python用for循環(huán)求和的方法以及相關(guān)實例代碼,需要的朋友們參考學習下。2019-07-07