#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Nov 8 23:05:54 2017
@author: lu
"""
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from keras.layers.core import Activation, Dense
from keras.models import Sequential
from sklearn.linear_model import Lasso
"""
GM11-->自定義的灰度預測函
programmer_1-->讀取文件提取基本信息
programmer_2-->用自定義的灰度預測函數,進行預測
programmer_3-->建立神經網絡模型,進行預測並畫圖預測圖
programmer_4-->使用自定義的灰度預測模型進行預測一組數據,並且畫圖
"""
def GM11(x0):
# 1-AGO序列, 累計求和
x1 = np.cumsum(x0)
# 緊鄰均值(MEAN)生成序列
z1 = (x1[:-1] + x1[1:]) / 2.0
z1 = z1.reshape(len(z1), 1)
B = np.append(-z1, np.ones_like(z1), axis=1)
Yn = x0[1:].reshape((len(x0) - 1, 1))
# 矩陣計算,計算參數
[[a], [b]] = np.dot(np.dot(np.linalg.inv(np.dot(B.T, B)), B.T), Yn)
# 還原值