내일배움캠프(본캠프)

[내일배움캠프] 본캠프 4/24

anscodus 2026. 4. 24. 20:26

오늘 한 일

  • 코드카타 문제풀이
  • 개인과제
더보기
더보기
  • 필수 4 상관관계 구하기
df.corr(method='pearson').round(2)

전체 상관관계 말고 특정 컬럼들만 보고싶은데 그 방법을 까먹음 

 

다른분들이랑 같이 공부하면서 해결법을 배웠다

df_corr = df[['machine_failure','air_temp','process_temp','rotational_speed','torque', 'tool_wear']].corr(method='pearson').round(2).abs()

 컬럼들을 대괄호 하나에 같이 묶으면 되는거였음 .....

 

 

 

  • 필수 5 데이터 시각화
fig, axes = plt.subplots(2, 3, figsize=(15, 10))
axes = axes.flatten()

sns.boxplot(x='machine_failure', y='air_temp', hue='machine_failure',
                   data=df, ax=axes[0], palette=['steelblue', 'tomato'], legend=False)
axes[0].set_title('air_temp')
axes[0].set_xticks([0,1])
axes[0].set_xticklabels(['정상','고장'])

 

 subplot 만드는게 오랜만에 해서 다 까먹었다...

axes[n]에 n+1번째의 플롯 내용을 적으면 되는거였음

 나중에 시간이 나면 복사붙여넣기 한거를 반복문으로 줄여봐야겠다.

 

 

  •  도전 2
# 도전 2. 머신러닝 3
from sklearn.linear_model import LogisticRegression

X=df[['air_temp', 'process_temp', 'torque']]
y=df['machine_failure']
X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.3, random_state=42
)
model = LogisticRegression(random_state=42, max_iter=1000)
model.fit(X_train, y_train)
print(f"계수(coefficients): {model.coef_[0]}")
print(f"절편(intercept): {model.intercept_[0]:.3f}")

 

y_pred_train = model.predict(X_train)
y_pred_test = model.predict(X_test)

train_accuracy = accuracy_score(y_train, y_pred_train)
test_accuracy = accuracy_score(y_test, y_pred_test)

print(f"훈련 데이터 정확도: {train_accuracy:.3f}")
print(f"테스트 데이터 정확도: {test_accuracy:.3f}")

 

 로지스틱 회귀 계수 막대그래프로 시각화하기

는 다음에 해야겠다....

 

개인과제 하느라 자격증 공부는 하나도 못함 !! ㅜㅜㅜㅜ