묻고 답해요
156만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
target변수 생성시 오류
데이터 전처리 전 타켓변수를 만들때 마다 오류메세지가 뜹니다.그리고 train의 'id' 를 삭제할 때에도 비슷한 오류가 뜨는데 도와주세요
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
작업형 2유형 질문있습니다!
안녕하세요 선생님 작업형 2유형 관련해서 질문이 있습니다. 2유형에서 고득점을 목표로 하지 않기 때문에 간단하게 기본 공식만 외워가려고 생각중인데요 target = train.pop("A")train = pd.get_dummies(train)test = pd.get_dummies(test) from sklearn.model_selection import train_test_splitX_tr,X_val,y_tr,y_val = train_test_split(train,target,test_size = 0.2, random_state = 0) from sklearn.ensemble import RandomForestRegressorrf = RandomForestRegressor(random_state=0)rf.fit(X_tr,y_tr)pred = rf.predict(X_yal) pred = rf.predict(test)result = pd.DataFrame({'pred':pred})result.to_csv("result.csv",index=False)print(pd.read_csv("result.csv").head())print(pd.read_csv("result.csv").shape) 이런식으로 간단하게 문제에 맞춰 작성했을때 빨간색 하이라이트 부분을 제출을 하는건데 , 초록색 부분을 주석처리를 해줘야 하는걸까요? 아니면 주석처리 하지 않고 위에처럼 제출을 하면 될까요?추가적으로 주석처리가 필요한 부분이 있으면 알려주십쇼!!
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
모델링 및 평가(분류) 질문! 왜 수치형 데이터만 활용하는가?
모델링 및 평가(분류) 강의에서 X_train 데이터의 15개의 칼럼 데이터 중 일부 수치 데이터만 활용하여 머신러닝에 사용하는데, 모든 데이터를 다 활용하지 않는 이유가 있을까요?만약 모든 데이터를 다 활용한다면 roc_auc_score의 변화는 어떻게 되나요?
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
원핫인코딩 데이터 합치기
피처 엔지니어링 강의 중 분리한 데이터 다시 합침 부분에서 강의영상과 출력값이 달라서 질문드립니다. 강의화면에서는 107 컬럼, 103컬럼인데요, 같은 코드 결과인데 컬럼수가 15개로 나온이유가 궁금합니다.
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
피처 엔지니어링 원핫인코딩 Train/Test 컬럼 불일치
범주형 변수에 get.dummies를 이용하여 원핫인코딩 하는 작업 중 질문이 있습니다.train 데이터셋과 test 데이터셋의 컬럼수가99개와 95개로 다릅니다.(다른 이유는 train 데이터셋과 test 데이터셋의 컬럼 중에 관측치가 다른 항목이 있기 때문이라고 하셨는데요,그런 이유라면 다른 것이 정상인가요?) 그런데 영상에서는 100개로 나옵니다,,강의 100개 vs 99개 컬럼 갯수가 다른 이유는 무엇일까요? 아래는 코드와 출력값 첨부드립니다.# 원핫 인코딩 n_train, n_test, c_train, c_test = get_nc_data() # 데이터 새로 불러오기 c_train = pd.get_dummies(c_train[cols]) c_test = pd.get_dummies(c_test[cols]) display(c_train.head()) display(c_test.head()) print(c_train.shape) print(c_test.shape)
-
미해결[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
train과 test의 카테고리가 동일하지않은경우에도 똑같이 통용되는 코드인가요?
학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요!질문과 관련된 영상 위치를 알려주면 더 빠르게 답변할 수 있어요먼저 유사한 질문이 있었는지 검색해보세요
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
작업형1 모의문제 3-9번
학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요!질문과 관련된 영상 위치를 알려주면 더 빠르게 답변할 수 있어요먼저 유사한 질문이 있었는지 검색해보세요9번문제에서 시험때 제출할때 print(df.sort_values('subscribed').index[0])만 쓰면 될까요? 아니면 월별 데이터 갯수인 print(df)까지 해야하나요
-
미해결[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
작업형 1 모의 문제 1번 70% 데이터 추출 관련
안녕하세요! '앞에서부터 70% 데이터 중 views 컬럼의 3사분위 수에서 1사분위 수를 뺀 값을 구하시오' 이 부분에서 .loc을 사용했을 때와 그냥 슬라이싱을 했을 때의 행 개수 차이가 나서요.. 왜 이렇게 차이가 나는지 궁금해서 문의 남깁니다! 좋은 강의 준비해주셔서 고맙습니다 :)
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
검정 방법의 조건??
어쩔때 적합도 검정을 해야하는지 어쩔때 독립성 검정을 해야하는지 헷갈리네요 ㅠ혹시 구분하는 방법이 있을까요?
-
미해결[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
강의자료 다운
강의자료는 따로 다운로드 받을 순 없나요?
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
문제 6번
학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요!질문과 관련된 영상 위치를 알려주면 더 빠르게 답변할 수 있어요먼저 유사한 질문이 있었는지 검색해보세요이상치 제거를df = df[(df['age'] == df['age'].astype(int) ) & df['age'] >0]이렇게 하면 틀린건가요?round쓰는게 이해가 안가네요
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
host_name, name 삭제 이유
단순 데이터가 많다는 이유로 삭제를 해야하는 건가요?
-
미해결[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
KeyError: "['name', 'host_name', 'last_review', 'host_id'] not found in axis"
아래의 코드를 입력하면 다음과 같은 에러가 발생합니다 KeyError: "['name', 'host_name', 'last_review', 'host_id'] not found in axis"왜 이런 건가요?ㅠㅠcols = ['name','host_name','last_review','host_id'] print(train.shape) train = train.drop(cols, axis=1) test = test.drop(cols, axis=1) print(train.shape)
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
레이블 인코딩 시 반복문 내에서 인코더를 다시 선언하는 이유
레이블 인코딩 시le = LabelEncoder() for col in cols: le = LabelEncoder() c_train[col = le.fit_transform(..) c_test .... for 문 전에 레이블 인코더를 호출하여 선언하고 for문 내에서 또 하는 이유는 무엇인가요? for문 시작 전 한번만 해 줘도 되는 게 아닌가해서 질문드려 봅니다.
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
members.csv을 다운받았을 때 데이터가 깨지는 현상
members.csv을 다운받았을 때 데이터가 깨지는 현상이 발생하는데해결방안이 있을까요
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
KeyError: 'Gender' 에러
위의 코드를 그대로 입력하고 baseline 코드까지 문제가 없다가 label에서 다음과 같은 에러가 발생했습니다. KeyError Traceback (most recent call last) /usr/local/lib/python3.10/dist-packages/pandas/core/indexes/base.py in get_loc(self, key) 3804 try: -> 3805 return self._engine.get_loc(casted_key) 3806 except KeyError as err:index.pyx in pandas._libs.index.IndexEngine.get_loc() index.pyx in pandas._libs.index.IndexEngine.get_loc() pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item() pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item() KeyError: 'Gender' The above exception was the direct cause of the following exception: 아래는 입력한 코드입니다. 어떤 부분이 문제일까요? ㅠㅠ#label from sklearn.preprocessing import LabelEncoder for col in cols : le = LabelEncoder() train[col] = le.fit_transform(train[col]) test[col] = le.transform(test[col]) train[cols].head()
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
캐글 타이타닉 문제
캐글 타이타닉 문제에서검증 데이터 분리 작업을 안해도 되는건가요?수업 영상 작업형2 모의고사는 전부 검증 데이터 분리 작업을해주셨던데,안해도 무방한건지 궁금합니다.
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
dir/__all__ 활용관련
안녕하세요. dir 이나 __all관련해서,,,print(sklearn.__all__) 은 알겠는데요. 그 다음,,, from sklearn.ensemble import RandomForestClassifier 여기서,, randaomforestclassifier 이게 생각이 나지 않을때 이걸 찾을 수 있는 방법은 없는지요?
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
상황별 가설검정 문의
안녕하세요,작업형3을 공부하던 중 궁금한 점이 생겨 문의드립니다. 어떤 상황에서 T검정, 카이제곱 검정, 회귀분석, 분산분석(ANOVA)를 수행하는건지명확히 분류가 잘 안 되는데 위와 같이 T검정, 카이제곱 검정, 회귀분석, 분산분석 중어떤 것을 수행할지는 문제에서 주어지는 사항일까요? 감사합니다!
-
미해결[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
test파일 예측에서 자꾸 에러가 발생합니다.
train = pd.read_csv('/kaggle/input/working8-2/churn_train.csv')test = pd.read_csv('/kaggle/input/working8-2/churn_test.csv')target = train.pop('TotalCharges')train = pd.get_dummies(train)test = pd.get_dummies(test)from sklearn.model_selection import train_test_splitX_tr,X_val,y_tr,y_val = train_test_split(train, target, test_size=0.2, random_state=2022)from sklearn.metrics import mean_absolute_errorfrom sklearn.ensemble import RandomForestRegressorrf = RandomForestRegressor(random_state=2022, max_depth=7, n_estimators=600)rf.fit(X_tr,y_tr)pred = rf.predict(X_val)answer = rf.predict(test)rf.predict(X_val)까지는 잘 예측이 되어,866.4986350062683의 값을 얻었습니다.그리하여 마지막으로 본 test파일을 예측하여 제출하려고 하는데, 계속해서 오류가 발생하네요 ㅠㅠㅠ아래는 에러 코드입니다.ValueError Traceback (most recent call last) Cell In[97], line 14 12 rf.fit(X_tr,y_tr) 13 pred = rf.predict(X_val) ---> 14 answer = rf.predict(test) File /opt/conda/lib/python3.10/site-packages/sklearn/ensemble/_forest.py:981, in ForestRegressor.predict(self, X) 979 check_is_fitted(self) 980 # Check data --> 981 X = self._validate_X_predict(X) 983 # Assign chunk of trees to jobs 984 n_jobs, _, _ = _partition_estimators(self.n_estimators, self.n_jobs) File /opt/conda/lib/python3.10/site-packages/sklearn/ensemble/_forest.py:602, in BaseForest._validate_X_predict(self, X) 599 """ 600 Validate X whenever one tries to predict, apply, predict_proba.""" 601 check_is_fitted(self) --> 602 X = self._validate_data(X, dtype=DTYPE, accept_sparse="csr", reset=False) 603 if issparse(X) and (X.indices.dtype != np.intc or X.indptr.dtype != np.intc): 604 raise ValueError("No support for np.int64 index based sparse matrices") File /opt/conda/lib/python3.10/site-packages/sklearn/base.py:548, in BaseEstimator._validate_data(self, X, y, reset, validate_separately, **check_params) 483 def _validate_data( 484 self, 485 X="no_validation", (...) 489 **check_params, 490 ): 491 """Validate input data and set or check the `n_features_in_` attribute. 492 493 Parameters (...) 546 validated. 547 """ --> 548 self._check_feature_names(X, reset=reset) 550 if y is None and self._get_tags()["requires_y"]: 551 raise ValueError( 552 f"This {self.__class__.__name__} estimator " 553 "requires y to be passed, but the target y is None." 554 ) File /opt/conda/lib/python3.10/site-packages/sklearn/base.py:481, in BaseEstimator._check_feature_names(self, X, reset) 476 if not missing_names and not unexpected_names: 477 message += ( 478 "Feature names must be in the same order as they were in fit.\n" 479 ) --> 481 raise ValueError(message) ValueError: The feature names should match those that were passed during fit. Feature names unseen at fit time: - customerID_CUST0001 - customerID_CUST0002 - customerID_CUST0006 - customerID_CUST0007 - customerID_CUST0008 - ... Feature names seen at fit time, yet now missing: - customerID_CUST0000 - customerID_CUST0003 - customerID_CUST0004 - customerID_CUST0005 - customerID_CUST0009 - ...