工具系列:TimeGPT_(9)模型交叉验证

交叉验证

文章目录

    • 交叉验证
    • 外生变量
    • 比较不同的模型

时间序列预测中的主要挑战之一是随着时间的推移固有的不确定性和变异性,因此验证所采用的模型的准确性和可靠性至关重要。交叉验证是一种强大的模型验证技术,特别适用于此任务,因为它提供了有关模型在未见数据上的预期性能的见解,确保在实际场景中部署之前,预测是可靠和有弹性的。

TimeGPT 理解时间序列预测的复杂需求,融合了 cross_validation 方法,旨在简化时间序列模型的验证过程。这个功能使从业者能够对历史数据严格测试他们的预测模型,评估它们的有效性,同时调整它们以获得最佳性能。本教程将指导您完成在 TimeGPT 类中进行交叉验证的微妙过程,确保您的时间序列预测模型不仅构建良好,而且经过验证是值得信赖和精确的。

# 导入colab_badge模块,用于生成Colab徽章
from nixtlats.utils import colab_badge
colab_badge('docs/tutorials/9_cross_validation')
# 导入必要的库
import numpy as np
from dotenv import load_dotenv
# 加载dotenv模块,用于从.env文件中加载环境变量
load_dotenv()
True
# 导入pandas库
import pandas as pd
# 导入TimeGPT类
from nixtlats import TimeGPT

# 创建TimeGPT对象,并传入token参数
# 如果没有传入token参数,则默认使用环境变量中的TIMEGPT_TOKEN
timegpt = TimeGPT(token='my_token_provided_by_nixtla'
)
# 创建一个TimeGPT对象,用于生成时间相关的文本。
timegpt = TimeGPT()

TimeGPT类中的cross_validation方法是一种高级功能,用于对时间序列预测模型进行系统验证。该方法需要一个包含按时间排序的数据的数据帧,并采用滚动窗口方案来精确评估模型在不同时间段的性能,从而确保模型的可靠性和稳定性。

关键参数包括freq,它表示数据的频率,如果未指定,则会自动推断。id_coltime_coltarget_col参数分别指定每个系列的标识符、时间步长和目标值的列。该方法通过参数进行自定义,例如n_windows表示评估模型的独立时间窗口的数量,step_size确定这些窗口之间的间隔。如果未指定step_size,则默认为预测的时间范围h

该过程还允许通过finetune_steps进行模型细化,指定在新数据上进行模型微调的迭代次数。通过clean_ex_first参数可以管理数据预处理,决定是否在预测之前清理外生信号。此外,该方法还支持通过date_features参数从时间数据进行增强特征工程,该参数可以自动生成关键的与日期相关的特征,也可以接受自定义函数进行定制特征创建。date_features_to_one_hot参数进一步支持将分类日期特征转换为适合机器学习模型的格式。

在执行过程中,cross_validation在每个窗口中评估模型的预测准确性,提供了模型性能随时间变化和过度拟合的稳健视图。这种详细评估确保生成的预测不仅准确,而且在不同的时间背景下保持一致。

# 读取数据集
pm_df = pd.read_csv('https://raw.githubusercontent.com/Nixtla/transfer-learning-time-series/main/datasets/peyton_manning.csv')# 使用timegpt库的cross_validation函数对数据进行交叉验证
# 参数说明:
# - pm_df: 待验证的数据集
# - h: 预测的时间步数
# - n_windows: 窗口数量,用于划分训练集和验证集
# - time_col: 时间列的列名
# - target_col: 目标列的列名
# - freq: 时间频率,这里设定为每天
timegpt_cv_df = timegpt.cross_validation(pm_df, h=7, n_windows=5, time_col='timestamp', target_col='value', freq='D',
)# 打印交叉验证结果的前几行
timegpt_cv_df.head()
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Preprocessing dataframes...
INFO:nixtlats.timegpt:Calling Forecast Endpoint...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Preprocessing dataframes...
INFO:nixtlats.timegpt:Calling Forecast Endpoint...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Preprocessing dataframes...
INFO:nixtlats.timegpt:Calling Forecast Endpoint...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Preprocessing dataframes...
INFO:nixtlats.timegpt:Calling Forecast Endpoint...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Preprocessing dataframes...
INFO:nixtlats.timegpt:Calling Forecast Endpoint...
INFO:nixtlats.timegpt:Validating inputs...
timestampcutoffvalueTimeGPT
02015-12-172015-12-167.5918627.939553
12015-12-182015-12-167.5288697.887512
22015-12-192015-12-167.1716577.766617
32015-12-202015-12-167.8913317.931502
42015-12-212015-12-168.3600718.312632
# 导入IPython.display模块中的display函数from IPython.display import display
# 从timegpt_cv_df数据框中获取唯一的cutoff值,并赋值给变量cutoffs
cutoffs = timegpt_cv_df['cutoff'].unique()# 遍历cutoffs中的每个cutoff值
for cutoff in cutoffs:# 使用timegpt.plot函数绘制图形,并将结果赋值给变量fig# 绘图所需的数据为pm_df的最后100行和timegpt_cv_df中cutoff等于当前遍历值的行,删除列'cutoff'和'value'# 指定时间列为'timestamp',目标列为'value'fig = timegpt.plot(pm_df.tail(100), timegpt_cv_df.query('cutoff == @cutoff').drop(columns=['cutoff', 'value']),time_col='timestamp', target_col='value')# 显示图形display(fig)

为了评估TimeGPT在分布预测方面的性能,您可以使用level参数生成预测区间。

# 导入所需模块和函数# 使用timegpt.cross_validation函数进行时间序列交叉验证
# 参数pm_df为待验证的时间序列数据
# 参数h为预测的时间步长,这里设置为7
# 参数n_windows为窗口数量,这里设置为5
# 参数time_col为时间列的列名,这里设置为'timestamp'
# 参数target_col为目标列的列名,这里设置为'value'
# 参数freq为时间序列的频率,这里设置为'D',表示按天
# 参数level为置信水平,这里设置为[80, 90],表示计算80%和90%的置信区间
# 返回值timegpt_cv_df为交叉验证结果的数据框
timegpt_cv_df = timegpt.cross_validation(pm_df, h=7, n_windows=5, time_col='timestamp', target_col='value', freq='D',level=[80, 90],
)
# 输出交叉验证结果的前几行数据
timegpt_cv_df.head()
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Preprocessing dataframes...
INFO:nixtlats.timegpt:Restricting input...
INFO:nixtlats.timegpt:Calling Forecast Endpoint...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Preprocessing dataframes...
INFO:nixtlats.timegpt:Restricting input...
INFO:nixtlats.timegpt:Calling Forecast Endpoint...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Preprocessing dataframes...
INFO:nixtlats.timegpt:Restricting input...
INFO:nixtlats.timegpt:Calling Forecast Endpoint...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Preprocessing dataframes...
INFO:nixtlats.timegpt:Restricting input...
INFO:nixtlats.timegpt:Calling Forecast Endpoint...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Preprocessing dataframes...
INFO:nixtlats.timegpt:Restricting input...
INFO:nixtlats.timegpt:Calling Forecast Endpoint...
INFO:nixtlats.timegpt:Validating inputs...
timestampcutoffvalueTimeGPTTimeGPT-lo-90TimeGPT-lo-80TimeGPT-hi-80TimeGPT-hi-90
02015-12-172015-12-167.5918627.9395537.5641517.6759458.2031618.314956
12015-12-182015-12-167.5288697.8875127.5673427.5982988.1767268.207681
22015-12-192015-12-167.1716577.7666177.1465607.2668298.2664048.386674
32015-12-202015-12-167.8913317.9315027.4930217.6570758.2059298.369982
42015-12-212015-12-168.3600718.3126327.0173357.4466779.1785869.607928
# 获取时间截断点的唯一值
cutoffs = timegpt_cv_df['cutoff'].unique()# 遍历每个截断点
for cutoff in cutoffs:# 绘制图表fig = timegpt.plot(# 绘制最近100个数据点pm_df.tail(100), # 查询截断点等于当前截断点的数据,并删除'cutoff'和'value'列timegpt_cv_df.query('cutoff == @cutoff').drop(columns=['cutoff', 'value']),# 设置时间列为'timestamp'time_col='timestamp', # 设置目标列为'value'target_col='value',# 设置置信水平为[80, 90]level=[80, 90],# 设置模型为'TimeGPT'models=['TimeGPT'])# 显示图表display(fig)

您还可以包括date_features以查看它们对预测准确性的影响。

# 对于给定的时间序列数据,进行时间序列交叉验证
# 使用timegpt.cross_validation函数进行交叉验证
# 参数说明:
# - pm_df: 待验证的时间序列数据
# - h: 预测的时间步长
# - n_windows: 窗口的数量,将时间序列数据划分为多个窗口进行交叉验证
# - time_col: 时间列的名称,用于指定时间序列数据中的时间信息
# - target_col: 目标列的名称,用于指定时间序列数据中的目标变量
# - freq: 时间序列数据的频率,以天为单位
# - level: 置信水平,用于计算预测区间
# - date_features: 日期特征,用于提取时间序列数据中的日期信息
# 返回值为交叉验证结果的数据框
timegpt_cv_df = timegpt.cross_validation(pm_df, h=7, n_windows=5, time_col='timestamp', target_col='value', freq='D',level=[80, 90],date_features=['month'],
)# 输出交叉验证结果的前几行数据
timegpt_cv_df.head()
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Preprocessing dataframes...
INFO:nixtlats.timegpt:Using the following exogenous variables: month_1, month_2, month_3, month_4, month_5, month_6, month_7, month_8, month_9, month_10, month_11, month_12
INFO:nixtlats.timegpt:Calling Forecast Endpoint...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Preprocessing dataframes...
INFO:nixtlats.timegpt:Using the following exogenous variables: month_1, month_2, month_3, month_4, month_5, month_6, month_7, month_8, month_9, month_10, month_11, month_12
INFO:nixtlats.timegpt:Calling Forecast Endpoint...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Preprocessing dataframes...
INFO:nixtlats.timegpt:Using the following exogenous variables: month_1, month_2, month_3, month_4, month_5, month_6, month_7, month_8, month_9, month_10, month_11, month_12
INFO:nixtlats.timegpt:Calling Forecast Endpoint...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Preprocessing dataframes...
INFO:nixtlats.timegpt:Using the following exogenous variables: month_1, month_2, month_3, month_4, month_5, month_6, month_7, month_8, month_9, month_10, month_11, month_12
INFO:nixtlats.timegpt:Calling Forecast Endpoint...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Preprocessing dataframes...
INFO:nixtlats.timegpt:Using the following exogenous variables: month_1, month_2, month_3, month_4, month_5, month_6, month_7, month_8, month_9, month_10, month_11, month_12
INFO:nixtlats.timegpt:Calling Forecast Endpoint...
INFO:nixtlats.timegpt:Validating inputs...
timestampcutoffvalueTimeGPTTimeGPT-lo-90TimeGPT-lo-80TimeGPT-hi-80TimeGPT-hi-90
02015-12-172015-12-167.5918627.9453117.5423667.6478528.2427698.348255
12015-12-182015-12-167.5288697.8925597.2712747.4810598.3040588.513843
22015-12-192015-12-167.1716577.7715817.1135447.2817118.2614518.429619
32015-12-202015-12-167.8913317.9395026.9881987.3453718.5336338.890807
42015-12-212015-12-168.3600718.3201707.1401637.6583148.9820279.500178
# 获取时间戳的唯一值
cutoffs = timegpt_cv_df['cutoff'].unique()# 遍历每个唯一的时间戳
for cutoff in cutoffs:# 使用timegpt.plot函数绘制图形# 参数1:使用pm_df的最后100行数据作为输入数据# 参数2:使用timegpt_cv_df中cutoff等于当前遍历的时间戳的数据,删除cutoff和value列作为输入数据# 参数3:指定时间戳列为timestamp# 参数4:指定目标值列为value# 参数5:指定80和90为置信水平# 参数6:指定使用TimeGPT模型fig = timegpt.plot(pm_df.tail(100), timegpt_cv_df.query('cutoff == @cutoff').drop(columns=['cutoff', 'value']),time_col='timestamp', target_col='value',level=[80, 90],models=['TimeGPT'])# 显示图形display(fig)

外生变量

此外,您可以传递外生变量以更好地向TimeGPT提供关于数据的信息。您只需在目标列之后简单地添加外生回归变量即可。

# 读取电力数据集Y_df,数据来自'https://raw.githubusercontent.com/Nixtla/transfer-learning-time-series/main/datasets/electricity.csv'
Y_df = pd.read_csv('https://raw.githubusercontent.com/Nixtla/transfer-learning-time-series/main/datasets/electricity.csv')# 读取外部变量数据集X_df,数据来自'https://raw.githubusercontent.com/Nixtla/transfer-learning-time-series/main/datasets/exogenous-vars-electricity.csv'
X_df = pd.read_csv('https://raw.githubusercontent.com/Nixtla/transfer-learning-time-series/main/datasets/exogenous-vars-electricity.csv')# 将Y_df和X_df数据集进行合并,合并后的数据集为df
df = Y_df.merge(X_df)

现在让我们使用这些信息对TimeGPT进行交叉验证。

# 导入TimeGPT模型
timegpt = TimeGPT(max_retries=2, retry_interval=5)  # 创建TimeGPT对象,设置最大重试次数为2,重试间隔为5秒
# 导入的库已经存在,不需要添加import语句# 对数据进行交叉验证,将数据按照unique_id分组,每组取最后的100*48个数据进行交叉验证
# h=48表示预测未来48个时间点的值,n_windows=2表示将数据分为两个窗口进行交叉验证
# level=[80, 90]表示计算80%和90%置信区间
timegpt_cv_df_x = timegpt.cross_validation(df.groupby('unique_id').tail(100 * 48), h=48, n_windows=2,level=[80, 90]
)# 查询unique_id为"BE"的数据的cutoff值,并将其存储在cutoffs中
cutoffs = timegpt_cv_df_x.query('unique_id == "BE"')['cutoff'].unique()# 遍历cutoffs中的每个cutoff值,对unique_id为"BE"的数据进行预测并绘制图表
for cutoff in cutoffs:# 绘制unique_id为"BE"的数据的最后24*7个时间点的真实值和预测值,并将其存储在fig中# timegpt_cv_df_x.query('cutoff == @cutoff & unique_id == "BE"')表示查询cutoff值为当前遍历到的cutoff值,unique_id为"BE"的数据# drop(columns=['cutoff', 'y'])表示删除查询结果中的cutoff和y两列# models=['TimeGPT']表示使用TimeGPT模型进行预测# level=[80, 90]表示计算80%和90%置信区间fig = timegpt.plot(df.query('unique_id == "BE"').tail(24 * 7), timegpt_cv_df_x.query('cutoff == @cutoff & unique_id == "BE"').drop(columns=['cutoff', 'y']),models=['TimeGPT'],level=[80, 90],)# 显示图表display(fig)
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Inferred freq: H
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Preprocessing dataframes...
INFO:nixtlats.timegpt:Inferred freq: H
WARNING:nixtlats.timegpt:The specified horizon "h" exceeds the model horizon. This may lead to less accurate forecasts. Please consider using a smaller horizon.
INFO:nixtlats.timegpt:Using the following exogenous variables: Exogenous1, Exogenous2, day_0, day_1, day_2, day_3, day_4, day_5, day_6
INFO:nixtlats.timegpt:Calling Forecast Endpoint...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Preprocessing dataframes...
INFO:nixtlats.timegpt:Inferred freq: H
WARNING:nixtlats.timegpt:The specified horizon "h" exceeds the model horizon. This may lead to less accurate forecasts. Please consider using a smaller horizon.
INFO:nixtlats.timegpt:Using the following exogenous variables: Exogenous1, Exogenous2, day_0, day_1, day_2, day_3, day_4, day_5, day_6
INFO:nixtlats.timegpt:Calling Forecast Endpoint...
INFO:nixtlats.timegpt:Validating inputs...

比较不同的模型

此外,您可以使用model参数为不同的TimeGPT实例生成交叉验证。

# 对数据进行交叉验证
timegpt_cv_df_x_long_horizon = timegpt.cross_validation(df.groupby('unique_id').tail(100 * 48),  # 对数据进行分组,每个组取最后的100 * 48个数据h=48,  # 预测的时间步长为48n_windows=2,  # 使用2个窗口进行交叉验证level=[80, 90],  # 设置置信水平为80%和90%model='timegpt-1-long-horizon',  # 使用timegpt-1-long-horizon模型
)# 将列名中的'TimeGPT'替换为'TimeGPT-LongHorizon'
timegpt_cv_df_x_long_horizon.columns = timegpt_cv_df_x_long_horizon.columns.str.replace('TimeGPT', 'TimeGPT-LongHorizon')# 将timegpt_cv_df_x_long_horizon与timegpt_cv_df_x进行合并
timegpt_cv_df_x_models = timegpt_cv_df_x_long_horizon.merge(timegpt_cv_df_x)# 获取unique_id为"BE"的数据的cutoff值
cutoffs = timegpt_cv_df_x_models.query('unique_id == "BE"')['cutoff'].unique()# 对每个cutoff值进行循环
for cutoff in cutoffs:# 绘制图形fig = timegpt.plot(df.query('unique_id == "BE"').tail(24 * 7),  # 获取unique_id为"BE"的最后24 * 7个数据timegpt_cv_df_x_models.query('cutoff == @cutoff & unique_id == "BE"').drop(columns=['cutoff', 'y']),  # 获取cutoff和unique_id为"BE"的数据,并删除'cutoff'和'y'列models=['TimeGPT', 'TimeGPT-LongHorizon'],  # 绘制'TimeGPT'和'TimeGPT-LongHorizon'模型的图形level=[80, 90],  # 设置置信水平为80%和90%)# 显示图形display(fig)
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Inferred freq: H
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Preprocessing dataframes...
INFO:nixtlats.timegpt:Inferred freq: H
INFO:nixtlats.timegpt:Using the following exogenous variables: Exogenous1, Exogenous2, day_0, day_1, day_2, day_3, day_4, day_5, day_6
INFO:nixtlats.timegpt:Calling Forecast Endpoint...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Validating inputs...
INFO:nixtlats.timegpt:Preprocessing dataframes...
INFO:nixtlats.timegpt:Inferred freq: H
INFO:nixtlats.timegpt:Using the following exogenous variables: Exogenous1, Exogenous2, day_0, day_1, day_2, day_3, day_4, day_5, day_6
INFO:nixtlats.timegpt:Calling Forecast Endpoint...
INFO:nixtlats.timegpt:Validating inputs...

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/581022.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

抗原设计与兔单B细胞技术的结合-卡梅德生物

随着生物医学研究的不断深入,抗体疗法作为治疗疾病的有力工具逐渐成为研究的焦点。而兔单B细胞技术作为抗体研究的创新方法,其与抗原设计的有机结合为获取定制抗体打开了崭新的创新之路。本文将深入探讨抗原设计与兔单B细胞技术相互融合的原理、优势&…

使用 GitHub 进行团队协作的操作指南

目录 前言1 使用github进行团队开发的意义2 邀请成员加入团队3 克隆和提交代码3.1 克隆远程仓库到本地3.2 加入暂存区3.3 提交修改到本地仓库3.4 设置本地仓库和远程仓库的关联3.5 将本地仓库的代码推送到远程仓库 结语 前言 GitHub 是一个广泛使用的基于 Git 的代码托管平台&…

Java - 获取 Jar 包内的 pom.xml 文件

目录 一.引言 二.通过 jar 命令 ◆ 查看 Jar 包内文件 ◆ 导出 Pom.xml ◆ 导出 Jar 包内文件 三.通过 unzip 命令 ◆ 导出 Jar 包内文件 四.总结 一.引言 引用其他同学的 Jar 包时,需要获取其对应 jar 包内的 pom.xml 文件检查版本依赖关系,下…

MYSQL存储过程和存储函数-数据库实验五

Mysql数据库实验及练习题相关 MySQL 数据库和表的管理-数据库实验一 MySQL连接查询、索引、视图-数据库实验二、实验三 MySQL约束、触发器-数据库实验四 MYSQL存储过程和存储函数-数据库实验五 MySQL批量随机生成name、TEL、idNumber MYSQL数据库的安全管理-数据库实验六 MYSQ…

基于JetCache整合实现一级、二级缓存方案(方案实现)

目录 一、整体方案说明 1.1 需求说明 1.2 整体方案实现组件结构图 二、Caffeine缓存实现 2.1 组件说明 2.2 组件结构图 2.3 组件Maven依赖 2.4 组件功能实现源码 2.4.1 CaffeineCacheManager扩展实现 2.4.2 CaffeineConfiguration配置类实现 2.4.3 涉及其他组件的类 …

如何在Android Termux中使用SFTP实现远程传输文件

文章目录 1. 安装openSSH2. 安装cpolar3. 远程SFTP连接配置4. 远程SFTP访问5. 配置固定远程连接地址6、结语 SFTP(SSH File Transfer Protocol)是一种基于SSH(Secure Shell)安全协议的文件传输协议。与FTP协议相比,SFT…

Spring Boot 中的虚拟线程

在本文中,我将讨论 Spring Boot 中的虚拟线程。 什么是虚拟线程? 虚拟线程作为 Java 中的一项功能引入,旨在简化并发性。 Virtual threads 是 轻量级的线程,由 Java Virtual Machine 而不是操作系统管理。它们被设计为易于使用且…

npm run dev 生成network网址无法被同局域网下的其他主机访问

当使用 npm run dev 运行开发服务器时,通常该服务器只会监听本地主机(localhost),这意味着只有在运行服务器的计算机上可以访问。如果你希望其他主机也能够访问该开发服务器,你可能需要配置服务器以监听所有可用的网络…

知识付费小程序如何搭建?

随着互联网的发展和人们对知识的渴求,知识付费行业正逐渐崭露头角。而其中,知识付费小程序因其便捷性、个性化等特点,成为了越来越多人的首选。那么,如何搭建一个知识付费小程序呢?本文将为你揭秘从零到一的全过程&…

for参数 命令语句 变量

for 参数f skip命令语句 命令说明: 跳过文本内容(行):skip 例子: for /f "skip1" %%i in(2.txt) do echo %%i for 参数f eol命令语句 命令说明: 怱略指定字符的文本内容(文本首部…

ElasticSearch:centos7安装elasticsearch7,kibana,ik中文分词器,云服务器安装elasticsearch

系统:centos7 elasticsearch: 7.17.16 安装目录:/usr/local 云服务器的安全组:开放 9200 和5601的端口 一、下载安装elasticsearch7.17.16 1、安装 #进入安装目录 cd /usr/local#下载elasticsearch wget https://artifacts.elastic.co/d…

Elasticsearch:在不停机的情况下优化 Elasticsearch Reindex

实现零停机、高效率和成功迁移更新的指南。更多阅读:Elasticsearch:如何轻松安全地对实时 Elasticsearch 索引 reindex 你的数据。 在使用 Elasticsearch 的时候,总会有需要修改索引映射的时候,遇到这种情况,我们只能做…

前端实现websocket类封装

随着Web应用程序的发展,越来越多的人开始利用Websocket技术来构建实时应用程序。Websocket是一种在客户端和服务器之间建立持久连接的协议。这种协议可以在一个单独的连接上实现双向通信。与HTTP请求-响应模型不同,Websocket允许服务器自主地向客户端发送…

想要学会JVM调优,先掌握JVM内存模型和JVM运行原理

1、前言 今天将和你一起探讨Java虚拟机(JVM)的性能调优。 JVM算是面试中的高频问题了,通常情况下总会有人问到:请你讲解下 JVM 的内存模型,JVM 的 性能调优做过? 2、为什么 JVM 在 Java 中如此重要 首…

ansible加密

本章主要介绍如何对ansible中的playbook 进行加密。 对整个playbook进行加密查看加密文件运行加密的playbook对playbook进行解密使用密码文件对单个字符串进行加密 前面写了许多playbook,这些playbook都是以明文的方式存在的,有时想对这些 playbook进…

利用网络教育系统构建个性化学习平台

在现代教育中,网络教育系统作为一种创新的学习方式,为学生提供了更加个性化和灵活的学习体验。在本文中,我们将通过简单的技术代码,演示如何构建一个基础的网络教育系统,为学生提供个性化的学习路径和资源。 1. 环境…

在Go语言中实现HTTP请求的缓存

大家好,我是你们可爱的编程小助手,今天我们要一起探讨如何使用Go语言实现HTTP请求的缓存。听起来是不是很酷?让我们开始吧! 首先,我们要明白什么是缓存。简单来说,缓存就是将数据存储在内存中,…

从 WasmEdge 运行环境读写 Rust Wasm 应用的时序数据

WebAssembly (Wasm) 正在成为一个广受欢迎的编译目标,帮助开发者构建可迁移平台的应用。最近 Greptime 和 WasmEdge 协作,支持了在 WasmEdge 平台上的 Wasm 应用通过 MySQL 协议读写 GreptimeDB 中的时序数据。 什么是 WebAssembly WebAssembly 是一种…

Mysql中 distinct 和 group by 哪个效率高?

结论 先说结论 有索引的情况下:group by和distinct都能使用索引,效率相同 无索引的情况下:distinct效率高于group by。原因是distinct 和 group by都会进行分组操作,但group by可能会进行排序,触发filesort&#xff…

DevC++ easyx 从图片放缩理解双线性插值意义

很久就想实现的一个功能,图片能够拖动,图片能够通过视口局部显示,但是图片放大缩小还是解决。 于是心心念念半年过去了。 恰逢校园地图大作业,按意思来说是可视化,想着能不能改改代码,搓一个地图&#xf…