python taipy庫輕松地將數(shù)據(jù)和機(jī)器學(xué)習(xí)模型轉(zhuǎn)為功能性Web應(yīng)用
神奇的python庫taipy
taipy 是一個開源的 Python 庫,任何具有基本 Python 技能的人都可以使用。對于數(shù)據(jù)科學(xué)家、機(jī)器學(xué)習(xí)工程師和 Python 程序員來說,它是一個方便的工具。借助 Taipy,你可以輕松地將數(shù)據(jù)和機(jī)器學(xué)習(xí)模型轉(zhuǎn)變?yōu)楣δ苄缘?Web 應(yīng)用程序。

Taipy 的核心理念
Taipy GUI
Taipy 庫提供了 GUI 類,可以在幾分鐘內(nèi)輕松創(chuàng)建強(qiáng)大的 Web 應(yīng)用程序。

當(dāng)你調(diào)用 GUI 的 run() 方法時,它會啟動一個 Web 服務(wù)器。Taipy 將創(chuàng)建的頁面轉(zhuǎn)換為 HTML 內(nèi)容發(fā)送回客戶端,使用戶能夠查看應(yīng)用程序界面并與之交互。
場景和數(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 擴(kuò)展來配置你的場景,無需任何代碼。

你的配置會自動保存為 TOML 文件。
庫的安裝
可以直接使用 pip 來進(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()
用戶界面生成+場景和數(shù)據(jù)管理
現(xiàn)在,讓我們加載此配置并在頂部添加一個用戶界面以實(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庫輕松地將數(shù)據(jù)和機(jī)器學(xué)習(xí)模型轉(zhuǎn)為功能性Web應(yīng)用的詳細(xì)內(nèi)容,更多關(guān)于python taipy庫的資料請關(guān)注腳本之家其它相關(guān)文章!
- python機(jī)器學(xué)習(xí)darts時間序列預(yù)測和分析
- python機(jī)器學(xué)習(xí)XGBoost梯度提升決策樹的高效且可擴(kuò)展實(shí)現(xiàn)
- python interpret庫訓(xùn)練模型助力機(jī)器學(xué)習(xí)
- Python mlxtend庫數(shù)據(jù)科學(xué)和機(jī)器學(xué)習(xí)補(bǔ)充工具功能探索
- python?lazypredict構(gòu)建大量基本模型簡化機(jī)器學(xué)習(xí)
- Python梯度提升庫XGBoost解決機(jī)器學(xué)習(xí)問題使用探究
- Python機(jī)器學(xué)習(xí)特征重要性分析的8個常用方法實(shí)例探究
- python機(jī)器學(xué)習(xí)deepchecks庫訓(xùn)練檢查模型特點(diǎn)探索
相關(guān)文章
Python模塊_PyLibTiff讀取tif文件的實(shí)例
今天小編就為大家分享一篇Python模塊_PyLibTiff讀取tif文件的實(shí)例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-01-01
Python調(diào)用訊飛語音合成API接口來實(shí)現(xiàn)文字轉(zhuǎn)語音
這篇文章主要為大家介紹了Python調(diào)用訊飛語音合成API接口來實(shí)現(xiàn)文字轉(zhuǎn)語音方法示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-04-04
Python 隨機(jī)生成測試數(shù)據(jù)的模塊:faker基本使用方法詳解
這篇文章主要介紹了Python 隨機(jī)生成測試數(shù)據(jù)的模塊:faker基本使用方法,結(jié)合實(shí)例形式詳細(xì)分析了Python 隨機(jī)生成測試數(shù)據(jù)的模塊faker基本功能、原理、使用方法及操作注意事項(xiàng),需要的朋友可以參考下2020-04-04
python用for循環(huán)求和的方法總結(jié)
在本篇文章里小編給各位分享了關(guān)于python用for循環(huán)求和的方法以及相關(guān)實(shí)例代碼,需要的朋友們參考學(xué)習(xí)下。2019-07-07
Python中使用sklearn進(jìn)行特征降維的方法
在Python中,可以使用sklearn庫中的特征降維方法對數(shù)據(jù)進(jìn)行處理。主要包括基于PCA算法的降維、基于LDA算法的降維、以及利用特征選擇方法進(jìn)行降維。這些方法可以提高模型的訓(xùn)練效率和預(yù)測準(zhǔn)確率,特別是在高維數(shù)據(jù)集中具有重要的作用2023-04-04

