<commit_before>from Settings import DefineManager
from Utils import LoggingManager
from . import FirebaseDatabaseManager
import pandas as pd
import numpy as np
from fbprophet import Prophet

def LearningModuleRunner(rawArrayDatas, processId, forecastDay):
    LoggingManager.PrintLogMessage("LearningManager", "LearningModuleRunner", "start of learning #" + str(processId), DefineManager.LOG_LEVEL_INFO)

    numOfAlgorithmModules=3
    rmse={}
    realForecast={}
    mockForecast={}
    trainSize=int(len(rawArrayDatas) * 0.7)
    testSize=len(rawArrayDatas)-trainSize

    dataY = rawArrayDatas[1]
    testY = dataY[trainSize:]
    ############################################################### LSTM
    # 전처리
        # [[날짜],[판매량]] 형태 2D list -> pandas.core.frame.DataFrame의 형태의 [년, 월, 요일, 판매량]
        #TODO ds를 요일, 계절로 변환을 PrepareLstm()에서 시행
        #TODO 날씨, 경제 등의 feature 도 pandas DatFrame에 포함(PrepareLstm()에서)
    LoggingManager.PrintLogMessage("LearningManager", "LearningModuleRunner", "start", DefineManager.LOG_LEVEL_INFO)
        #전체 data 전처리
    XY=PrepareLstm(rawArrayDatas)
        #train data 추출(0.7)
    X = XY[0][:trainSize]
    Y = XY[1][:trainSize]
    trainXY=[X,Y]
    LoggingManager.PrintLogMessage("LearningManager", "LearningModuleRunner", "LSTMpreprocessing succeed", DefineManager.LOG_LEVEL_INFO)
    # 계산
        #trainXY로 testY 예측
    mockForecast['Lstm'] = Lstm(preprocessedData=trainXY, forecastDay=testSize)
        #전체 XY로 realForecast 예측
    realForecast['Lstm'] = Lstm(preprocessedData=XY, forecastDay=forecastDay)
    LoggingManager.PrintLogMessage("LearningManager", "LearningModuleRunner", "LSTMpredict succeed", DefineManager.LOG_LEVEL_INFO)
    # 평가
    testRmse=0
    for i in range(testSize):
        testRmse=testRmse + (testY[i] - mockForecast['Lstm'][i]) ** 2
    rmse['Lstm'] = testRmse
    LoggingManager.PrintLogMessage("LearningManager", "LearningModuleRunner", "LSTMevaluation succeed", DefineManager.LOG_LEVEL_INFO)

    ################################################################ BAYSEIAN
    # 전처리 raw data를 preprocessed data(ds-y)로 변환하는 과정
        #[[날짜],[판매량]] 형태 2D list -> pandas.core.frame.DataFrame의 형태의 [날짜, 판매량]

        # 전체 data 전처리
    XY = PrepareBayseian(rawArrayDatas)
        # train data 추출(0.7)
    X = XY[0][:trainSize]
    Y = XY[1][:trainSize]
    trainXY=[X,Y]
    LoggingManager.PrintLogMessage("LearningManager", "LearningModuleRunner", "BAYSEIANpreprocessing succeed", DefineManager.LOG_LEVEL_INFO)
    #계산
        # trainXY로 testY 예측
    mockForecast['Bayseian'] = Bayseian(preprocessedData=trainXY, forecastDay=testSize)[0]<commit_msg>pandas type error fix<commit_after>from Settings import DefineManager
from Utils import LoggingManager
from . import FirebaseDatabaseManager
import pandas as pd
import numpy as np
from fbprophet import Prophet

def LearningModuleRunner(rawArrayDatas, processId, forecastDay):
    LoggingManager.PrintLogMessage("LearningManager", "LearningModuleRunner", "start of learning #" + str(processId), DefineManager.LOG_LEVEL_INFO)

    numOfAlgorithmModules=3
    rmse={}
    realForecast={}
    mockForecast={}
    trainSize=int(len(rawArrayDatas) * 0.7)
    testSize=len(rawArrayDatas)-trainSize

    dataY = rawArrayDatas[1]
    testY = dataY[trainSize:]
    ############################################################### LSTM
    # 전처리
        # [[날짜],[판매량]] 형태 2D list -> pandas.core.frame.DataFrame의 형태의 [년, 월, 요일, 판매량]
        #TODO ds를 요일, 계절로 변환을 PrepareLstm()에서 시행
        #TODO 날씨, 경제 등의 feature 도 pandas DatFrame에 포함(PrepareLstm()에서)
    LoggingManager.PrintLogMessage("LearningManager", "LearningModuleRunner", "start", DefineManager.LOG_LEVEL_INFO)
        #전체 data 전처리
    XY=PrepareLstm(rawArrayDatas)
        #train data 추출(0.7)
    X = XY[0][:trainSize]
    Y = XY[1][:trainSize]
    trainXY=[X,Y]
    LoggingManager.PrintLogMessage("LearningManager", "LearningModuleRunner", "LSTMpreprocessing succeed", DefineManager.LOG_LEVEL_INFO)
    # 계산
        #trainXY로 testY 예측
    mockForecast['Lstm'] = Lstm(preprocessedData=trainXY, forecastDay=testSize)
        #전체 XY로 realForecast 예측
    realForecast['Lstm'] = Lstm(preprocessedData=XY, forecastDay=forecastDay)
    LoggingManager.PrintLogMessage("LearningManager", "LearningModuleRunner", "LSTMpredict succeed", DefineManager.LOG_LEVEL_INFO)
    # 평가
    testRmse=0
    for i in range(testSize):
        testRmse=testRmse + (testY[i] - mockForecast['Lstm'][i]) ** 2
    rmse['Lstm'] = testRmse
    LoggingManager.PrintLogMessage("LearningManager", "LearningModuleRunner", "LSTMevaluation succeed", DefineManager.LOG_LEVEL_INFO)

    ################################################################ BAYSEIAN
    # 전처리 raw data를 preprocessed data(ds-y)로 변환하는 과정
        #[[날짜],[판매량]] 형태 2D list -> pandas.core.frame.DataFrame의 형태의 [날짜, 판매량]

        # 전체 data 전처리
    XY = PrepareBayseian(rawArrayDatas)
        # train data 추출(0.7)
    X = XY.iloc[:trainSize,0]
    Y =XY.iloc[:trainSize,1]
    trainXY=[X,Y]
    LoggingManager.PrintLogMessage("LearningManager", "LearningModuleRunner", "BAYSEIANpreprocessing succeed", DefineManager.LOG_LEVEL_INFO)
    #계산
        # trainXY로 testY 예측
    mockForecast['Bayseian'] = Bayseian(preprocessedData=trainXY, forecastDay=testSize)[0]
{'fraction_non_alphanumeric': 0.1540216771249287, 'fraction_numerical': 0.00646510743487355, 'mean_word_length': 4.589798087141339, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1514305', 'n_tokens_mistral': 1948, 'n_tokens_neox': 2014, 'n_words': 344}