묻고 답해요
158만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
삭제예정콘텐츠 강의
'(삭제 예정 콘텐츠) 회귀모형'라는 강의가 있는데 빅데이터분석기사 실기 시험에 필요한 내용일까요? 수강해야 되는지 몰라서 질문드립니다.
-
해결됨비전공자를 위한 진짜 입문 올인원 개발 부트캠프
로그 이미지 주소 중 절대 경로 원리에 관한 질문
본 강의 중 로그가 나오지 않는 이슈에 관하여경로 설정에 문제가 있다고 하셨고, grab_market_web/src/App.js의 내용 중 로그 src의 경로를"./imgages/icons/log.png"에서 -> "/imgages/icons/log.png"으로 변경하라고 하였습니다. 작동은 잘 되는데, 작동 원리가 궁금합니다./ 절대값 root경로의 시작은 어디로 설정되어 있나요?이전에는 메인 화면에서는 ./ 상대 경로 중, 현재 경로로 설정되어 있었는데 잘 작동했던 이유도 궁금합니다.App.js파일의 내용이니까 App.js가 존재하는 grab_market_web/src 디렉토리가 현재 경로라고 이해되는데,그보다 상위 디렉토리에 존재하는 grab_market_web/public이 ./ 현재 경로로 인식되어grab_market_web/public/images가 호출 되는 것도 이해가 잘 되지 않으며/ 절대 경로로 설정시에도grab_market_web/public/images가 호출되는 것이 잘 이해가 되지 않습니다.
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
Lightgbm 관련 질문
Ligthgbm을 쓰면 결측치 처리가 필요없고, 범주형 데이터 인코딩도 필요없다고 하셨는데트리 관련 모델이라 수치형 변수 스케일링도 딱히 필요가 없고,이상치 처리에 대해서도 딱히 필요가 없나요??
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
작업형2 모의문제2 lightGBM 적용 질문
import pandas as pd train = pd.read_csv('train.csv') test = pd.read_csv('test.csv') pd.set_option('display.max_columns', None) # print(train.shape, test.shape) # print(train.head()) # print(test.head()) # print(train.info()) # print(test.info()) cols = train.select_dtypes(include='object') for col in cols : train[col] = train[col].astype('category') test[col] = test[col].astype('category') # 이걸 안 하면 lgb.predict(test) 구문에서 에러남 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.2, random_state=2023) import lightgbm lgb = lightgbm.LGBMRegressor(random_state = 2023) lgb.fit(X_tr, y_tr) pred = lgb.predict(X_val) from sklearn.metrics import r2_score, mean_absolute_error, mean_squared_error # print("r2 : ", r2_score(y_val, pred)) #0.2392705394376351 # print("mae : ", mean_absolute_error(y_val, pred)) #71.81171796246842 # print("mse : ", mean_squared_error(y_val, pred)) #63344.209788490516 pred_res = lgb.predict(test) pd.DataFrame({'price': pred_res}).to_csv('result.csv', index=False) print(pd.read_csv('result.csv')) y_test = pd.read_csv("y_test.csv") print(r2_score(y_test, pred_res)) #0.22012967580409581안녕하세요, 딴짓님lightGBM 모델 설명 주셔서 적용해보았는데요.이렇게 하는 게 맞을까요?for col in cols : train[col] = train[col].astype('category') test[col] = test[col].astype('category')이 부분을 하지 않으면 에러가 나긴 하더라구요. train[col]을 하지 않으면 아래와 같은 에러메시지가 나옵니다.'DataFrame.dtypes for data must be int, float or bool.Did not expect the data types in the following fields: name, host_name, neighbourhood_group, neighbourhood, room_type, last_review' test[col]을 하지 않으면 아래와 같은 에러메시지가 나옵니다.'train and valid dataset categorical_feature do not match.' lightGBM모델은 데이터 타입이 int, float, bool 이 세가지만 허용하게 되어 object 타입을 category 타입으로 변경train만 변경해주면 test[col]을 하지 않았을 때와 같은 에러메시지가 출력되니 test도 category로 변경이게 맞을까요? 평가지표 같은 것도 주석으로 작성했는데, lightGBM을 이렇게 사용하는 것이 맞는지 확인 한 번 부탁드립니다!
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
preprocessing MinMaxScaler와 minmax_scale의 차이가 궁금합니다.
작업형2 수치형데이터 인코딩 MinMaxScaler로 열심히하다가,작업형1 min-max scale 문제에 위 수치형데이터 인코딩을 하면서 순간 혼돈이 왔었는데요,MinMaxScaler와 min-max scale의 preprocessing 차이가 궁금합니다..!
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
모의문제3 작업형1 출력오류 질문입니다.
안녕하세요 강사님 모의문제3 작업형1 7번 출력 시 발생한 오류를 해결하지 못해 질문드립니다.강사님의 코드와 비교했을 때 iloc/loc만 다를뿐 나머지는 동일한 코드인데 출력값이 202로 다릅니다...어떤 문제가 있어서 그럴까요? 그리고 이외의 2가지 질문 더 있습니다..! 실제 시험에서 평가지표(R-Squared, MAE, MSE, RMSE, RMSLE, MAPE)의 수치를 나타내어야 하는가요? 만일 그렇다면, 다음과 같이 함수로 만들 수 있도록 모두 외워야하나요? 아니면 시험환경에서 주어지나요?작업형2에서 csv파일은 만들어서 제출 후 오류가 있음을 발견해 다시 csv파일을 만들어서 제출해도 상관이 없을까요?시험칠 때 코드에서 주석다는 것은 큰 문제 없을까요? 긴 질문이지만 답변해주시면 감사합니다...ㅜ
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
작업형 2 시험에서 제출 시 평가를 꼭 해야하나요 ?
회귀는 rmse, 분류는 roc 등으로 평가가 있는데,실제 시험에서 평가 없이 바로 제출해도 무방한가요 ?
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
작업형 2유형 제출 관련
안녕하세요. 큰 도움 받고 있습니다. 감사합니다!!다름이 아니라 유형별로 답안 제출할 때,작업형1: print()작업형3: 별도의 답안 입력창에 답 입력하여 제출하는 것으로 알고 있는데,2유형은 제출 전 마지막 행을 어떤 내용으로 끝내야 하는지 헷갈려서요.pd.DataFrame().to_csv() 식의 파일 저장으로 제출하면 될까요?
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
섹션 6 작업형 2 정확도 오류 원인 질문드립니다! Classification metrics can't handle a mix of binary and continuous targets
from sklearn.model_selection import train_test_split X_tr,X_val,y_tr,y_val=train_test_split(train.drop('Attrition_Flag',axis=1),train['Attrition_Flag'],test_size=0.2,random_state=2023) from sklearn.ensemble import RandomForestClassifier rf=RandomForestClassifier(random_state=2023) rf.fit(X_tr,y_tr) pred=rf.predict_proba(X_val) from sklearn.metrics import accuracy_score # 정확도 print(accuracy_score(y_val, pred[:,1])) --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-63-aa6b6ce781f8> in <cell line: 10>() 8 9 # 정확도 ---> 10 print(accuracy_score(y_val, pred[:,1])) 2 frames /usr/local/lib/python3.10/dist-packages/sklearn/metrics/_classification.py in _check_targets(y_true, y_pred) 93 94 if len(y_type) > 1: ---> 95 raise ValueError( 96 "Classification metrics can't handle a mix of {0} and {1} targets".format( 97 type_true, type_pred ValueError: Classification metrics can't handle a mix of binary and continuous targets 혹은 print(accuracy_score(y_val, pred)) 실행 시, 오류2번 Classification metrics can't handle a mix of binary and continuous-multioutput targets해당 코드로 제출까지는 잘 되고 있습니다. 그러나 정확도 측정 시 오류가 발생하여, 제출에 문제가 있는 것인가 불안하여 오류 현상 문의드립니다..!
-
미해결비전공자를 위한 진짜 입문 올인원 개발 부트캠프
맥북 터미널에서 node-v 입력시 나오는 오류
안녕하세요 그랩님!혹시 영상 4:56쯤 단계부터 오류가 떠 다른 분들의 질문과 그랩님 답변도 보고 이것저것 시도해 보았으나 해결이 안되어 질문드립니다ㅜㅜ 혹시 아래의 오류가 제가 지금 사용하는 맥북이 2017년 버전(10.13.1)으로 시스템 업그레이드를 한지 오래되었기 때문에 뜨는걸까요..? 맥에서 지원하는 최신 시스템 업그레이드를 하려면외장하드 구입 후 컴퓨터 내 백업을 준비 후에 OS 삭제>재설치>백업복원 까지 진행해야 하기에 하기 오류가 컴퓨터 백업과 OS 재설치 없이도 해결이 가능할지 혹시 아실까 하여 문의드립니다ㅜㅜ
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
과대적합 발생 시 처리 방법에 대해 궁금합니다!
평가 지표를 이용해 점수 확인 시, train점수가 높지만 test 점수가 낮을 때 과대적합이 발생했다고 판단하고, max_depth와 n_estimators를 조금씩 조절해야한다고 알고 있습니다!그런데, 조절 시 점수 판단 기준이 궁금합니다. 예를 들어 accuracy 사용 시, train - 1.0 , test - 0.9xxx 정도로 점수가 나오면 train점수를 낮춰가면서라도 test와 비슷해지도록 맞춰나가야 하는 것인가요?!아니면 train과 test가 현저히 차이날 때만 조절하면 될까요? ㅠㅠ이론적인 지식이 부족해서 어떻게 처리해야하는지 감이 잡히질 않아 질문드립니다. 항상 감사드립니다 : )
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
섹션7. 모의고사 풀어보기 2 질문있습니다.
goorm을 써서 코드를 실행해보는데데이터 분석하는 과정에서 랜덤 포레스트를 쓸 때는 warning 메시지가 하나도 안 나왔는데 한번 XGBoost를 사용하니까 바로 WARNING: ../src/learner.cc:1095: Starting in XGBoost 1.3.0, the default evaluation metric used with the objective 'binary:logistic' was changed from 'error' to 'logloss'. Explicitly set eval_metric if you'd like to restore the old behavior.0.9724770642201834/usr/local/lib/python3.9/dist-packages/xgboost/compat.py:31: FutureWarning: pandas.Int64Index is deprecated and will be removed from pandas in a future version. Use pandas.Index with the appropriate dtype instead. from pandas import MultiIndex, Int64Index/usr/local/lib/python3.9/dist-packages/xgboost/sklearn.py:1146: UserWarning: The use of label encoder in XGBClassifier is deprecated and will be removed in a future release. To remove this warning, do the following: 1) Pass option use_label_encoder=False when constructing XGBClassifier object; and 2) Encode your labels (y) as integers starting with 0, i.e. 0, 1, 2, ..., [num_class - 1]. warnings.warn(label_encoder_deprecation_msg, UserWarning)/usr/local/lib/python3.9/dist-packages/xgboost/data.py:208: FutureWarning: pandas.Int64Index is deprecated and will be removed from pandas in a future version. Use pandas.Index with the appropriate dtype instead. from pandas import MultiIndex, Int64Index이런 워닝 코드가 뜹니다. 어떤 것이 문제일까요?코드는 아래에 있습니다.import pandas as pd pd.set_option('display.max_columns',None) train = pd.read_csv("train.csv") test = pd.read_csv("test.csv") # 사용자 코딩 # print(train.head()) # print(train.describe()) from sklearn.model_selection import train_test_split X_tr,X_val,y_tr,y_val = train_test_split(train.drop('target',axis=1), train['target'], test_size=0.2, random_state=2022) from sklearn.ensemble import RandomForestClassifier rf = RandomForestClassifier(random_state=2022, max_depth=5, n_estimators=400) rf.fit(X_tr,y_tr) pred = rf.predict(X_val) from xgboost import XGBClassifier xgb = XGBClassifier(random_state=2022, max_depth=5, n_estimators=400, learning_rate=0.01) xgb.fit(X_tr,y_tr) pred = xgb.predict(X_val) from sklearn.metrics import f1_score print(f1_score(y_val,pred))
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
기출유형 4회 작업형2 f1_score 평가
안녕하세요, 매 강의마다 좋은 수업해주셔서 감사드립니다. lightgmb 뽀너스 영상도 정말 감사합니다~~f1_score로 평가를 진행하고 싶었으나, 해당 오류가 발생하여 질문드리게 되었습니다. 제시된 데이터 set에 적합한 평가 모델을 문제에서 제시를 해주는 것인지, 제가 잘못된 코딩을 한 것 인지 확인해주시면 너무 감사드릴 것같습니다.Please choose another average setting, one of [None, 'micro', 'macro', 'weighted'].에러 메시지를 확인하고 임의로 micro를 추가하여 옵션값을 주니까 에러 메시지 없이 평가값이 나오는점 확인하였습니다. 혹시 average setting이라는걸 세팅하는 경우는 어떤 경우인지 알려주실 수 있으신가요??발생 오류 : Target is multiclass but average='binary'--------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-22-dbd4046600d4> in <cell line: 34>() 32 pred = model.predict(X_val) 33 ---> 34 print(f1_score(y_val,pred)) 35 36 # submit = pd.DataFrame({ 3 frames /usr/local/lib/python3.10/dist-packages/sklearn/metrics/_classification.py in _check_set_wise_labels(y_true, y_pred, average, labels, pos_label) 1389 if y_type == "multiclass": 1390 average_options.remove("samples") -> 1391 raise ValueError( 1392 "Target is %s but average='binary'. Please " 1393 "choose another average setting, one of %r." % (y_type, average_options) ValueError: Target is multiclass but average='binary'. Please choose another average setting, one of [None, 'micro', 'macro', 'weighted'].*작성코드# 라이브러리 불러오기 import pandas as pd # 데이터 불러오기 train = pd.read_csv("train.csv") test = pd.read_csv("test.csv") target = train.pop('Segmentation') train = train.drop('ID',axis = 1) test_id = test.pop('ID') # 데이터 인코딩 train = pd.get_dummies(train) test = pd.get_dummies(test) # print(train.shape,test.shape) # 검증데이터 생성 from sklearn.model_selection import train_test_split X_tr,X_val,y_tr,y_val = train_test_split( train,target,test_size=0.2,random_state=2023 ) # 모델 생성 및 평가 from sklearn.metrics import f1_score from sklearn.ensemble import RandomForestClassifier model = RandomForestClassifier(random_state = 2023,max_depth = 5,n_estimators = 200) model.fit(X_tr,y_tr) pred = model.predict(X_val) print(f1_score(y_val,pred))
-
해결됨딥러닝 CNN 완벽 가이드 - TFKeras 버전
안녕하세요 교수님 코드 부분 질문있습니다.
show_pixel_histogram(images_array[0])값이 실행할때마다 항상 다른 히스토그램을 보여주고있습니다.실행할때마다 batch_size만큼 다음 batch로 넘어가기 때문에 히스토그램 값이 달라지는것이 맞는지 여쭤보고 싶습니다.
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
인코딩 전후 데이터 크기 관련
작업형2 예시문제는X_train과 X_test의 '주구매상품' 컬럼의 카테고리 개수와 종류가 다른 경우였습니다(차집합 소형가전)인코딩 전에 두 데이터를 concat -> 인코딩 후 -> 다시 두 개로 분리하는 것은 원핫 인코딩에만 해당되는 것일까요?왜냐면 라벨 인코딩은 제가 concat 과정을 생략하고 모델 선택 및 예측까지 진행했을 때 딱히 에러가 발생하거나 성능에 문제가 있어보이진 않았습니다. 선생님도 강의에서 라벨 인코딩을 진행하면서 concat 과정을 거치지 않은 걸로 보이고요object형의 카테고리 개수가 다르더라도 라벨 인코딩을 선택한다면 별도의 처리를 거치지 않아도 되는 것인지가 궁금합니다늘 감사드립니다
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
3회 기출유형 작업형 2 roc auc score 에러 질문드립니다.
시험환경에서는 제공되지 않겟지만, 궁금해서 돌려보면 아래 에러가 발생합니다. 아래 에러는 어떤 에러인지 궁금합니다. --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-63-01bc5037f802> in <cell line: 2>() 1 from sklearn.metrics import roc_auc_score ----> 2 roc_auc_score(y_val, pred) 5 frames/usr/local/lib/python3.10/dist-packages/sklearn/utils/validation.py in check_consistent_length(*arrays) 395 uniques = np.unique(lengths) 396 if len(uniques) > 1: --> 397 raise ValueError( 398 "Found input variables with inconsistent numbers of samples: %r" 399 % [int(l) for l in lengths] ValueError: Found input variables with inconsistent numbers of samples: [298, 497]
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
작업형2 모의문제2 질문
히스토그램이랑 describe로 확인한 price 값 중에 굉장히 멀리떨어져있는 값이 나왔는데, 이건 이상치로 해석하는게 아닌가요?'그리고 강의에서 r 2값이 0.077이 나왔는데. 이게 평가 지표에서 좋게 받을 수 있는건가요?R에서는 상관관계랑 *** 로 변수를 선택하는게 있었던거 같은데, 파이썬에서는 그냥 진행해야하는건가요?
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
모의고사2-test인덱스 정렬 질문드립니다~
안녕하세요! 모의고사풀어보기 2에서 시험 환경에 선생님이 올려주신 코드를 그대로 복사해서 print(test)를 해보면 아래와 같이 인덱스가 오름차순으로 정렬되지 않아 마지막 값에 'index':test.index를 했을 때도 선생님 화면과 다르게 나오던데, 혹시 데이터가 바뀐 걸까요..? 늘 친절히 알려주셔서 감사합니다!!
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
not defined 에러메시지 관련
안녕하세요. 5회기출에서 스케일링하다가 에러메시지가 나왔는데 무슨 문제인지 알려주시면 감사하겠습니다import pandas as pd train = pd.read_csv("train.csv") test = pd.read_csv("test.csv") # 3. 수치형 이상치 스케일링 # print(train.head()) train.select_dtypes(exclude='object') # 수치형 컬럼 확인 cols = ['mileage', 'tax','mpg', 'engineSize'] from sklearn.preprocessing import MinMaxScaler Scaler = MinMaxScaler() train[cols] = scaler.fit_transform(train[cols]) test[cols] = scaler.transform(test[cols]) # print(train.head()) --------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-53-9214327183aa> in <cell line: 11>() 9 from sklearn.preprocessing import MinMaxScaler 10 Scaler = MinMaxScaler() ---> 11 train[cols] = scaler.fit_transform(train[cols]) 12 test[cols] = scaler.transform(test[cols]) 13 NameError: name 'scaler' is not defined
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
독립성 검정
안녕하세요?독립성 검정강의에서문제를 꼬아서 낸다고 하면 데이터를 정제된 데이터로 바꾸는 데이터 프레임으로 만드는거 혹시 어떻게 하면 좋을지 잘 모르겠어요 ㅠㅠdf.groupby('근무지')['근무기간'].sum() 해서 합계는 다 구하겠는데, 데이터 프레임으로 만드는건 피봇 기능을 써야할것 같은데...