当前位置:首页>python>【时间序列机器学习】Python01-时间序列自回归模型(AR)拟合及可视化

【时间序列机器学习】Python01-时间序列自回归模型(AR)拟合及可视化

  • 2026-01-31 19:19:56
【时间序列机器学习】Python01-时间序列自回归模型(AR)拟合及可视化
时间序列机器学习
01时间序列自回归模型(Autoregressive model,AR模型)拟合及可视化
Python(标准化代码)
01
概念、原理、思想、应用

概念:用自身过去值的线性组合来预测未来值。

原理:AR(p)模型:X_t = c + Σφ_i X_{t-i} + ε_t,其中p是阶数,φ是参数,ε是白噪声。

思想:时间序列的当前值可以用过去值的线性组合来解释。

应用:预测平稳时间序列。

可视化:拟合值与实际值的对比图,残差图。

公共卫生意义:可用于预测疾病发病数,帮助资源分配。

02
操作流程

-数据预处理:

-模型构建:

-训练:

-评估:

-可视化:

-保存结果:

03
代码及操作演示与功能解析

时间序列机器学习模型大致可以分为三类:经典统计模型、传统机器学习模型 和 深度学习模型。

 一、 经典统计模型

这类模型基于序列自身的统计特性(如自相关性、趋势性、季节性)进行建模。

 二、 传统机器学习模型

这类模型将时间序列问题转化为监督学习问题,利用特征工程来捕捉时序模式。

 三、 深度学习模型

这类模型能自动从原始序列数据中学习复杂的时序依赖关系和非线性模式。

时间序列数据的可视化方法

1.  线图: 最基础、最核心的可视化。横轴为时间,纵轴为观测值。用于直观展示趋势、季节性、异常值。

2.  自相关图和偏自相关图:

       ACF: 展示时间序列与其自身各阶滞后之间的相关性。用于识别MA模型的阶数`q`和序列的周期性。

       PACF: 展示在控制中间滞后项后,序列与某阶滞后项之间的纯粹相关性。用于识别AR模型的阶数`p`。

3.  季节图: 将多年的数据按季节周期(如月、周)叠加在一张图上,用于清晰地观察季节性模式以及模式是否随时间变化。

4.  子序列图: 将时间序列分解为多个子序列(如每年的数据),并绘制在同一张图中,便于比较不同周期的模式。

5.  箱线图: 按时间周期(如月份、星期几)对数据进行分组并绘制箱线图,用于观察数据在不同周期内的分布情况(中位数、四分位数、异常值)。

6.  热力图: 常用于展示一天内不同小时、一周内不同天的模式(如网站流量、电力负荷)。

7.  分解图: 将时间序列分解为趋势、季节性 和残差 三个部分,分别进行可视化,帮助我们理解数据的构成。

8.  预测结果对比图: 将历史数据、真实值和模型的预测值绘制在同一张图上,是评估模型性能最直观的方式。

import osimport pandas as pdimport numpy as npimport matplotlib.pyplot as pltimport seaborn as snsfrom datetime import datetime, timedeltaimport warningswarnings.filterwarnings('ignore')# 统计和模型相关from statsmodels.tsa.stattools import adfuller, kpss, pacffrom statsmodels.tsa.arima.model import ARIMAfrom statsmodels.tsa.statespace.sarimax import SARIMAXfrom sklearn.metrics import mean_squared_error, mean_absolute_errorimport scipy.stats as stats# 报告生成from docx import Documentfrom docx.shared import Inchesimport matplotlib.pyplot as pltclass ARModelAnalyzer:    def __init__(self):        self.desktop_path = os.path.join(os.path.expanduser("~"), "Desktop")        self.results_path = os.path.join(self.desktop_path, "Results时间AR")        self.create_directories()# 设置中文字体        plt.rcParams['font.sans-serif'] = ['SimHei''Microsoft YaHei']        plt.rcParams['axes.unicode_minus'] = False        self.selected_diseases = ["influenza""common_cold""pneumonia","bacillary_dysentery""hand_foot_mouth""hemorrhagic_fever"        ]    def create_directories(self):"""创建必要的目录结构"""        directories = ["Models""Plots""Forecasts""Diagnostics""Word_Report"]for dir_name in directories:            dir_path = os.path.join(self.results_path, dir_name)if not os.path.exists(dir_path):                os.makedirs(dir_path)print(f"创建结果目录: {self.results_path}")    def load_data(self):"""加载数据"""        data_path = os.path.join(self.desktop_path, "Results""combined_weather_disease_data.csv")        try:            self.combined_data = pd.read_csv(data_path)            self.combined_data['timestamp'] = pd.to_datetime(self.combined_data['timestamp'])print("数据加载成功!")print(f"数据形状: {self.combined_data.shape}")return True        except Exception as e:print(f"数据加载失败: {e}")return False    def split_data(self):"""划分训练集和测试集"""        train_start = '1981-01-01'        train_end = '2015-12-31'        test_start = '2016-01-01'        test_end = '2025-12-31'        self.train_data = self.combined_data[            (self.combined_data['timestamp'] >= train_start) &            (self.combined_data['timestamp'] <= train_end)            ].copy()        self.test_data = self.combined_data[            (self.combined_data['timestamp'] >= test_start) &            (self.combined_data['timestamp'] <= test_end)            ].copy()print(f"训练集时间范围: {self.train_data['timestamp'].min()} 至 {self.train_data['timestamp'].max()}")print(f"测试集时间范围: {self.test_data['timestamp'].min()} 至 {self.test_data['timestamp'].max()}")print(f"训练集样本数: {len(self.train_data)}")print(f"测试集样本数: {len(self.test_data)}")    def fast_stationarity_test(self, ts_data):"""快速平稳性检验"""# 处理全零序列if np.all(ts_data == 0) or np.std(ts_data) == 0:return {'is_stationary': True,'p_value': 1,'cv_mean': 0,'cv_var': 0            }# 使用KPSS检验        try:            kpss_result = kpss(ts_data, nlags='auto')            kpss_pvalue = kpss_result[1]        except:            kpss_pvalue = np.nan# 简单的视觉检验:检查均值方差是否大致稳定        n_segments = 4        segment_length = len(ts_data) // n_segmentsif segment_length < 10:            n_segments = 2        means = []        vars_ = []for i in range(n_segments):            start_idx = i * segment_length            end_idx = (i + 1) * segment_length if i < n_segments - 1 else len(ts_data)            segment = ts_data[start_idx:end_idx]            means.append(np.mean(segment))            vars_.append(np.var(segment))# 如果均值或方差的变异系数 > 0.5,认为不平稳        cv_mean = np.std(means) / np.mean(means) if np.mean(means) != 0 else 1        cv_var = np.std(vars_) / np.mean(vars_) if np.mean(vars_) != 0 else 1        is_stationary = (kpss_pvalue > 0.05 if not np.isnan(kpss_pvalue) else True) and cv_mean < 0.5 and cv_var < 0.5return {'is_stationary': is_stationary,'p_value': kpss_pvalue,'cv_mean': cv_mean,'cv_var': cv_var        }    def safe_ar_order_selection(self, ts_data, max_order=10):"""安全确定AR阶数"""# 处理全零或常数序列if np.all(ts_data == 0) or np.std(ts_data) == 0:return 1        n = len(ts_data)        max_order = min(max_order, n // 4)  # 更保守的最大阶数if max_order < 1:return 1# 使用PACF的截尾性确定阶数        try:            pacf_vals = pacf(ts_data, nlags=max_order, method='ywm')            significant_lags = np.where(np.abs(pacf_vals[1:]) > 1.96 / np.sqrt(n))[0] + 1if len(significant_lags) > 0:                optimal_p = min(np.max(significant_lags), 5)  # 限制最大阶数为5else:                optimal_p = 1        except:            optimal_p = 1# 确保在合理范围内        optimal_p = max(1, min(optimal_p, max_order))return optimal_p
# 最终回退到均值模型                class MeanModel:                    def __init__(self, mean_value):                        self.params = [mean_value]                        self.aic = np.nan                        self.bic = np.nan                        self.call = "mean_model"                    def forecast(self, steps):return np.full(steps, self.params[0])return MeanModel(np.mean(ts_data[~np.isnan(ts_data)]))    def calculate_metrics(self, actual, forecast):"""计算评估指标"""if len(actual) != len(forecast) or len(actual) == 0:return {'rmse': np.nan, 'mae': np.nan, 'mape': np.nan}        rmse = np.sqrt(mean_squared_error(actual, forecast))        mae = mean_absolute_error(actual, forecast)if np.mean(actual) > 0:            mape = np.mean(np.abs((actual - forecast) / actual)) * 100else:            mape = np.nanreturn {'rmse': rmse, 'mae': mae, 'mape': mape}    def create_batch_plots(self, disease, train_ts, test_ts, ar_model, ar_forecast, optimal_p, test_metrics):"""创建批量图形"""        try:# 准备数据            train_dates = self.train_data['timestamp'].values            test_dates = self.test_data['timestamp'].values# 获取拟合值            try:if hasattr(ar_model, 'fittedvalues'):                    fitted_values = ar_model.fittedvalueselse:                    fitted_values = np.full(len(train_ts), np.nan)            except:                fitted_values = np.full(len(train_ts), np.nan)# 1. 完整序列图            full_dates = np.concatenate([train_dates, test_dates])            full_actual = np.concatenate([train_ts, test_ts])            full_fitted = np.concatenate([fitted_values, np.full(len(test_ts), np.nan)])            full_forecast = np.concatenate([np.full(len(train_ts), np.nan), ar_forecast])            fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(12, 10))
# 完整序列图            ax1.plot(full_dates, full_actual, label='实际值', linewidth=0.6, color='blue')            ax1.plot(full_dates[:len(train_ts)], fitted_values, label='拟合值', linewidth=0.4, color='green', alpha=0.7)            ax1.plot(full_dates[len(train_ts):], ar_forecast, label='预测值', linewidth=0.6, color='red')            ax1.axvline(x=train_dates[-1], color='gray', linestyle='--', alpha=0.7)            ax1.set_title(f'{disease} - AR模型完整时间序列\nAR({optimal_p}), MAPE: {test_metrics["mape"]:.2f}%')            ax1.set_xlabel('日期')            ax1.set_ylabel('病例数')            ax1.legend()            ax1.grid(True, alpha=0.3)# 2. 测试集详细图(只显示最近几年)            recent_start = pd.Timestamp('2015-01-01')            mask = full_dates >= recent_start            recent_dates = full_dates[mask]            recent_actual = full_actual[mask]            recent_forecast = full_forecast[mask]            ax2.plot(recent_dates, recent_actual, label='实际值', linewidth=0.8, color='black')            ax2.plot(recent_dates, recent_forecast, label='预测值', linewidth=0.8, color='red')            ax2.axvline(x=pd.Timestamp('2016-01-01'), color='blue', linestyle='--')            ax2.set_title(                f'{disease} - 测试集预测对比\nRMSE: {test_metrics["rmse"]:.2f}, MAE: {test_metrics["mae"]:.2f}')            ax2.set_xlabel('日期')            ax2.set_ylabel('病例数')            ax2.legend()            ax2.grid(True, alpha=0.3)            plt.tight_layout()# 保存图形            plt.savefig(os.path.join(self.results_path, 'Plots', f'Full_Series_{disease}.png'),                        dpi=150, bbox_inches='tight')            plt.close()return True        except Exception as e:print(f"创建图形时出错: {e}")return False    def analyze_disease(self, disease):"""分析单个疾病"""        try:print(f"正在分析 {disease}...")# 提取时间序列            train_ts = self.train_data[disease].values.astype(float)            test_ts = self.test_data[disease].values.astype(float)# 处理NaN值            train_ts = np.nan_to_num(train_ts, nan=0)            test_ts = np.nan_to_num(test_ts, nan=0)# 处理全零序列if np.all(train_ts == 0) or np.std(train_ts) == 0:print(f"{disease} 为常数序列,使用简单预测...")                constant_value = 0 if np.all(train_ts == 0) else np.mean(train_ts)                test_forecast = np.full(len(test_ts), constant_value)                test_metrics = self.calculate_metrics(test_ts, test_forecast)# 创建简单图形                try:                    fig, ax = plt.subplots(figsize=(12, 6))                    ax.plot(self.train_data['timestamp'], train_ts, label='训练集', linewidth=0.6)                    ax.plot(self.test_data['timestamp'], test_ts, label='测试集实际值', linewidth=0.6)                    ax.plot(self.test_data['timestamp'], test_forecast, label='预测值', linewidth=0.6, color='red')                    ax.set_title(f'{disease} - 常数序列预测')                    ax.set_xlabel('日期')                    ax.set_ylabel('病例数')                    ax.legend()                    ax.grid(True, alpha=0.3)                    plt.savefig(os.path.join(self.results_path, 'Plots', f'Full_Series_{disease}.png'),                                dpi=150, bbox_inches='tight')                    plt.close()                except Exception as e:print(f"图形创建失败: {e}")# 返回结果                result_df = pd.DataFrame({'Disease': [disease],'AR_Order': [0],'Diff_Order': [0],'AIC': [np.nan],'BIC': [np.nan],'Test_RMSE': [test_metrics['rmse']],'Test_MAE': [test_metrics['mae']],'Test_MAPE': [test_metrics['mape']]                })return result_df# 1. 快速平稳性检验            stationarity = self.fast_stationarity_test(train_ts)if not stationarity['is_stationary']:print(f"{disease} 序列不平稳,进行一阶差分...")                train_ts_diff = np.diff(train_ts)                diff_order = 1else:                train_ts_diff = train_ts                diff_order = 0# 2. 安全确定AR阶数            optimal_p = self.safe_ar_order_selection(train_ts_diff, max_order=8)print(f"{disease} 最优AR阶数: {optimal_p}")# 3. 安全拟合AR模型            ar_model = self.safe_arima_fit(train_ts, order_vec=(optimal_p, diff_order, 0), method='css')# 4. 预测            forecast_horizon = len(test_ts)            try:if hasattr(ar_model, 'forecast'):                    ar_forecast = ar_model.forecast(steps=forecast_horizon)else:                    ar_forecast = ar_model.forecast(forecast_horizon)            except:print("预测失败,使用最后观测值")                last_value = train_ts[-1] if len(train_ts) > 0 else 0                ar_forecast = np.full(forecast_horizon, last_value)# 5. 计算评估指标            test_forecast = ar_forecast[:len(test_ts)]            test_actual = test_ts[:len(test_forecast)]            test_metrics = self.calculate_metrics(test_actual, test_forecast)# 6. 图形输出            self.create_batch_plots(disease, train_ts, test_ts, ar_model, ar_forecast, optimal_p, test_metrics)# 7. 保存预测结果            forecast_df = pd.DataFrame({'Date': self.test_data['timestamp'].values[:len(test_forecast)],'Actual': test_actual,'Forecast': test_forecast,'Error': test_actual - test_forecast            })            forecast_df.to_csv(os.path.join(self.results_path, 'Forecasts', f'Forecast_Results_{disease}.csv'),                               index=False)# 8. 返回结果            aic = ar_model.aic if hasattr(ar_model, 'aic'else np.nan            bic = ar_model.bic if hasattr(ar_model, 'bic'else np.nan            result_df = pd.DataFrame({'Disease': [disease],'AR_Order': [optimal_p],'Diff_Order': [diff_order],'AIC': [aic],'BIC': [bic],'Test_RMSE': [test_metrics['rmse']],'Test_MAE': [test_metrics['mae']],'Test_MAPE': [test_metrics['mape']]            })print(f"{disease} 分析完成! MAPE: {test_metrics['mape']:.2f}%")return result_df        except Exception as e:print(f"分析 {disease} 时出错: {e}")# 返回一个包含NaN值的标准数据框return pd.DataFrame({'Disease': [disease],'AR_Order': [np.nan],'Diff_Order': [np.nan],'AIC': [np.nan],'BIC': [np.nan],'Test_RMSE': [np.nan],'Test_MAE': [np.nan],'Test_MAPE': [np.nan]            })    def create_summary_visualizations(self, model_results):"""创建汇总可视化"""print("创建汇总可视化...")
# 性能比较图(处理NaN值)        performance_data = model_results[~model_results['Test_MAPE'].isna()]if len(performance_data) > 0:            plt.figure(figsize=(10, 6))            performance_data = performance_data.sort_values('Test_MAPE', ascending=False)            bars = plt.bar(performance_data['Disease'], performance_data['Test_MAPE'], alpha=0.8)# 添加数值标签for bar in bars:                height = bar.get_height()                plt.text(bar.get_x() + bar.get_width() / 2., height + 0.1,                         f'{height:.1f}%', ha='center', va='bottom')            plt.title('AR模型预测性能比较\n测试集平均绝对百分比误差 (MAPE)')            plt.xlabel('疾病')            plt.ylabel('MAPE (%)')            plt.xticks(rotation=45)            plt.grid(True, alpha=0.3)            plt.tight_layout()            plt.savefig(os.path.join(self.results_path, 'Plots''Model_Performance_Comparison.png'),                        dpi=150, bbox_inches='tight')            plt.close()else:print("没有有效的MAPE数据创建性能比较图")# 准确度热力图        accuracy_data = model_results[['Disease''Test_RMSE''Test_MAE''Test_MAPE']].copy()        accuracy_long = accuracy_data.melt(id_vars=['Disease'],                                           value_vars=['Test_RMSE''Test_MAE''Test_MAPE'],                                           var_name='Metric', value_name='Value')# 移除NaN值        accuracy_long = accuracy_long[~accuracy_long['Value'].isna()]if len(accuracy_long) > 0:# 创建数据透视表            heatmap_data = accuracy_long.pivot(index='Disease', columns='Metric', values='Value')            plt.figure(figsize=(8, 6))            sns.heatmap(heatmap_data, annot=True, fmt='.2f', cmap='YlOrRd', cbar_kws={'label''误差值'})            plt.title('AR模型预测准确度热力图')            plt.tight_layout()            plt.savefig(os.path.join(self.results_path, 'Plots''Accuracy_Heatmap.png'),                        dpi=150, bbox_inches='tight')            plt.close()else:print("没有有效的准确度数据创建热力图")    def generate_summary_report(self, model_results, start_time, end_time):"""生成总结报告"""print("生成总结报告...")        report_path = os.path.join(self.results_path, 'Modeling_Summary_Report.txt')        with open(report_path, 'w', encoding='utf-8') as f:            f.write("=== AR模型建模优化总结报告 ===\n\n")            f.write(f"建模时间: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n")            f.write(f"总耗时: {(end_time - start_time).total_seconds() / 60:.2f} 分钟\n")            f.write("训练集范围: 1981-01-01 至 2015-12-31\n")            f.write("测试集范围: 2016-01-01 至 2025-12-31\n")            f.write(f"分析的疾病数量: {len(self.selected_diseases)}\n\n")            f.write("优化措施:\n")            f.write("- 使用pandas加速数据读取和处理\n")            f.write("- 简化平稳性检验流程\n")            f.write("- 使用PACF安全确定AR阶数\n")            f.write("- 使用CSS方法加速模型拟合\n")            f.write("- 增加错误处理和回退机制\n")            f.write("- 降低图形输出质量以加快保存速度\n\n")            f.write("各疾病模型性能:\n")            f.write(model_results.to_string(index=False))            f.write("\n\n性能排名 (按MAPE升序):\n")            ranked_models = model_results.sort_values('Test_MAPE', na_position='last')            f.write(ranked_models.to_string(index=False))# 安全获取最佳模型            valid_models = ranked_models[~ranked_models['Test_MAPE'].isna()]if len(valid_models) > 0:                best_model = valid_models.iloc[0]                best_mape = best_model['Test_MAPE']                avg_mape = valid_models['Test_MAPE'].mean()else:                best_model = None                best_mape = np.nan                avg_mape = np.nan            f.write(f"\n\n最佳预测模型: {best_model['Disease'] if best_model is not None else 'NA'}\n")            f.write(f"最佳MAPE: {best_mape:.2f}%\n"if not np.isnan(best_mape) else"最佳MAPE: NA\n")            f.write(f"平均MAPE: {avg_mape:.2f}%\n"if not np.isnan(avg_mape) else"平均MAPE: NA\n")            f.write("\n文件输出:\n")            f.write("1. Models/All_Model_Results.csv - 所有模型结果\n")            f.write("2. Plots/ - 汇总可视化图表\n")            f.write("3. Forecasts/ - 各疾病预测结果\n")            f.write("4. Modeling_Summary_Report.txt - 本报告\n")    def generate_word_report(self, model_results, ranked_models):"""生成Word分析报告"""print("生成Word分析报告...")        try:# 创建Word文档            doc = Document()# 标题页            doc.add_heading('AR模型时间序列分析报告', 0)            doc.add_paragraph(f"报告生成时间: {datetime.now().strftime('%Y年%m月%d日 %H:%M:%S')}")            doc.add_paragraph(f"分析疾病数量: {len(model_results)}")            doc.add_paragraph("训练集: 1981-2015")            doc.add_paragraph("测试集: 2016-2025")            doc.add_page_break()# 执行摘要            doc.add_heading('执行摘要', level=1)            doc.add_paragraph("本报告对6种主要传染病的时间序列数据进行了自回归(AR)模型分析。")# 安全添加最佳模型信息            valid_models = ranked_models[~ranked_models['Test_MAPE'].isna()]if len(valid_models) > 0:                best_model = valid_models.iloc[0]                best_mape = best_model['Test_MAPE']                avg_mape = valid_models['Test_MAPE'].mean()                doc.add_paragraph(f"最佳预测模型: {best_model['Disease']} (MAPE: {best_mape:.2f}%)")                doc.add_paragraph(f"平均预测准确率: {avg_mape:.2f}%")else:                doc.add_paragraph("所有模型均未能成功拟合")            doc.add_paragraph()# 方法学            doc.add_heading('方法学', level=1)            doc.add_paragraph("1. 数据划分: 使用1981-2015年数据作为训练集,2016-2025年数据作为测试集")            doc.add_paragraph("2. 平稳性检验: 使用KPSS检验和变异系数分析")            doc.add_paragraph("3. 模型选择: 基于PACF截尾性确定AR模型阶数")            doc.add_paragraph("4. 模型拟合: 使用条件平方和(CSS)方法拟合AR模型")            doc.add_paragraph("5. 预测评估: 使用RMSE、MAE和MAPE指标评估预测性能")            doc.add_paragraph()# 模型性能汇总表            doc.add_heading('模型性能汇总', level=1)            doc.add_paragraph()# 创建性能表格            table = doc.add_table(rows=len(model_results) + 1, cols=5)            table.style = 'Light Grid Accent 1'# 表头            headers = table.rows[0].cells            headers[0].text = '疾病'            headers[1].text = 'AR阶数'            headers[2].text = 'RMSE'            headers[3].text = 'MAE'            headers[4].text = 'MAPE'# 表格数据for i, (_, row) in enumerate(model_results.iterrows()):                cells = table.rows[i + 1].cells                cells[0].text = str(row['Disease'])                cells[1].text = str(row['AR_Order'])                cells[2].text = f"{row['Test_RMSE']:.2f}"if not np.isnan(row['Test_RMSE']) else'NA'                cells[3].text = f"{row['Test_MAE']:.2f}"if not np.isnan(row['Test_MAE']) else'NA'                cells[4].text = f"{row['Test_MAPE']:.2f}%"if not np.isnan(row['Test_MAPE']) else'NA'            doc.add_paragraph()# 详细分析            doc.add_heading('详细分析', level=1)            doc.add_paragraph()for _, row in ranked_models.iterrows():                doc.add_heading(f"疾病: {row['Disease']}", level=2)                doc.add_paragraph(f"AR阶数: {row['AR_Order']}")if not np.isnan(row['Test_MAPE']):                    doc.add_paragraph(f"MAPE: {row['Test_MAPE']:.2f}%")                    doc.add_paragraph(f"RMSE: {row['Test_RMSE']:.2f}")else:                    doc.add_paragraph("模型拟合失败")                doc.add_paragraph()# 结论与建议            doc.add_heading('结论与建议', level=1)            doc.add_paragraph("1. AR模型在传染病时间序列预测中表现出良好的性能")            doc.add_paragraph("2. 不同疾病的预测难度存在显著差异")            doc.add_paragraph("3. 建议对高MAPE的疾病考虑更复杂的模型或引入外部变量")            doc.add_paragraph("4. 模型可用于传染病预警和资源规划")# 保存文档            doc.save(os.path.join(self.results_path, 'Word_Report''AR模型分析报告.docx'))print("Word报告生成成功!")        except Exception as e:print(f"生成Word报告时出错: {e}")    def run_analysis(self):"""运行完整分析"""print("开始AR模型时间序列分析...")        start_time = datetime.now()# 1. 加载数据if not self.load_data():return# 2. 划分数据        self.split_data()# 3. 分析所有疾病print("开始分析所有疾病...")        model_results_list = []for disease in self.selected_diseases:            result = self.analyze_disease(disease)            model_results_list.append(result)# 合并结果        model_results = pd.concat(model_results_list, ignore_index=True)        end_time = datetime.now()print(f"分析完成,耗时: {(end_time - start_time).total_seconds() / 60:.2f} 分钟")# 4. 保存模型结果        model_results.to_csv(os.path.join(self.results_path, 'Models''All_Model_Results.csv'), index=False)# 5. 创建汇总可视化        self.create_summary_visualizations(model_results)# 6. 生成总结报告        self.generate_summary_report(model_results, start_time, end_time)# 7. 生成Word报告        ranked_models = model_results.sort_values('Test_MAPE', na_position='last')        self.generate_word_report(model_results, ranked_models)# 8. 最终总结print("\n=== AR模型建模优化完成 ===")print(f"总分析疾病数量: {len(self.selected_diseases)}")print(f"总耗时: {(end_time - start_time).total_seconds() / 60:.2f} 分钟")print(f"输出文件位置: {self.results_path}\n")# 安全显示最终结果        valid_results = model_results[~model_results['Test_MAPE'].isna()]if len(valid_results) > 0:            best_model = valid_results.loc[valid_results['Test_MAPE'].idxmin()]            worst_model = valid_results.loc[valid_results['Test_MAPE'].idxmax()]print(f"最佳预测模型: {best_model['Disease']}")print(f"最佳MAPE: {best_model['Test_MAPE']:.2f}%")print(f"最差MAPE: {worst_model['Test_MAPE']:.2f}%")print(f"平均MAPE: {valid_results['Test_MAPE'].mean():.2f}%")else:print("没有成功的模型拟合结果")print("\n详细报告请查看:")print(f"- 文本报告: {os.path.join(self.results_path, 'Modeling_Summary_Report.txt')}")print(f"- Word报告: {os.path.join(self.results_path, 'Word_Report', 'AR模型分析报告.docx')}")# 运行分析if __name__ == "__main__":    analyzer = ARModelAnalyzer()    analyzer.run_analysis()   

🔍01-时间序列自回归模型(AR)拟合及可视化

概念:自回归模型用时间序列的自身滞后值作为自变量来预测当前值,属于线性预测模型。

原理:AR(p)模型形式为:$X_t = c + \sum_{i=1}^p \phi_i X_{t-i} + \varepsilon_t$,其中p为滞后阶数,$\phi_i$为自回归系数,$\varepsilon_t$为白噪声。

思想:"历史影响现在",认为时间序列当前值可以由其过去有限个时刻的线性组合加上随机扰动来解释。

应用:气温、气压等气象要素的短期预测,疾病发病率的短期趋势外推。

可视化:

自相关图(ACF)和偏自相关图(PACF):用于确定模型阶数p

拟合值与实际值对比图:评估模型拟合效果

残差自相关图:检验模型残差是否满足白噪声假设

公共卫生意义:基于历史疾病数据预测短期发病趋势,为医疗资源调配提供参考。

医学统计数据分析分享交流SPSS、R语言、Python、ArcGis、Geoda、GraphPad、数据分析图表制作等心得。承接数据分析,论文返修,医学统计,机器学习,生存分析,空间分析,问卷分析业务。若有投稿和数据分析代做需求,可以直接联系我,谢谢!

!!!可加我粉丝群!!!

“医学统计数据分析”公众号右下角;

找到“联系作者”,

可加我微信,邀请入粉丝群!

【医学统计数据分析】工作室“粉丝群”
01
【临床】粉丝群

有临床流行病学数据分析

如(t检验、方差分析、χ2检验、logistic回归)、

(重复测量方差分析与配对T检验、ROC曲线)、

(非参数检验、生存分析、样本含量估计)、

(筛检试验:灵敏度、特异度、约登指数等计算)、

(绘制柱状图、散点图、小提琴图、列线图等)、

机器学习、深度学习、生存分析

等需求的同仁们,加入【临床】粉丝群

02
【公卫】粉丝群

疾控,公卫岗位的同仁,可以加一下【公卫】粉丝群,分享生态学研究、空间分析、时间序列、监测数据分析、时空面板技巧等工作科研自动化内容。

03
【生信】粉丝群

有实验室数据分析需求的同仁们,可以加入【生信】粉丝群,交流NCBI(基因序列)、UniProt(蛋白质)、KEGG(通路)、GEO(公共数据集)等公共数据库、基因组学转录组学蛋白组学代谢组学表型组学等数据分析和可视化内容。

或者可扫码直接加微信进群!!!

精品视频课程-“医学统计数据分析”视频号付费合集

“医学统计数据分析”视频号-付费合集兑换相应课程后,获取课程理论课PPT、代码、基础数据等相关资料,请大家在【医学统计数据分析】公众号右下角,找到“联系作者”,加我微信后打包发送。感谢您的支持!!

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-02-07 13:32:37 HTTP/2.0 GET : https://f.mffb.com.cn/a/470472.html
  2. 运行时间 : 3.199639s [ 吞吐率:0.31req/s ] 内存消耗:4,991.69kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=b56f731078b49138684b4c439bacdde6
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.001002s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001405s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.101272s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.101215s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001616s ]
  6. SELECT * FROM `set` [ RunTime:0.101021s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000678s ]
  8. SELECT * FROM `article` WHERE `id` = 470472 LIMIT 1 [ RunTime:0.100852s ]
  9. UPDATE `article` SET `lasttime` = 1770442358 WHERE `id` = 470472 [ RunTime:2.254731s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.076095s ]
  11. SELECT * FROM `article` WHERE `id` < 470472 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.041996s ]
  12. SELECT * FROM `article` WHERE `id` > 470472 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.027416s ]
  13. SELECT * FROM `article` WHERE `id` < 470472 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.157683s ]
  14. SELECT * FROM `article` WHERE `id` < 470472 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.117667s ]
  15. SELECT * FROM `article` WHERE `id` < 470472 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.036557s ]
3.201061s