arimax.py 文件源码

python
阅读 42 收藏 0 点赞 0 评论 0

项目:pyflux 作者: RJT1990 项目源码 文件源码
def plot_fit(self, **kwargs):
        """ 
        Plots the fit of the model against the data
        """
        import matplotlib.pyplot as plt
        import seaborn as sns

        figsize = kwargs.get('figsize',(10,7))
        plt.figure(figsize=figsize)
        date_index = self.index[max(self.ar, self.ma):self.data.shape[0]]
        mu, Y = self._model(self.latent_variables.get_z_values())

        # Catch specific family properties (imply different link functions/moments)
        if self.model_name2 == "Exponential":
            values_to_plot = 1.0/self.link(mu)
        elif self.model_name2 == "Skewt":
            t_params = self.transform_z()
            model_scale, model_shape, model_skewness = self._get_scale_and_shape(t_params)
            m1 = (np.sqrt(model_shape)*sp.gamma((model_shape-1.0)/2.0))/(np.sqrt(np.pi)*sp.gamma(model_shape/2.0))
            additional_loc = (model_skewness - (1.0/model_skewness))*model_scale*m1
            values_to_plot = mu + additional_loc
        else:
            values_to_plot = self.link(mu)

        plt.plot(date_index, Y, label='Data')
        plt.plot(date_index, values_to_plot, label='ARIMA model', c='black')
        plt.title(self.data_name)
        plt.legend(loc=2)   
        plt.show()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号