해결된 질문
작성
·
294
0
예시문제 작업형2를 시험환경에서 lgb 모델로 머신러닝을 실시하였는데, 'random_state' 파라미터 관련 경고 메세지가 뜨는데, lgb 모델에서는 'random_state' 를 사용할 수 없는 건가요?
[코딩내용]
import pandas as pd
X_test = pd.read_csv("data/X_test.csv")
X_train = pd.read_csv("data/X_train.csv")
y_train = pd.read_csv("data/y_train.csv")
pd.set_option('display.max_columns', 100)
pd.options.display.float_format = '{:.2f}'.format
# print(X_train.shape, X_test.shape, y_train.shape)
# print(X_train.head(3))
# print(X_test.head(3))
# print(X_train.info())
# print(X_train.describe())
# print(X_train.describe(include='object'))
# print(X_test.describe(include='object'))
# print(y_train.head(3))
# print(y_train['gender'].value_counts())
# print(X_train.isnull().sum())
# print(X_test.isnull().sum())
# print(y_train.isnull().sum())
# print(X_train['환불금액'].mean())
# print(X_test['환불금액'].mean())
X_train['환불금액'] = X_train['환불금액'].fillna(0)
X_test['환불금액'] = X_test['환불금액'].fillna(0)
# print(X_train.isnull().sum())
# print(X_test.isnull().sum())
X_train = X_train.drop('cust_id', axis=1)
X_test_id = X_test.pop('cust_id')
# print(X_test.head(3))
cols = X_train.select_dtypes(exclude='object').columns
# print(cols)
from sklearn.preprocessing import RobustScaler
scaler = RobustScaler()
X_train[cols] = scaler.fit_transform(X_train[cols])
X_test[cols] = scaler.transform(X_test[cols])
# print(X_train.head(3))
cols = X_train.select_dtypes(include='object').columns
# print(cols)
from sklearn.preprocessing import LabelEncoder
for col in cols :
le = LabelEncoder()
X_train[col] = le.fit_transform(X_train[col])
X_test[col] = le.transform(X_test[col])
# print(X_train.head(3))
from sklearn.model_selection import train_test_split
X_tr, X_val, y_tr, y_val = train_test_split(X_train, y_train['gender'], test_size=0.15, random_state=2022)
# print(X_tr.shape, X_val.shape, y_tr.shape, y_val.shape)
from sklearn.metrics import roc_auc_score
import lightgbm as lgb
model = lgb.LGBMClassifier(ramdom_state=2022, max_depth=5, n_estimators=600, learning_rate=0.01)
model.fit(X_tr, y_tr)
pred = model.predict_proba(X_val)
# print(pred[:10])
print(roc_auc_score(y_val, pred[ : , 1]))
# 0.6153810060060059
# max_depth=5 : 0.6353541041041042
# n_estimators=600, learning_rate=0.01 : 0.647366116116116
[경고 메세지]
[LightGBM] [Warning] Unknown parameter: ramdom_state
예, 처음부터 다시 작성하니까 이상이 없습니다.
시험에서 중간에 이런 경우가 발생하면 지우고 다시 작성을 해야 하는가요?