python taipy庫(kù)輕松地將數(shù)據(jù)和機(jī)器學(xué)習(xí)模型轉(zhuǎn)為功能性Web應(yīng)用
神奇的python庫(kù)taipy
taipy 是一個(gè)開源的 Python 庫(kù),任何具有基本 Python 技能的人都可以使用。對(duì)于數(shù)據(jù)科學(xué)家、機(jī)器學(xué)習(xí)工程師和 Python 程序員來(lái)說(shuō),它是一個(gè)方便的工具。借助 Taipy,你可以輕松地將數(shù)據(jù)和機(jī)器學(xué)習(xí)模型轉(zhuǎn)變?yōu)楣δ苄缘?Web 應(yīng)用程序。
Taipy 的核心理念
Taipy GUI
Taipy 庫(kù)提供了 GUI 類,可以在幾分鐘內(nèi)輕松創(chuàng)建強(qiáng)大的 Web 應(yīng)用程序。
當(dāng)你調(diào)用 GUI 的 run() 方法時(shí),它會(huì)啟動(dòng)一個(gè) Web 服務(wù)器。Taipy 將創(chuàng)建的頁(yè)面轉(zhuǎn)換為 HTML 內(nèi)容發(fā)送回客戶端,使用戶能夠查看應(yīng)用程序界面并與之交互。
場(chǎng)景和數(shù)據(jù)管理
讓我們?cè)?Taipy 中創(chuàng)建一個(gè)場(chǎng)景,以根據(jù)你選擇的類型過(guò)濾電影數(shù)據(jù)。
此場(chǎng)景模擬了一個(gè)簡(jiǎn)單的管道。每次類型選擇發(fā)生變化時(shí)都會(huì)提交,并輸出該類型的七部最受歡迎的電影。
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 擴(kuò)展來(lái)配置你的場(chǎng)景,無(wú)需任何代碼。
你的配置會(huì)自動(dòng)保存為 TOML 文件。
庫(kù)的安裝
可以直接使用 pip 來(lái)進(jìn)行安裝。
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()
用戶界面生成+場(chǎng)景和數(shù)據(jù)管理
現(xiàn)在,讓我們加載此配置并在頂部添加一個(gè)用戶界面以實(shí)現(xiàn)完整的應(yīng)用程序。
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庫(kù)輕松地將數(shù)據(jù)和機(jī)器學(xué)習(xí)模型轉(zhuǎn)為功能性Web應(yīng)用的詳細(xì)內(nèi)容,更多關(guān)于python taipy庫(kù)的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
- python機(jī)器學(xué)習(xí)darts時(shí)間序列預(yù)測(cè)和分析
- python機(jī)器學(xué)習(xí)XGBoost梯度提升決策樹的高效且可擴(kuò)展實(shí)現(xiàn)
- python interpret庫(kù)訓(xùn)練模型助力機(jī)器學(xué)習(xí)
- Python mlxtend庫(kù)數(shù)據(jù)科學(xué)和機(jī)器學(xué)習(xí)補(bǔ)充工具功能探索
- python?lazypredict構(gòu)建大量基本模型簡(jiǎn)化機(jī)器學(xué)習(xí)
- Python梯度提升庫(kù)XGBoost解決機(jī)器學(xué)習(xí)問(wèn)題使用探究
- Python機(jī)器學(xué)習(xí)特征重要性分析的8個(gè)常用方法實(shí)例探究
- python機(jī)器學(xué)習(xí)deepchecks庫(kù)訓(xùn)練檢查模型特點(diǎn)探索
相關(guān)文章
Python模塊_PyLibTiff讀取tif文件的實(shí)例
今天小編就為大家分享一篇Python模塊_PyLibTiff讀取tif文件的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-01-01Python調(diào)用訊飛語(yǔ)音合成API接口來(lái)實(shí)現(xiàn)文字轉(zhuǎn)語(yǔ)音
這篇文章主要為大家介紹了Python調(diào)用訊飛語(yǔ)音合成API接口來(lái)實(shí)現(xiàn)文字轉(zhuǎn)語(yǔ)音方法示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-04-04Python 隨機(jī)生成測(cè)試數(shù)據(jù)的模塊:faker基本使用方法詳解
這篇文章主要介紹了Python 隨機(jī)生成測(cè)試數(shù)據(jù)的模塊:faker基本使用方法,結(jié)合實(shí)例形式詳細(xì)分析了Python 隨機(jī)生成測(cè)試數(shù)據(jù)的模塊faker基本功能、原理、使用方法及操作注意事項(xiàng),需要的朋友可以參考下2020-04-04python無(wú)法引用另一個(gè)文件夾的py文件問(wèn)題及解決
這篇文章主要介紹了python無(wú)法引用另一個(gè)文件夾的py文件問(wèn)題及解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-08-08python用for循環(huán)求和的方法總結(jié)
在本篇文章里小編給各位分享了關(guān)于python用for循環(huán)求和的方法以及相關(guān)實(shí)例代碼,需要的朋友們參考學(xué)習(xí)下。2019-07-07Python中使用sklearn進(jìn)行特征降維的方法
在Python中,可以使用sklearn庫(kù)中的特征降維方法對(duì)數(shù)據(jù)進(jìn)行處理。主要包括基于PCA算法的降維、基于LDA算法的降維、以及利用特征選擇方法進(jìn)行降維。這些方法可以提高模型的訓(xùn)練效率和預(yù)測(cè)準(zhǔn)確率,特別是在高維數(shù)據(jù)集中具有重要的作用2023-04-04