> For the complete documentation index, see [llms.txt](https://kerasnoone.gitbook.io/garnet/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kerasnoone.gitbook.io/garnet/xi-fen-ling-yu/shi-jian-xu-lie/0x04-ni-he-du-liang-fang-fa.md).

# 0x04 拟合度量方法

## 拟合度量

对于建立的时间序列模型, 常见的如ARIMA模型, 模型的质量如何, 评价方法需要考虑以下几个方面:

* 模型对数据集的描述能力, 体现了模型的拟合程度和预测准确的能力
* 模型本身的复杂度, 相同预测结果, 更简单的模型更合适

综合以上两者, 常用下面的几种方法对模型进行评价.

## AIC

**AIC, Akaike information criterion, 赤池信息量**:

$$AIC=2k-2\ln{L}$$

其中$$k$$模型变量的个数, 对于ARIMA模型, 就是`p+q`的值; $$L$$是损失函数, 通常使用**MSE**, 这在回归分析中有介绍, **MSE**即是**均方残差**, 即残差平方和除以对应的自由度, 是拟合结果与实际观测值之间差距的平方之和.

## BIC

**BIC, Bayesian information criterion, 贝叶斯信息量**:

$$BIC=\ln(n)k-2\ln{L}$$

使用**BIC**的优势在于: 在维数过大且训练样本数据相对较少的情况下, 可以有效避免出现维度灾难现象.

## AIC/BIC与Python

使用:

```python
from statsmodels.tsa.arima_model import ARIMA
```

模型得到的`statsmodels.tsa.arima.ARIMAResults`结果对象中, 包含了这两种度量方法拟合后的结果值. 可以使用这种度量, 对不同参数的ARIMA模型进行评价, 从中选取最好的模型来使用.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kerasnoone.gitbook.io/garnet/xi-fen-ling-yu/shi-jian-xu-lie/0x04-ni-he-du-liang-fang-fa.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
