第100+1步 ChatGPT文献复现:ARIMAX预测肺结核 vol. 1

2024-03-12 07:36

本文主要是介绍第100+1步 ChatGPT文献复现:ARIMAX预测肺结核 vol. 1,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

基于WIN10的64位系统演示

一、写在前面

各位大佬,好久不见。

《100步入门机器学习》肝完了,不懂大家学了多少了,默认你们都学完了吧。

今年我们换一个玩法(灌水):一系列更接近实战的教程,复现一些经典的文献。

姑且叫做《100+X步入门机器学习》!

首先,从ARIMAX模型开始,龙年第一篇:

《PLoS One》杂志的2023年一篇题目为《A comparative study of three models to analyze the impact of air pollutants on the number of pulmonary tuberculosis cases in Urumqi, Xinjiang》文章的公开数据做案例。

这文章做的是用:空气污染物对新疆乌鲁木齐肺结核病例数影响的比较研究。

为了让大家一步一个脚印(多水教程),我就一次只弄1-2个结果咯。

二、学习和复现:结果一描述性分析

首先,结果一长这样:

1咒语

[复制结果2的图片]

请问这个论文结果使用了什么方法?

并给出python代码,同时运行这个代码,输出最终的输出图片

原始数据见附件“{pone.0277314.s006.xlsx}”,其中只需要使用前两列进行分析:“Time”以及“PTB cases”。

你可以一步一步来,进行完一步操作以后,保存结果,然后问我是否继续分析。我说继续分析,你才继续。

请用中回答。

输入咒语,跟着GPT回复:

这张论文结果图显示了时间序列分解,这通常涉及到将时间序列数据分解成趋势、季节性和随机成分。从图中可以看出,有四个子图分别代表原始的时间序列(PTB cases),季节性指数(Seasonal Index),趋势(Trend),以及周期性成分(Cycle)。

在Python中,可以使用statsmodels库的季节性分解功能进行这种分析。首先,我们需要加载数据并使用statsmodels中的seasonal_decompose函数。我将开始这个过程,首先加载数据,然后进行初步的时间序列分解。如果结果正确,我们可以继续进一步的分析步骤。

现在我会加载数据,并展示如何使用Python进行季节性分解。

(2)GPT也给出对应的代码:

import pandas as pd
from statsmodels.tsa.seasonal import seasonal_decompose
import matplotlib.pyplot as plt
# 加载数据,这次使用正确的列名
file_path = 'pone.0277314.s006.xlsx'
data_check = pd.read_excel(file_path)  # Load data to check the column names
corrected_column = data_check.columns[1]  # This is the actual column name with the invisible character# Now loading the data with the correct column name
data = pd.read_excel(file_path, usecols=['Time', corrected_column])# Convert 'Time' to datetime and set as the index for the data
data['Time'] = pd.to_datetime(data['Time'])
data.set_index('Time', inplace=True)# Perform the seasonal decomposition
decomposition = seasonal_decompose(data[corrected_column], model='additive', period=12)plt.rc('figure', figsize=(10, 8))  # Adjusting the size may help with layout issues# Plot the decomposition results
decomposition.plot()# Use tight layout to automatically adjust subplot parameters
plt.tight_layout()plt.subplots_adjust(left=0.05)  # 减少左侧边距# Save the decomposition plot to a file
fig = plt.gcf()  # Get the current figure object
adjusted_img_path = '/mnt/data/adjusted_decomposed_timeseries.png'
fig.savefig(adjusted_img_path, bbox_inches='tight')  # Save the figure with tight bounding box

给出代码的基本步骤和功能

1、使用pandas库加载Excel文件,并只选择了'Time'和'PTB cases'这两列。

2、将'Time'列转换为datetime对象,并设置为数据框的索引。

3、使用seasonal_decompose函数从statsmodels库中进行时间序列的季节性分解。

4、设置图表大小,绘制并展示分解结果。

5、保存结果图为PNG格式。

(3)试着在本地Python运行

在Spyder中输入:

可以运行,但是吧,左边空了一大片。

此时,你可以继续求助GPT,注意看我的咒语:

GPT给出优化方案:

图片左侧的空白区域可能是由于日期格式不正确或者是matplotlib在绘图时默认的布局设置导致的。解决这个问题的方法可以有以下几个:

检查和修正日期格式:确保时间序列是正确的datetime对象,并且是以正确的格式显示在x轴上。

使用紧凑布局:plt.tight_layout()可以自动调整子图参数,让它们更好地适应图表区域。

调整子图间距:使用plt.subplots_adjust()可以手动调整子图的布局设置。

修改图表尺寸:调整图表的尺寸以适应子图的显示。

优化x轴标签:如果x轴的刻度标签太长或者不必要,可以缩短它们或者完全移除。

这回答提醒了我:

因为原始数据的日期是中文格式:2014年1月,所以代码不支持。

我只需要把日期格式改为:2014-1,即可:

不过继续完善横坐标,也就是横坐标从2014-01开始,每隔三个月展示一个日期,2014-01、2014-03、一直到2018-12,这里就不演示了。

(4)我有一个大胆的想法

请使用英文帮我就这个图片写一段SCI论文的result,要求精简:

Results

Temporal Decomposition of PTB Cases in Urumqi

We employed time series decomposition to assess the patterns of PTB (Pulmonary Tuberculosis) cases in Urumqi from January 2014 to December 2018. The decomposition model allowed us to dissect the time series into four distinct components: observed, seasonal, trend, and residual.

The observed data (Fig. 2, top panel) indicates the number of PTB cases reported each month over the five-year period. Fluctuations in the data illustrate the dynamic nature of PTB incidence over time. The seasonal component (Fig. 2, second panel) reveals a consistent pattern repeating yearly, suggesting a regular influence of seasonal factors on PTB cases.

The trend component (Fig. 2, third panel) demonstrates a gradual decrease in the number of PTB cases over the years, signaling a promising downtrend in incidence. This decline may reflect the effectiveness of ongoing public health interventions and improvements in local healthcare practices.

Lastly, the cyclical component (Fig. 2, bottom panel), which captures fluctuations adjusted for seasonality and trend, suggests additional, irregular forces at play that periodically affect PTB case numbers. These could correspond to sporadic outbreaks or changes in reporting practices.

Our analysis underscores the multifaceted nature of PTB case dynamics in Urumqi, shaped by seasonal patterns, long-term trends, and irregular episodic factors. The discernible seasonal patterns highlight potential opportunities for targeted seasonal interventions, while the overall downward trend is indicative of successful long-term disease control measures in the region.

不错,写得很详细,下次不要描述的那么详细:

In the time series decomposition of PTB cases in Urumqi from January 2014 to December 2018, we observed a clear seasonal pattern and a long-term downward trend in cases. The decomposition highlights consistent seasonal fluctuations and suggests the effectiveness of health interventions over the studied period.

能不能用,大家自行对照原文,认真对照学习(看看怎么白嫖合适)。

三、个人感悟

利用GPT-4的多模态能力,不仅可以浏览和理解学术文献,还能直接提取其中的编程代码,并且在本地平台上即时运行这些代码,这极大地提高了研究(白嫖)和学习(偷懒)的效率。

四、数据

链接:https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0277314

这篇关于第100+1步 ChatGPT文献复现:ARIMAX预测肺结核 vol. 1的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/800547

相关文章

Spring AI集成DeepSeek的详细步骤

《SpringAI集成DeepSeek的详细步骤》DeepSeek作为一款卓越的国产AI模型,越来越多的公司考虑在自己的应用中集成,对于Java应用来说,我们可以借助SpringAI集成DeepSe... 目录DeepSeek 介绍Spring AI 是什么?1、环境准备2、构建项目2.1、pom依赖2.2

Deepseek R1模型本地化部署+API接口调用详细教程(释放AI生产力)

《DeepseekR1模型本地化部署+API接口调用详细教程(释放AI生产力)》本文介绍了本地部署DeepSeekR1模型和通过API调用将其集成到VSCode中的过程,作者详细步骤展示了如何下载和... 目录前言一、deepseek R1模型与chatGPT o1系列模型对比二、本地部署步骤1.安装oll

Spring AI Alibaba接入大模型时的依赖问题小结

《SpringAIAlibaba接入大模型时的依赖问题小结》文章介绍了如何在pom.xml文件中配置SpringAIAlibaba依赖,并提供了一个示例pom.xml文件,同时,建议将Maven仓... 目录(一)pom.XML文件:(二)application.yml配置文件(一)pom.xml文件:首

SpringBoot整合DeepSeek实现AI对话功能

《SpringBoot整合DeepSeek实现AI对话功能》本文介绍了如何在SpringBoot项目中整合DeepSeekAPI和本地私有化部署DeepSeekR1模型,通过SpringAI框架简化了... 目录Spring AI版本依赖整合DeepSeek API key整合本地化部署的DeepSeek

PyCharm接入DeepSeek实现AI编程的操作流程

《PyCharm接入DeepSeek实现AI编程的操作流程》DeepSeek是一家专注于人工智能技术研发的公司,致力于开发高性能、低成本的AI模型,接下来,我们把DeepSeek接入到PyCharm中... 目录引言效果演示创建API key在PyCharm中下载Continue插件配置Continue引言

Ubuntu系统怎么安装Warp? 新一代AI 终端神器安装使用方法

《Ubuntu系统怎么安装Warp?新一代AI终端神器安装使用方法》Warp是一款使用Rust开发的现代化AI终端工具,该怎么再Ubuntu系统中安装使用呢?下面我们就来看看详细教程... Warp Terminal 是一款使用 Rust 开发的现代化「AI 终端」工具。最初它只支持 MACOS,但在 20

Ilya-AI分享的他在OpenAI学习到的15个提示工程技巧

Ilya(不是本人,claude AI)在社交媒体上分享了他在OpenAI学习到的15个Prompt撰写技巧。 以下是详细的内容: 提示精确化:在编写提示时,力求表达清晰准确。清楚地阐述任务需求和概念定义至关重要。例:不用"分析文本",而用"判断这段话的情感倾向:积极、消极还是中性"。 快速迭代:善于快速连续调整提示。熟练的提示工程师能够灵活地进行多轮优化。例:从"总结文章"到"用

AI绘图怎么变现?想做点副业的小白必看!

在科技飞速发展的今天,AI绘图作为一种新兴技术,不仅改变了艺术创作的方式,也为创作者提供了多种变现途径。本文将详细探讨几种常见的AI绘图变现方式,帮助创作者更好地利用这一技术实现经济收益。 更多实操教程和AI绘画工具,可以扫描下方,免费获取 定制服务:个性化的创意商机 个性化定制 AI绘图技术能够根据用户需求生成个性化的头像、壁纸、插画等作品。例如,姓氏头像在电商平台上非常受欢迎,

从去中心化到智能化:Web3如何与AI共同塑造数字生态

在数字时代的演进中,Web3和人工智能(AI)正成为塑造未来互联网的两大核心力量。Web3的去中心化理念与AI的智能化技术,正相互交织,共同推动数字生态的变革。本文将探讨Web3与AI的融合如何改变数字世界,并展望这一新兴组合如何重塑我们的在线体验。 Web3的去中心化愿景 Web3代表了互联网的第三代发展,它基于去中心化的区块链技术,旨在创建一个开放、透明且用户主导的数字生态。不同于传统

AI一键生成 PPT

AI一键生成 PPT 操作步骤 作为一名打工人,是不是经常需要制作各种PPT来分享我的生活和想法。但是,你们知道,有时候灵感来了,时间却不够用了!😩直到我发现了Kimi AI——一个能够自动生成PPT的神奇助手!🌟 什么是Kimi? 一款月之暗面科技有限公司开发的AI办公工具,帮助用户快速生成高质量的演示文稿。 无论你是职场人士、学生还是教师,Kimi都能够为你的办公文