第十届 泰迪杯数据挖掘挑战赛-B题-第二题--突变预测

第十届 泰迪杯数据挖掘挑战赛-B题-第二题--突变预测,第1张

 详细代码

🍞正在为您运送作品详情https://mianbaoduo.com/o/bread/Ypmck51q

from adtk.data import validate_series
import os
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sb
from pylab import rcParams
import math
import scipy.stats as st
import statistics
from statsmodels.tsa.stattools import adfuller
import statsmodels as sm
def sumzip(*items):
    return [sum(values) for values in zip(*items)]

%matplotlib inline

meses = ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez']

def sumzip(*items):
    return [sum(values) for values in zip(*items)]

def draw_mean (X, Y) :
    X_mean = np.mean(X)
    Y_mean = np.mean(Y)
    num = 0
    den = 0
    for i in range (len(X)) :
        num += (X[i] - X_mean) * (Y[i] - Y_mean)
        den += (X[i] - X_mean) ** 2
    m = num/den
    c = Y_mean - m * X_mean
    Y_pred = m * X + c
    plt.plot([min(X), max(X)], [min(Y_pred), max(Y_pred)], color = 'red')


def inclui_nan(db, index):
    
    print("Iniciando tratamento de " + index)
    
    for idx, row in db.iterrows():
        if math.isnan(row[index]):
            database.loc[idx,index] = database[database["mes"] == row.mes].eval(index).mean();

def tratar_outlier(db, index):
    
    print("Iniciando tratamento de " + index)
    
    lim = 3 #outliers extremos


;;;;
;;;
;;;
;;略



    for key, value in result[4].items():
        print('\t%s: %.3f' % (key, value))
    if result[1]<=0.05:
        print("Strong evidence against Null Hypothesis")
        print("Reject Null Hypothesis - Data is Stationary")
    else:
        print("Strong evidence for  Null Hypothesis")
        print("Accept Null Hypothesis - Data is not Stationary")
        
def mean_absolute_percentage_error(y_true, y_pred): 
    y_true, y_pred = np.array(y_true), np.array(y_pred)
    return np.mean(np.abs((y_true - y_pred) / y_true)) * 100

 

 

 

 

 

 

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/737386.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-28
下一篇 2022-04-28

发表评论

登录后才能评论

评论列表(0条)

保存