python taipy庫輕松地將數(shù)據(jù)和機(jī)器學(xué)習(xí)模型轉(zhuǎn)為功能性Web應(yīng)用
神奇的python庫taipy
taipy 是一個(gè)開源的 Python 庫,任何具有基本 Python 技能的人都可以使用。對(duì)于數(shù)據(jù)科學(xué)家、機(jī)器學(xué)習(xí)工程師和 Python 程序員來說,它是一個(gè)方便的工具。借助 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() 方法時(shí),它會(huì)啟動(dòng)一個(gè) Web 服務(wù)器。Taipy 將創(chuàng)建的頁面轉(zhuǎn)換為 HTML 內(nèi)容發(fā)送回客戶端,使用戶能夠查看應(yīng)用程序界面并與之交互。
場(chǎng)景和數(shù)據(jù)管理
讓我們?cè)?Taipy 中創(chuàng)建一個(gè)場(chǎng)景,以根據(jù)你選擇的類型過濾電影數(shù)據(jù)。
此場(chǎng)景模擬了一個(gè)簡單的管道。每次類型選擇發(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ò)展來配置你的場(chǎng)景,無需任何代碼。

你的配置會(huì)自動(dòng)保存為 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()
用戶界面生成+場(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庫輕松地將數(shù)據(jù)和機(jī)器學(xué)習(xí)模型轉(zhuǎn)為功能性Web應(yīng)用的詳細(xì)內(nèi)容,更多關(guān)于python taipy庫的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
Pycharm搭建一個(gè)Django項(xiàng)目的方法步驟
本文主要介紹了Pycharm搭建一個(gè)Django項(xiàng)目的方法步驟,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-02-02
Python比較文件夾比另一同名文件夾多出的文件并復(fù)制出來的方法
這篇文章主要介紹了Python比較文件夾比另一同名文件夾多出的文件并復(fù)制出來的方法,涉及Python針對(duì)文件與文件夾的操作技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-03-03
解決vscode python print 輸出窗口中文亂碼的問題
今天小編就為大家分享一篇解決vscode python print 輸出窗口中文亂碼的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2018-12-12
Python執(zhí)行系統(tǒng)命令的五種方式小結(jié)
在日常開發(fā)中,有時(shí)需要在Python腳本中執(zhí)行系統(tǒng)命令,Python有五種方式來執(zhí)行系統(tǒng)命令(推薦使用第五種),本文為大家整理了這五種方法的具體使用,希望對(duì)大家有所幫助2024-01-01
使用Python構(gòu)建一個(gè)簡單的批處理GUI工具
在許多工作流程中,我們都會(huì)遇到需要重復(fù)執(zhí)行的一系列任務(wù),手動(dòng)執(zhí)行這些步驟可能既繁瑣又容易出錯(cuò),自動(dòng)化此類序列可以顯著提高生產(chǎn)力,所以本文小編給大家分享了如何使用Python構(gòu)建一個(gè)簡單的批處理GUI工具,需要的朋友可以參考下2025-04-04
python編寫adb截圖工具的實(shí)現(xiàn)源碼
adb截圖工具可用于Android手機(jī)及Android終端,Android端或者Android終端的遠(yuǎn)程截圖至本地電腦中,今天通過本文給大家介紹python編寫adb截圖工具的實(shí)現(xiàn)源碼,感興趣的朋友一起看看吧2021-08-08
Python將xml和xsl轉(zhuǎn)換為html的方法
這篇文章主要介紹了Python將xml和xsl轉(zhuǎn)換為html的方法,實(shí)例分析了使用libxml2模塊操作xml和xsl轉(zhuǎn)換為html的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-03-03

