> For the complete documentation index, see [llms.txt](https://air-pro.gitbook.io/air-delay-project/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://air-pro.gitbook.io/air-delay-project/undefined-2/undefined-3/2.md).

# 2차 전처리 과정

## 전처리 과정 명세

전 과정과의 대표적인 차이점은 다음과 같다.&#x20;

1. 계획시간 및 실제시간 간의 차이를 계산한 후, 극소 데이터 제거
2. 지연을 안했지만 지연사유가 있는 데이터, 약 900여개 지연사유 삭제
3. 부정기편 삭제
4. 지연시간이 -180분이거나 300분 이상을 넘었을 경우 삭제
5. 계획 시간이 23시에서 1시사이 일 경우 삭제.(데이터 너무 적음)
6. 전처리 후, 학습데이터로 사용되지 않는 모든 칼럼 삭제
7. 출발 데이터와 도착 데이터로 2가지 학습 셋 준비

요약하면 오버피팅을 우려해 극단적인 데이터를 제거하고, 테스트 데이터에는 기록되지 않는 부정기편 관련 데이터를 삭제하였다. 또한, 1차에서는 제거했던 FLT 데이터를 다시 학습 데이에 추가하였다.

## 실행 코드

```python
# 계획시간 및 실제시간간의 차이 계산
df_H1 = df['ATT_H'].loc[df['DLY'] == 1] - df['STT_H'].loc[df['DLY'] == 1]
df_H2 = df['ATT_H'].loc[(df['DLY'] == 1) & (df['DRR'] == 1)] - df['STT_H'].loc[(df['DLY'] == 1) & (df['DRR'] == 1)]
df_STT_Time = df['STT_H'] * 60 + df['STT_M']
df_ATT_Time = df['ATT_H'] * 60 + df['ATT_M']
df_H3 = df_ATT_Time - df_STT_Time
df['Time'] = df_H3

# 지연을 안했지만 지연사유가 있는 데이터, 약 900여개 지연사유 삭제
df['DRR'].loc[(df['DLY'] == 0) & (df['DRR'] != 0)] = 0

# 부정기편 삭제
df = df.loc[df['IRR'] == 0]

# 지연시간이 -180분이거나 300분 이상을 넘었을 경우 삭제
df = df.loc[(df['Time'] >= -180) & (df['Time'] < 300)]

# 계획 시간이 23시에서 1시사이 일 경우 삭제.(데이터 너무 적어 overfitting 우려)
df = df.loc[(df['STT_H'] != 0) & (df['STT_H'] != 1) & (df['STT_H'] != 23)]

# 전처리 후, 학습데이터로 사용되지 않는 모든 칼럼 삭제
df = df.drop(['STT_M', 'ATT_H', 'ATT_M'], axis = 1)
df = df.drop(['Time'], axis = 1)

# 출발 데이터와 도착 데이터로 2가지 학습 셋 준비
df_A = df.loc[df['AOD'] == 0]
df_D = df.loc[df['AOD'] == 1]
df_A = df_A.drop(['DRR', 'AOD', 'IRR'], axis = 1)
df_D = df_D.drop(['DRR', 'AOD', 'IRR'], axis = 1)
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://air-pro.gitbook.io/air-delay-project/undefined-2/undefined-3/2.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
