모델 학습 및 예측에서 roc_auc_score 가 1이 나와버려서 뭔가 이상하게 학습을 시킨 것 같은데 괜찮은건가요? 그리고 X_test 를 이용해서 predict 할 때는 타겟값인 TravelInsurance 가 없어야하는 것 아닌가요? 왜 오류가 나는지 모르겠습니다... 아래는 어떤 식으로 전처리되었는지 X_tr과 X_test 입니다!
학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! 질문과 관련된 영상 위치를 알려주면 더 빠르게 답변할 수 있어요 먼저 유사한 질문이 있었는지 검색해보세요 강의 내용 6분 40초와 관련이 있습니다. 제가 2번 문제를 풀다가 Gender 부분을 C(Gender) 처리를 하지 않고 풀었는데 강의를 다시 보다 보니 문자열 처리를 해주는 것을 알았습니다. 근데 문자열 처리 유무와 상관없이 값이 전부 동일한 것을 보고 이렇게 질문을 드립니다. 회귀분석에서 ols가 범주형 변수가 있어도 C() 처리를 안해줘도 된다고 하셨는데 로지스틱 회귀 분석에서도 동일한지 여쭤보고 싶습니다. 왜 결과값이 문자열 처리에 상관없이 동일하게 나오는 건가요? 감사합니다.
안녕하세요, 학습 중 질문이 있어 글 작성합니다. 코드를 정확하게 이해하고자 자세하게 여쭤보겠습니다. 1. 강의 9:20 경 코드 from sklearn.model_selection import train_test_split X_tr, X_val, y_tr, y_val = train_test_split(train.drop('output', axis=1), train['output'], test_size=0.15, random_state=2022) # 랜덤 포레스트 from sklearn.ensemble import RandomForestClassifier rf = RandomForestClassifier() rf.fit(X_tr, y_tr) pred = rf.predict(X_val) rf.fit에는 당연히 X, y의 train 데이터가 들어가야 하겠는데. pred에 X_val이 들어가야 하는 이유는 무엇인가요? 2. 강의 22:10 경 코드 pred_proba = xgb.predict_proba(test) pd.DataFrame({ 'id' : test_id, 'output' : pred_proba[:, 1]}).to_csv('0000.csv', index=False) roc_auc_score에서 pred가 아닌 pred_proba를 사용함은 이해를 했으며(output이 확률이니까), pred_proba[:, 1] 에서 :1의 의미를 알고싶습니다. 답변주심에 미리감사드립니다!
안녕하세요. 섹션5 [작업형2] 모의문제 및 캐글 - 2번쨰 강의 관련 질문입니다. 검증데이터 분리 시 아래와 같이 코드를 적었는데, from sklearn.model_selection import train_test_split X_tr, X_val, y_tr, y_val = train_test_split(train.drop('price', axis=1), train['price'], test_size = 0.15, random_state=2022) 윗 행에서 train.drop('price') 후, train['price']을 하는 이유가 뭔가요? 'price'값이 타겟이기 떄문에 X_tr 은 'price'가 없어야 하고, 반면, X_val은 'price'만 있어야 하니까 위 코드가 나온게 맞는것인지요? 감사합니다.
pip install pandas 명령을 입력하면 다음과 같은 오류가 발생해요. Collecting pandas Using cached pandas-2.2.2.tar.gz (4.4 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing metadata (pyproject.toml) ... error error: subprocess-exited-with-error × Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [12 lines of output] + meson setup C:\Users\user\AppData\Local\Temp\pip-install-t_73zgrt\pandas_07f940e4918444ecb3ee5b4569956cfa C:\Users\user\AppData\Local\Temp\pip-install-t_73zgrt\pandas_07f940e4918444ecb3ee5b4569956cfa\.mesonpy-3kj1_j_g\build -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --vsenv --native-file=C:\Users\user\AppData\Local\Temp\pip-install-t_73zgrt\pandas_07f940e4918444ecb3ee5b4569956cfa\.mesonpy-3kj1_j_g\build\meson-python-native-file.ini The Meson build system Version: 1.2.1 Source dir: C:\Users\user\AppData\Local\Temp\pip-install-t_73zgrt\pandas_07f940e4918444ecb3ee5b4569956cfa Build dir: C:\Users\user\AppData\Local\Temp\pip-install-t_73zgrt\pandas_07f940e4918444ecb3ee5b4569956cfa\.mesonpy-3kj1_j_g\build Build type: native build Project name: pandas Project version: 2.2.2 ..\..\meson.build:2:0: ERROR: Could not find C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe A full log can be found at C:\Users\user\AppData\Local\Temp\pip-install-t_73zgrt\pandas_07f940e4918444ecb3ee5b4569956cfa\.mesonpy-3kj1_j_g\build\meson-logs\meson-log.txt [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed × Encountered error while generating package metadata. ╰─> See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details. C:\Program Files (x86)\Microsoft Visual Studio 폴더가 없던데 어떻게 해야 한나요.
강의에서 나오는 prototype 말고 class 문법으로 바꿔서 공부하시는 분들 참고하셔요! 🫶 ❤ 화살표함수란 ? 함수를 간결하게 정의할 수 있는 문법으로, 함수가 호출될 때의 this 컨텍스트가 정적으로 결정됨. 주로 콜백 함수나 메서드 정의 시 this 바인딩 문제를 해결하기 위해 사용됨. 정리 Arrow Function 내부에서 this를 사용하면, 함수가 정의된 시점의 외부 컨텍스트를 유지하게 됨 화살표 함수 ver. run = () => { if (this.direction === 'left') { this.xPos += this.speed; } else if (this.direction === 'right') { this.xPos -= this.speed; } this.mainElm.style.left = `${this.xPos}%`; requestAnimationFrame(this.run); }; Bind 메소드 ver. run() { if (this.direction === 'left') { this.xPos += this.speed; } else if (this.direction === 'right') { this.xPos -= this.speed; } this.mainElm.style.left = `${this.xPos}%`; requestAnimationFrame(this.run.bind(this)); }
[문제] import pandas as pd from statsmodels.formula.api import logit df = pd.read_csv("/kaggle/input/bigdatacertificationkr/Titanic.csv") formula = "Survived ~ C(Pclass) + Gender + SibSp + Parch" model = logit(formula, data=df).fit() model.params 다름아니라 여기서 Pclass에 왜 앞에 C()를 하셨는지 이해가 안갑니다.! 참고로 데이터 info는 다음 아래와 같았습니다. Pclass : 'int' Gender : 'object' SibSp : 'int' Parch : 'int'
학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! 질문과 관련된 영상 위치를 알려주면 더 빠르게 답변할 수 있어요 먼저 유사한 질문이 있었는지 검색해보세요 해당 문제에서 "Events컬럼이 '1'인경우 80%의 Salse값만 반영함" 이라는 조건을 실행하기 위해서 아래와 같은 함수를 만들었는데 'Events' Key error 가 나네요. 어느 부분을 수정하면 될까요? def calc(df) : if df['Events'] == 1 : return df['Sales']*0.8 else : return df['Sales'] df['events80'] = df.apply(calc)