当前位置: 首页 > news >正文

第100+33步 ChatGPT学习:时间序列EMD-ARIMA-LSTM模型

基于Python 3.9版本演示

 

一、写在前面

上一节,我们学了经验模态分解(Empirical Mode Decomposition,EMD)。

如同结尾所说,“那么,做这些分解有什么作用呢?有大佬基于这些分解出来的序列分别作预测,然后再次合并,达到提升预测性能的作用。”

 

二、EMD&LSTM-ARIMA组合策略

该组合策略主要是将传统的经验模态分解(EMD)方法和现代的机器学习技术(LSTM 和 ARIMA 模型)相结合,用于增强时序数据的预测能力。下面是这个策略的具体描述:

(1)经验模态分解 (EMD):

1)首先,使用 EMD 方法处理原始时序数据,将其分解为多个内模函数(IMF)和一个剩余信号。这一步骤的目的是提取数据中的不同频率成分,每个 IMF 代表原始信号的不同频率层次,而剩余信号包含了趋势信息。

2)EMD 是一种自适应方法,适用于非线性和非平稳时间序列数据分析,可以揭示隐藏在复杂数据集中的简单结构和成分。

(2)LSTM 和 ARIMA 模型的应用:

1)将不同的 IMF 成分分配给不同的预测模型:选定的IMF由 LSTM 模型处理,通常选择那些更具高频和复杂动态的成分;而趋势性较强的成分(包括剩余信号)则交由 ARIMA 模型进行分析。

2)LSTM (长短期记忆网络):适合处理和预测时间序列数据中的长期依赖关系,因此用于捕捉和预测时序数据中的非线性模式和复杂关系。

3)ARIMA (自回归积分滑动平均模型):擅长处理线性关系和趋势变化,适用于具有明显趋势或季节性的时间序列数据。

 

三、EMD&LSTM-ARIMA组合策略代码Pyhton实现

下面,我使用的是之前分享过的肺结核的数据做演示:

311fef53b2d142c087306ca3061bc39a.png

Pyhon代码:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import CubicSpline
import torch
import torch.nn as nn
import torch.optim as optim
from statsmodels.tsa.arima.model import ARIMA
from sklearn.metrics import mean_absolute_error, mean_squared_error# 读取数据
file_path = 'pone.0277314.s006.xlsx'
data = pd.read_excel(file_path)# 提取时间和PTB病例数
time_series = data['Time']
ptb_cases = data['PTB cases']# 将时间转换为数值形式
time_numeric = np.arange(len(time_series))def get_envelope_mean(signal):"""计算信号的上包络线和下包络线的均值"""maxima = np.where(np.r_[True, signal[1:] > signal[:-1]] & np.r_[signal[:-1] > signal[1:], True])[0]minima = np.where(np.r_[True, signal[1:] < signal[:-1]] & np.r_[signal[:-1] < signal[1:], True])[0]if len(maxima) < 2 or len(minima) < 2:return np.zeros_like(signal)upper_env = CubicSpline(maxima, signal[maxima])(time_numeric)lower_env = CubicSpline(minima, signal[minima])(time_numeric)return (upper_env + lower_env) / 2def sift(signal, max_iter=1000, tol=1e-6):"""对信号进行sifting操作,提取IMF"""h = signalfor _ in range(max_iter):m = get_envelope_mean(h)h1 = h - mif np.mean(np.abs(h - h1)) < tol:breakh = h1return hdef emd(signal, max_imfs=6):"""进行EMD分解"""residual = signalimfs = []for _ in range(max_imfs):imf = sift(residual)imfs.append(imf)residual = residual - imfif np.all(np.abs(residual) < 1e-6):breakreturn np.array(imfs), residual# 执行EMD分解
imfs, residual = emd(ptb_cases.values)# 绘制分解结果
num_imfs = imfs.shape[0]
plt.figure(figsize=(12, 9))
for i in range(num_imfs):plt.subplot(num_imfs + 1, 1, i + 1)plt.plot(time_series, imfs[i], label=f'IMF {i + 1}')plt.legend()plt.subplot(num_imfs + 1, 1, num_imfs + 1)
plt.plot(time_series, residual, label='Residual')
plt.legend()
plt.tight_layout()
plt.show()# LSTM模型
class LSTMModel(nn.Module):def __init__(self, input_size=1, hidden_layer_size=50, output_size=1):super(LSTMModel, self).__init__()self.hidden_layer_size = hidden_layer_sizeself.lstm = nn.LSTM(input_size, hidden_layer_size)self.linear = nn.Linear(hidden_layer_size, output_size)self.hidden_cell = (torch.zeros(1,1,self.hidden_layer_size),torch.zeros(1,1,self.hidden_layer_size))def forward(self, input_seq):lstm_out, self.hidden_cell = self.lstm(input_seq.view(len(input_seq) ,1, -1), self.hidden_cell)predictions = self.linear(lstm_out.view(len(input_seq), -1))return predictions[-1]def train_lstm_model(train_data, n_steps):model = LSTMModel()loss_function = nn.MSELoss()optimizer = optim.Adam(model.parameters(), lr=0.001)epochs = 200for epoch in range(epochs):for seq in range(len(train_data) - n_steps):model.hidden_cell = (torch.zeros(1, 1, model.hidden_layer_size),torch.zeros(1, 1, model.hidden_layer_size))seq_train = torch.FloatTensor(train_data[seq:seq + n_steps])label = torch.FloatTensor(train_data[seq + n_steps:seq + n_steps + 1])optimizer.zero_grad()y_pred = model(seq_train)single_loss = loss_function(y_pred, label)single_loss.backward()optimizer.step()if epoch % 50 == 0:print(f'Epoch {epoch+1} loss: {single_loss.item()}')return modeldef arima_model(train_data, order):model = ARIMA(train_data, order=order)model_fit = model.fit()return model_fitn_steps = 10
imfs_lstm = [3, 4]  # 分配给LSTM的IMFs索引
imfs_arima = [0, 1, 2]  # 分配给ARIMA的IMFs索引lstm_predictions = np.zeros(len(time_numeric))
arima_predictions = np.zeros(len(time_numeric))# LSTM预测
for idx in imfs_lstm:print(f'Training LSTM for IMF {idx+1}')train_data = imfs[idx].flatten()model = train_lstm_model(train_data, n_steps)for i in range(n_steps, len(train_data)):seq = torch.FloatTensor(train_data[i-n_steps:i])with torch.no_grad():lstm_predictions[i] += model(seq).item()print(f'LSTM predictions for IMF {idx+1} completed')# ARIMA预测
for idx in imfs_arima:print(f'Training ARIMA for IMF {idx+1}')train_data = imfs[idx]model_fit = arima_model(train_data, order=(5, 1, 0))arima_predictions += model_fit.predict(start=0, end=len(train_data) - 1)print(f'ARIMA predictions for IMF {idx+1} completed')# 合并预测结果
final_predictions = lstm_predictions + arima_predictions# 计算误差
mae = mean_absolute_error(ptb_cases, final_predictions)
mse = mean_squared_error(ptb_cases, final_predictions)
rmse = np.sqrt(mse)
mape = np.mean(np.abs((ptb_cases - final_predictions) / ptb_cases)) * 100# 打印误差
print(f'MAE: {mae}')
print(f'MSE: {mse}')
print(f'RMSE: {rmse}')
print(f'MAPE: {mape}')# 绘制预测结果
plt.figure(figsize=(12, 6))
plt.plot(time_numeric, ptb_cases, label='Original Data')
plt.plot(time_numeric, final_predictions, label='Predicted Data')
plt.legend()
plt.show()

输出:

d132d76bacaf4b23a1b55c63857090db.png

跟原图对比:

发现了没,似乎是整体向下偏移了一波。让GPT帮忙优化一下算法。

 

五、优化后

根据每个模型的误差(MAE)微调一下试试:

Pyhon代码:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import CubicSpline
import torch
import torch.nn as nn
import torch.optim as optim
from statsmodels.tsa.arima.model import ARIMA
from sklearn.metrics import mean_absolute_error, mean_squared_error# 读取数据
file_path = 'pone.0277314.s006.xlsx'
data = pd.read_excel(file_path)# 提取时间和PTB病例数
time_series = data['Time']
ptb_cases = data['PTB cases']# 将时间转换为数值形式
time_numeric = np.arange(len(time_series))def get_envelope_mean(signal):"""计算信号的上包络线和下包络线的均值"""maxima = np.where(np.r_[True, signal[1:] > signal[:-1]] & np.r_[signal[:-1] > signal[1:], True])[0]minima = np.where(np.r_[True, signal[1:] < signal[:-1]] & np.r_[signal[:-1] < signal[1:], True])[0]if len(maxima) < 2 or len(minima) < 2:return np.zeros_like(signal)upper_env = CubicSpline(maxima, signal[maxima])(time_numeric)lower_env = CubicSpline(minima, signal[minima])(time_numeric)return (upper_env + lower_env) / 2def sift(signal, max_iter=1000, tol=1e-6):"""对信号进行sifting操作,提取IMF"""h = signalfor _ in range(max_iter):m = get_envelope_mean(h)h1 = h - mif np.mean(np.abs(h - h1)) < tol:breakh = h1return hdef emd(signal, max_imfs=6):"""进行EMD分解"""residual = signalimfs = []for _ in range(max_imfs):imf = sift(residual)imfs.append(imf)residual = residual - imfif np.all(np.abs(residual) < 1e-6):breakreturn np.array(imfs), residual# 执行EMD分解
imfs, residual = emd(ptb_cases.values)# 绘制分解结果
num_imfs = imfs.shape[0]
plt.figure(figsize=(12, 9))
for i in range(num_imfs):plt.subplot(num_imfs + 1, 1, i + 1)plt.plot(time_series, imfs[i], label=f'IMF {i + 1}')plt.legend()plt.subplot(num_imfs + 1, 1, num_imfs + 1)
plt.plot(time_series, residual, label='Residual')
plt.legend()
plt.tight_layout()
plt.show()# LSTM模型
class LSTMModel(nn.Module):def __init__(self, input_size=1, hidden_layer_size=50, output_size=1):super(LSTMModel, self).__init__()self.hidden_layer_size = hidden_layer_sizeself.lstm = nn.LSTM(input_size, hidden_layer_size)self.linear = nn.Linear(hidden_layer_size, output_size)self.hidden_cell = (torch.zeros(1,1,self.hidden_layer_size),torch.zeros(1,1,self.hidden_layer_size))def forward(self, input_seq):lstm_out, self.hidden_cell = self.lstm(input_seq.view(len(input_seq) ,1, -1), self.hidden_cell)predictions = self.linear(lstm_out.view(len(input_seq), -1))return predictions[-1]def train_lstm_model(train_data, n_steps):model = LSTMModel(hidden_layer_size=100)  # 调整隐藏层大小loss_function = nn.MSELoss()optimizer = optim.Adam(model.parameters(), lr=0.001)  # 调整学习率epochs = 300  # 增加训练轮数for epoch in range(epochs):for seq in range(len(train_data) - n_steps):model.hidden_cell = (torch.zeros(1, 1, model.hidden_layer_size),torch.zeros(1, 1, model.hidden_layer_size))seq_train = torch.FloatTensor(train_data[seq:seq + n_steps])label = torch.FloatTensor(train_data[seq + n_steps:seq + n_steps + 1])optimizer.zero_grad()y_pred = model(seq_train)single_loss = loss_function(y_pred, label)single_loss.backward()optimizer.step()if epoch % 50 == 0:print(f'Epoch {epoch+1} loss: {single_loss.item()}')return modeldef arima_model(train_data, order):model = ARIMA(train_data, order=order)model_fit = model.fit()return model_fitn_steps = 10
imfs_lstm = [3, 4]  # 分配给LSTM的IMFs索引
imfs_arima = [0, 1, 2]  # 分配给ARIMA的IMFs索引lstm_predictions = np.zeros(len(time_numeric))
arima_predictions = np.zeros(len(time_numeric))# LSTM预测
for idx in imfs_lstm:print(f'Training LSTM for IMF {idx+1}')train_data = imfs[idx].flatten()model = train_lstm_model(train_data, n_steps)for i in range(n_steps, len(train_data)):seq = torch.FloatTensor(train_data[i-n_steps:i])with torch.no_grad():lstm_predictions[i] += model(seq).item()print(f'LSTM predictions for IMF {idx+1} completed')# ARIMA预测
for idx in imfs_arima:print(f'Training ARIMA for IMF {idx+1}')train_data = imfs[idx]model_fit = arima_model(train_data, order=(5, 1, 0))arima_predictions += model_fit.predict(start=0, end=len(train_data) - 1)print(f'ARIMA predictions for IMF {idx+1} completed')# 合并预测结果
final_predictions = lstm_predictions + arima_predictions# 计算LSTM和ARIMA模型的误差
lstm_error = np.mean(ptb_cases - lstm_predictions)
arima_error = np.mean(ptb_cases - arima_predictions)# 根据误差平移预测结果
final_predictions += (lstm_error + arima_error) / 2# 计算误差
mae = mean_absolute_error(ptb_cases, final_predictions)
mse = mean_squared_error(ptb_cases, final_predictions)
rmse = np.sqrt(mse)
mape = np.mean(np.abs((ptb_cases - final_predictions) / ptb_cases)) * 100# 打印误差
print(f'MAE: {mae}')
print(f'MSE: {mse}')
print(f'RMSE: {rmse}')
print(f'MAPE: {mape}')# 绘制预测结果
plt.figure(figsize=(12, 6))
plt.plot(time_numeric, ptb_cases, label='Original Data')
plt.plot(time_numeric, final_predictions, label='Predicted Data')
plt.legend()
plt.show()

看看结果:

a16746d0046246e6b010ed115f534fd9.png

效果也不是太好。

 

六、最后

下一期,我们来测试一下其他矫正方法。

 

相关文章:

第100+33步 ChatGPT学习:时间序列EMD-ARIMA-LSTM模型

基于Python 3.9版本演示 一、写在前面 上一节&#xff0c;我们学了经验模态分解&#xff08;Empirical Mode Decomposition&#xff0c;EMD&#xff09;。 如同结尾所说&#xff0c;“那么&#xff0c;做这些分解有什么作用呢&#xff1f;有大佬基于这些分解出来的序列分别作…...

(C语言)双向链表

目录 链表的分类 双向链表的实现 1&#xff09;定义链表 2&#xff09;初始化双向链表 3&#xff09;申请节点 4&#xff09;尾插 5&#xff09;头插 6&#xff09;打印链表 7&#xff09;尾删 8&#xff09;头插 9&#xff09;查找 10&#xff09;指定位置删除 11…...

青少年编程与数学 02-004 Go语言Web编程 04课题、接收和处理请求

青少年编程与数学 02-004 Go语言Web编程 04课题、接收和处理请求 课题摘要:一、构建WEB服务器1. 安装Go语言2. 创建项目结构3. 编写代码4. 运行WEB服务器5. 访问WEB服务器 二、接收请求1. 定义处理函数&#xff08;Handler&#xff09;2. 将处理函数与路由关联3. 启动服务器4. …...

Unity全局光照详解

之前就学过但是太久没用又忘了&#xff0c;因此用最简洁易懂的语言做个记录。 全局光照分为两个系统&#xff0c;分别是实时光照和混合光照。&#xff08;点击window/Rendering/Lighing打开此面板&#xff09; 其中全局光照对于我来说都是新技术了&#xff0c;上一次学…...

计算机网络知识点全梳理(三.TCP知识点总结)

目录 TCP基本概念 为什么需要TCP 什么是TCP 什么是TCP链接 如何唯一确定一个 TCP 连接 TCP三次握手 握手流程 为什么是三次握手&#xff0c;而不是两次、四次 为什么客户端和服务端的初始序列号 ISN 不同 既然 IP 层会分片&#xff0c;为什么 TCP 层还需要 MSS TCP四…...

ELK Stack 安装、配置以及集成到 Java 微服务中的使用

ELK Stack 是由 Elasticsearch、Logstash 和 Kibana 组成的日志管理解决方案。以下是详细的安装、配置步骤以及如何将其集成到 Java 微服务中。 1. 安装 ELK Stack 1.1 安装 Elasticsearch 在 Ubuntu 上安装 Elasticsearch&#xff1a; bash wget -qO - https://artifacts…...

list_

1.对象创建 // // Created by 徐昌真 on 2024/12/12. // #include <iostream> #include <list>using namespace std;void Print(list<int> &my_list) {for ( list<int>::iterator iter my_list.begin(); iter ! my_list.end(); iter ){cout <…...

电机驱动,为什么不需要变速器?

在现代汽车和工业应用中&#xff0c;电机驱动的技术愈发成熟&#xff0c;其核心优势之一是能够省去传统机械变速器的需求。 一、电机驱动的基本原理 电机驱动又被称为电动机驱动&#xff0c;其基本原理是将电能转化为机械能。通过控制电机的输入电压和电流&#xff0c;电机能…...

how to write 述职pptx as a tech manager

As a technical manager, crafting an effective 述职 (performance review) PPT requires you to highlight your leadership, team accomplishments, technical contributions, challenges faced, and future plans. Heres a structured approach to design your PPT: 1. Cov…...

关于QMessageBox的一些使用总结和避坑指南

参考学习 Qt中QMessageBox的用法—看这一篇就够了 Qt&#xff1a;使用QMessageBox弹出标准对话框 QMessageBox模态与非模态及QT中的exec() 如何调整QMessageBox的大小 QSS 自定义QMessageBox python QMessageBox设置标签和按钮居中、中文按钮 使用建议 经过查看多方的资料&…...

C语言预处理详解

1.预定义符号 C语言设置了一些预定义符号&#xff0c;可以直接使用&#xff0c;预定义符号也是在预处理期间处理的 __FILE__ //进⾏编译的源⽂件 __LINE__ //⽂件当前的⾏号 __DATE__ //⽂件被编译的⽇期 __TIME__ //⽂件被编译的时间 __STDC__ //如果编译器遵循ANSI C&#…...

大语言模型画图(流程图、框架图)

第一步&#xff1a;向随意大语言模型&#xff0c;描述内容&#xff0c;推荐豆包 豆包 加上下面Prompt 通过Mermaid语法&#xff0c;描述上面流程图 第二步&#xff1a;将生成Mermaid输入流程图生成网站 中文Mermaid - 流程图、关系图在线画图、生成和编辑器...

2024年API接口发展趋势:智能化、自动化引领潮流

随着信息技术的飞速发展&#xff0c;应用程序编程接口&#xff08;API&#xff09;已成为现代软件开发的核心组成部分。API作为不同系统之间的桥梁&#xff0c;使得数据、功能和服务能够在各种平台和设备之间无缝流动。在2024年&#xff0c;API接口正经历着一系列显著的变革和发…...

数据挖掘与机器学习DMML(part 8)K近邻(KNN)

K Nearest Neighbours KNN Definition KNN 是一种简单的算法&#xff0c;它存储所有可用案例&#xff0c;并根据相似度量对新案例进行分类。 KNN 不同名称&#xff1a; K-Nearest Neighbors • Memory-Based Reasoning基于记忆的推理 • Example-Based Reasoning基于实例的…...

Fortify 24.2.0版本最新版 win/mac/linux

工具介绍&#xff1a; Fortify SCA作为一款业内主流的静态代码扫描工具&#xff0c;被广泛应用于白盒测试中。与其他静态代码扫描工具相比&#xff0c;Fortify SCA的突出优势主要在于更加广泛地支持的语言和开发平台、更全面和权威的安全规则库使扫描更加全面、更加智能化的自定…...

突破时间与空间限制的富媒体百宝箱——智能工具箱:让云上内容生产更easy

“这是你的同款日常吗&#xff1f;老是在赶deadline&#xff0c;苦练PS还未出师&#xff0c;premiere、达芬奇真的好难&#xff0c;学python脑容量确实不够~打工人太难了~~” 来试试智能工具箱吧&#xff01;即来即用&#xff0c;一键实现办公自由。图片工具、视频工具、音频工…...

MacOs使用Wine 安装UaExpert与UaExpert的使用

要在 macOS 上使用 Wine 安装和运行 UaExpert&#xff0c;可以按照以下步骤操作&#xff1a; 安装 Wine 在 macOS 上&#xff0c;你可以通过 Homebrew 来安装 Wine。如果你还没有安装 Homebrew&#xff0c;可以先安装 Homebrew&#xff0c;然后使用它来安装 Wine。 bash /bin…...

【Prompt Engineering】3.文本概括

一、引言 文本信息量大&#xff0c;LLM在文本概括任务上展现出强大能力。本章介绍如何通过编程方式调用API接口实现文本概括功能。 首先&#xff0c;我们需要引入 zhipuAI 包&#xff0c;加载 API 密钥&#xff0c;定义 getCompletion 函数。 from zhipuai import ZhipuAIke…...

力扣-图论-14【算法学习day.64】

前言 ###我做这类文章一个重要的目的还是给正在学习的大家提供方向和记录学习过程&#xff08;例如想要掌握基础用法&#xff0c;该刷哪些题&#xff1f;&#xff09;我的解析也不会做的非常详细&#xff0c;只会提供思路和一些关键点&#xff0c;力扣上的大佬们的题解质量是非…...

redis 架构详解

Redis架构详解可以从以下几个方面进行阐述&#xff1a; 一、部署架构 Redis有多种部署架构&#xff0c;适用于不同的应用场景和需求&#xff0c;主要包括以下几种&#xff1a; 单机模式&#xff08;Standalone Mode&#xff09; 特点&#xff1a;部署简单&#xff0c;配置方便…...

大话软工笔记—需求分析概述

需求分析&#xff0c;就是要对需求调研收集到的资料信息逐个地进行拆分、研究&#xff0c;从大量的不确定“需求”中确定出哪些需求最终要转换为确定的“功能需求”。 需求分析的作用非常重要&#xff0c;后续设计的依据主要来自于需求分析的成果&#xff0c;包括: 项目的目的…...

DockerHub与私有镜像仓库在容器化中的应用与管理

哈喽&#xff0c;大家好&#xff0c;我是左手python&#xff01; Docker Hub的应用与管理 Docker Hub的基本概念与使用方法 Docker Hub是Docker官方提供的一个公共镜像仓库&#xff0c;用户可以在其中找到各种操作系统、软件和应用的镜像。开发者可以通过Docker Hub轻松获取所…...

vue3 字体颜色设置的多种方式

在Vue 3中设置字体颜色可以通过多种方式实现&#xff0c;这取决于你是想在组件内部直接设置&#xff0c;还是在CSS/SCSS/LESS等样式文件中定义。以下是几种常见的方法&#xff1a; 1. 内联样式 你可以直接在模板中使用style绑定来设置字体颜色。 <template><div :s…...

微服务商城-商品微服务

数据表 CREATE TABLE product (id bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 商品id,cateid smallint(6) UNSIGNED NOT NULL DEFAULT 0 COMMENT 类别Id,name varchar(100) NOT NULL DEFAULT COMMENT 商品名称,subtitle varchar(200) NOT NULL DEFAULT COMMENT 商…...

使用 Streamlit 构建支持主流大模型与 Ollama 的轻量级统一平台

🎯 使用 Streamlit 构建支持主流大模型与 Ollama 的轻量级统一平台 📌 项目背景 随着大语言模型(LLM)的广泛应用,开发者常面临多个挑战: 各大模型(OpenAI、Claude、Gemini、Ollama)接口风格不统一;缺乏一个统一平台进行模型调用与测试;本地模型 Ollama 的集成与前…...

LINUX 69 FTP 客服管理系统 man 5 /etc/vsftpd/vsftpd.conf

FTP 客服管理系统 实现kefu123登录&#xff0c;不允许匿名访问&#xff0c;kefu只能访问/data/kefu目录&#xff0c;不能查看其他目录 创建账号密码 useradd kefu echo 123|passwd -stdin kefu [rootcode caozx26420]# echo 123|passwd --stdin kefu 更改用户 kefu 的密码…...

Go语言多线程问题

打印零与奇偶数&#xff08;leetcode 1116&#xff09; 方法1&#xff1a;使用互斥锁和条件变量 package mainimport ("fmt""sync" )type ZeroEvenOdd struct {n intzeroMutex sync.MutexevenMutex sync.MutexoddMutex sync.Mutexcurrent int…...

使用SSE解决获取状态不一致问题

使用SSE解决获取状态不一致问题 1. 问题描述2. SSE介绍2.1 SSE 的工作原理2.2 SSE 的事件格式规范2.3 SSE与其他技术对比2.4 SSE 的优缺点 3. 实战代码 1. 问题描述 目前做的一个功能是上传多个文件&#xff0c;这个上传文件是整体功能的一部分&#xff0c;文件在上传的过程中…...

Python爬虫(四):PyQuery 框架

PyQuery 框架详解与对比 BeautifulSoup 第一部分&#xff1a;PyQuery 框架介绍 1. PyQuery 是什么&#xff1f; PyQuery 是一个 Python 的 HTML/XML 解析库&#xff0c;它采用了 jQuery 的语法风格&#xff0c;让开发者能够用类似前端 jQuery 的方式处理文档解析。它的核心特…...

C/Python/Go示例 | Socket Programing与RPC

Socket Programming介绍 Computer networking这个领域围绕着两台电脑或者同一台电脑内的不同进程之间的数据传输和信息交流&#xff0c;会涉及到许多有意思的话题&#xff0c;诸如怎么确保对方能收到信息&#xff0c;怎么应对数据丢失、被污染或者顺序混乱&#xff0c;怎么提高…...