From the mac

master
sanginnwoo 2022-10-21 12:58:10 +09:00
parent b96bda38cc
commit 62892ae0f0
3 changed files with 60 additions and 47 deletions

View File

@ -2,51 +2,52 @@ import settle_prediction_steps_main
import pandas as pd import pandas as pd
import os import os
input_dir = 'data_1' # 입력 파일이 있는 폴더명 지정: 사용자 직접 지정 필요
output_dir = 'output_1' input_dir = 'data'
# 침하 예측 결과 파일을 저장할 폴더명 지정: 사용자 직접 지정 필요
output_dir = 'output'
# 에러 분석 결과 파일을 저장할 폴더명 지정: 사용자 직접 지정 필요
output_error = 'error'
# 입력 파일의 이름을 저장할 리스트 초기화
input_files = [] input_files = []
df_overall = pd.DataFrame(columns=['File', 'Data_usage', # 일단 및 다단 성토를 포함한 예측의 에러를 저장할 데이터프레임 초기화
'RMSE_hyper_original', df_overall = pd.DataFrame(columns=['File', 'Data_usage', 'RMSE_hyper_original', 'RMSE_hyper_nonlinear',
'RMSE_hyper_nonlinear', 'Final_error_hyper_original', 'Final_error_hyper_nonlinear'])
'Final_error_hyper_original',
'Final_error_hyper_nonlinear'])
df_multi_step = pd.DataFrame(columns=['File', 'Data_usage', # 다단 성토만의 예측의 에러를 저장할 데이터프레임 초기화
'RMSE_hyper_original', df_multi_step = pd.DataFrame(columns=['File', 'Data_usage', 'RMSE_hyper_original', 'RMSE_hyper_nonlinear', 'RMSE_step',
'RMSE_hyper_nonlinear', 'Final_error_hyper_original', 'Final_error_hyper_nonlinear', 'Final_error_step'])
'RMSE_step',
'Final_error_hyper_original',
'Final_error_hyper_nonlinear',
'Final_error_step'])
# 입력 파일 저장 폴더에서 입력 파일의 이름을 파악하여 배열에 저장
for (root, directories, files) in os.walk(input_dir): # 입력 파일 안의 모든 파일에 대해서
for file in files: # 모든 파일 중 하나의 파일에 대해서
file_path = os.path.join(root, file) # 파일 경로를 포함한 파일명 설정
input_files.append(file_path) # 파일명을 배열에 저장
for (root, directories, files) in os.walk(input_dir): # 입력 파일명 저장소의 파일 하나에 대해서 예측을 수행하고, 결과값으로 잔차값을 받아서 저장
for file in files:
file_path = os.path.join(root, file)
input_files.append(file_path)
for input_file in input_files: for input_file in input_files:
# 최종 성토 이후 데이터 사용 영역에 대해서 [20 30 40 50 60 70 80 90]
for i in range(20, 100, 10): for i in range(20, 100, 10):
RETURN_VALUES = settle_prediction_steps_main.\ # 침하 예측을 수행하고 반환값 저장
return_values = settle_prediction_steps_main.\
run_settle_prediction(input_file, output_dir, i, 100, False, False) run_settle_prediction(input_file, output_dir, i, 100, False, False)
df_overall.loc[len(df_overall.index)] = [input_file, i, # 데이터프레임에 일단 및 다단 성토를 포함한 예측의 에러를 저장
RETURN_VALUES[0], df_overall.loc[len(df_overall.index)] = [input_file, i, return_values[0], return_values[1],
RETURN_VALUES[1], return_values[3], return_values[4]]
RETURN_VALUES[3],
RETURN_VALUES[4]]
if RETURN_VALUES[6]: # 데이터프레임에 다단 성토만에 대한 예측의 에러를 저장
df_multi_step.loc[len(df_overall.index)] = [input_file, i, if return_values[6]:
RETURN_VALUES[0], df_multi_step.loc[len(df_multi_step.index)] = [input_file, i, return_values[0], return_values[1],
RETURN_VALUES[1], return_values[2], return_values[3],
RETURN_VALUES[2], return_values[4], return_values[5]]
RETURN_VALUES[3],
RETURN_VALUES[4],
RETURN_VALUES[5]]
# 에러 파일 출력 # 에러 파일을 출력
df_overall.to_csv('Error_overall.csv') df_overall.to_csv(output_error + '/error_overall.csv')
df_multi_step.to_csv('Error_multi_step.csv') df_multi_step.to_csv(output_error + 'error_multi_step.csv')

View File

@ -11,7 +11,7 @@ import matplotlib.pyplot as plt
''' '''
# CSV 파일 읽기 (일단, 다단 성토 포함) # CSV 파일 읽기 (일단, 다단 성토 포함)
df_overall = pd.read_csv('Error_overall.csv', encoding='euc-kr') df_overall = pd.read_csv('error_overall.csv', encoding='euc-kr')
# 통계량 저장소 statistics 초기화 # 통계량 저장소 statistics 초기화
statistic =[] statistic =[]
@ -23,6 +23,9 @@ statistic =[]
# FE (O) # FE (O)
# FE (NL) # FE (NL)
# 카운트 초기화
count = 0
# 최종 성토 단계에서 각 침하 데이터 사용 영역에 대해서 다음을 수행 # 최종 성토 단계에서 각 침하 데이터 사용 영역에 대해서 다음을 수행
for data_usage in range(20, 100, 10): for data_usage in range(20, 100, 10):
@ -83,6 +86,9 @@ for data_usage in range(20, 100, 10):
plt.savefig('error_analysis/error_nonstep(%i percent).png' % data_usage, plt.savefig('error_analysis/error_nonstep(%i percent).png' % data_usage,
bbox_inches='tight') bbox_inches='tight')
# 카운트 증가
count = count + 1
# 데이터 사용 영역 설정 # 데이터 사용 영역 설정
data_usages = range(20, 100, 10) data_usages = range(20, 100, 10)
@ -163,6 +169,9 @@ statistic_step =[]
# FE (NL) # FE (NL)
# FE (S) # FE (S)
# 카운트 초기화
count = 0
# 최종 성토 단계에서 각 침하 데이터 사용 영역에 대해서 다음을 수행 # 최종 성토 단계에서 각 침하 데이터 사용 영역에 대해서 다음을 수행
for data_usage in range(20, 100, 10): for data_usage in range(20, 100, 10):
@ -239,6 +248,9 @@ for data_usage in range(20, 100, 10):
plt.savefig('error_analysis/error_step(%i percent).png' % data_usage, plt.savefig('error_analysis/error_step(%i percent).png' % data_usage,
bbox_inches='tight') bbox_inches='tight')
# 카운트 증가
count = count + 1
# 데이터 사용 영역 배열 설정 # 데이터 사용 영역 배열 설정
data_usages = range(20, 100, 10) data_usages = range(20, 100, 10)

View File

@ -309,15 +309,15 @@ def run_settle_prediction(input_file, output_dir,
final_step_monitor_end_index - final_step_predict_end_index] final_step_monitor_end_index - final_step_predict_end_index]
# RMSE 산정 (단계, 비선형 쌍곡선, 기존 쌍곡선) # RMSE 산정 (단계, 비선형 쌍곡선, 기존 쌍곡선)
RMSE_step = fun_rmse(sm_rmse, sp_step_rmse) rmse_step = fun_rmse(sm_rmse, sp_step_rmse)
RMSE_hyper_nonlinear = fun_rmse(sm_rmse, sp_hyper_nonlinear_rmse) rmse_hyper_nonlinear = fun_rmse(sm_rmse, sp_hyper_nonlinear_rmse)
RMSE_hyper_original = fun_rmse(sm_rmse, sp_hyper_original_rmse) rmse_hyper_original = fun_rmse(sm_rmse, sp_hyper_original_rmse)
# RMSE 출력 (단계, 비선형 쌍곡선, 기존 쌍곡선) # RMSE 출력 (단계, 비선형 쌍곡선, 기존 쌍곡선)
if print_values: if print_values:
print("RMSE (Nonlinear Hyper + Step): %0.3f" % RMSE_step) print("RMSE (Nonlinear Hyper + Step): %0.3f" % rmse_step)
print("RMSE (Nonlinear Hyperbolic): %0.3f" % RMSE_hyper_nonlinear) print("RMSE (Nonlinear Hyperbolic): %0.3f" % rmse_hyper_nonlinear)
print("RMSE (Original Hyperbolic): %0.3f" % RMSE_hyper_original) print("RMSE (Original Hyperbolic): %0.3f" % rmse_hyper_original)
# (최종 계측 침하량 - 예측 침하량) 계산 # (최종 계측 침하량 - 예측 침하량) 계산
final_error_step = np.abs(settle[-1] - sp_step_rmse[-1]) final_error_step = np.abs(settle[-1] - sp_step_rmse[-1])
@ -442,9 +442,9 @@ def run_settle_prediction(input_file, output_dir,
mybox = {'facecolor': 'white', 'edgecolor': 'black', 'boxstyle': 'round', 'alpha': 0.2} mybox = {'facecolor': 'white', 'edgecolor': 'black', 'boxstyle': 'round', 'alpha': 0.2}
plt.text(max(time), 0.25 * min(-settle), plt.text(max(time), 0.25 * min(-settle),
"Root Mean Squared Error" "Root Mean Squared Error"
+ "\n" + "Nonlinear + Step Loading: %0.3f" % RMSE_step + "\n" + "Nonlinear + Step Loading: %0.3f" % rmse_step
+ "\n" + "Nonlinear Hyperbolic: %0.3f" % RMSE_hyper_nonlinear + "\n" + "Nonlinear Hyperbolic: %0.3f" % rmse_hyper_nonlinear
+ "\n" + "Original Hyperbolic: %0.3f" % RMSE_hyper_original, + "\n" + "Original Hyperbolic: %0.3f" % rmse_hyper_original,
color='r', horizontalalignment='right', color='r', horizontalalignment='right',
verticalalignment='top', fontsize='12', bbox=mybox) verticalalignment='top', fontsize='12', bbox=mybox)
@ -484,7 +484,7 @@ def run_settle_prediction(input_file, output_dir,
is_multi_step = False is_multi_step = False
# 반환 # 반환
return [RMSE_hyper_original, RMSE_hyper_nonlinear, RMSE_step, return [rmse_hyper_original, rmse_hyper_nonlinear, rmse_step,
final_error_hyper_original, final_error_hyper_nonlinear, final_error_hyper_original, final_error_hyper_nonlinear,
final_error_step, is_multi_step] final_error_step, is_multi_step]