묻고 답해요
161만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
작업형1 모의문제3 문제8
df.groupby(['city', 'f2']).sum()안녕하세요, 문제를 풀다가 궁금한 점이 있어서 문의드립니다.위와 같이 코드를 작성하면<ipython-input-20-0b895b525272>:8: FutureWarning: The default value of numeric_only in DataFrameGroupBy.sum is deprecated. In a future version, numeric_only will default to False. Either specify numeric_only or select only columns which should be valid for the function. df.groupby(['city', 'f2']).sum()이런 오류가 발생하는데요. groupby에서의 sum함수가 deprecated되었다고 하는데요, 이는 다른 함수로 대체되거나 아예 사라지는 것으로 알고있습니다. 시험보는 버전 내에서는 문제없이 사용해도 될까요?
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
Warning 대처방법 문의드립니다.
작업형1 모의문제3의 문제8번 중 일부 코드를 실행한 결과 FutureWarning이 발생하였습니다.(다른 코드 실행시에도 종종 보입니다.)왜 발생하는지, 해결방법은 무엇인지 조언 부탁드립니다. 작성코드df=pd.read_csv("members.csv")df=df.fillna(method='bfill')df=df.groupby(['city','f2']).sum().reset_index() 실행결과<ipython-input-136-bfe31d68ed6e>:5: FutureWarning: The default value of numeric_only in DataFrameGroupBy.sum is deprecated. In a future version, numeric_only will default to False. Either specify numeric_only or select only columns which should be valid for the function. df=df.groupby(['city','f2']).sum().reset_index()
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
3회 기출문제 작업형2
안녕하세요! 강의 듣던 중 질문이 생겨 글남깁니다. 2회 기출문제 작업형2 강의와는 다르게 왜 데이터 전처리 과정에서 수치형데이터와 범주형데이터를 분리하나요? 왜 2회 기출문제 과정에서는 필요가없는걸까요? ㅠㅠ # 수치형 데이터와 범주형 데이터 분리n_train = train.select_dtypes(exclude='object').copy()c_train = train.select_dtypes(include='object').copy()n_test = test.select_dtypes(exclude='object').copy()c_test = test.select_dtypes(include='object').copy() (↑이 과정에 대한 질문입니다!) 어쩔때 robustscaler를 쓰고, minmaxscaler를 쓰고.. 스케일 방법이 다양한데 어떻게 선택하는건가요? 검증데이터 분리할떄 test_size 설정기준은 무엇인가요? 0.1로할떄도 있고 0.2로 할떄도 있으신데 어떻게 선정하시는건가요? 위와 마찬가지로 검증데이터 분리과정에서 random_state = 1204 를 설정하는 이유가 이해가 잘 안갑니다 ㅠ 저것의 의미가 무엇이고 숫자는 왜 1204인건가요?? (3,4번 질문은 이 코드에서의 질문입니다! from sklearn.model_selection import train_test_splitX_tr, X_val, y_tr, y_val = train_test_split(train.drop('TravelInsurance', axis=1),train['TravelInsurance'],test_size=0.1,random_state=1204)X_tr.shape, X_val.shape, y_tr.shape, y_val.shape)
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
빅분기 실기 제2문형에 관한 질문
✨빅분기 실기 너무 준비할께 많네요. TT실기 2유형에 같은 경우 모델을 정하고 데이터모형 평가 성능을 높이기 위한 하이퍼 파라미터 튜닝 절차를 반드시 거쳐야 하는지 여쭤봅니다.
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
"모의고사2" 질문
선생님!!궁금한 점을 질문드리면 항상 빠른 답변 드리시는 점에 감사드립니다."모의고사2" 관련하여 궁금한점을 질문드립니다.평가지표가 f1 인데, f1도 점수가 높은 경우 성능이 좋은건가요? 만약 하이퍼파라미터 투닝을 할 경우 f1 점수가 높게 나오는 것으로 test 데이터를 에측해서 csv 화일을 작성해야 하는 건지요?'모의고사2'를 시험환경에서 연습하는데, 랜덤포레스트는 큰 문제 없이 진행되었는데, xgboost 모델로 할 경우 진행이 안되고 에러가 발생합니다.이유가 무엇이고 어떻게 수정해야 하는지요?
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
분류 모델 평가 관련
안녕하세요 빠른 답변 주셔서 공부에 많은 도움이 되고 있어 감사드립니다.roc_auc_score 평가 시에만 accuracy, precision, recall, f1 과 다르게 predict_proba를 사용하는 이유 궁금합니다
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
[시험환경에 적응하기:작업형2] 'DataConversionWarning'이유 알려주세요
작업형2를 아래와 같이 했는데 DataConversionWarning 나왔습니다검색해보니 y_train 변경때문이며 ravel()을 사용하라고하는데 이유 설명 부탁 드립니다[error명]DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples,), for example using ravel().[작성내용]import pandas as pdX_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',None)# 사용자 코딩#print(X_train.shape,X_test.shape,y_train.shape)#print(y_train.isnull().sum())#print(X_train['환불금액'].describe())X_train['환불금액']=X_train['환불금액'].fillna(X_train['환불금액'].mean())X_test['환불금액']=X_test['환불금액'].fillna(X_train['환불금액'].mean())#print(X_train.isnull().sum())X_train=X_train.drop('cust_id',axis=1)X_test_id=X_test.pop('cust_id')y_train=y_train.drop('cust_id',axis=1)#print(X_test.head(2))#print(X_train.select_dtypes(exclude='object').columns)# '주구매상품', '주구매지점'# '총구매액', '최대구매액', '환불금액', '내점일수', '내점당구매건수', '주말방문비율', '구매주기'from sklearn.preprocessing import LabelEncodercols=['주구매상품', '주구매지점']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()) from sklearn.preprocessing import MinMaxScalercols2=['총구매액', '최대구매액', '환불금액', '내점일수', '내점당구매건수', '주말방문비율', '구매주기']scaler=MinMaxScaler()X_train[cols2]=scaler.fit_transform(X_train[cols2])X_test[cols2]=scaler.transform(X_test[cols2])#print(X_train.head(2))from sklearn.model_selection import train_test_splitX_tr,X_val,y_tr,y_val=train_test_split(X_train,y_train, test_size=0.3, random_state=2023)#print(X_tr.shape,X_val.shape,y_tr.shape,y_val.shape)#(2450, 9) (1050, 9) (2450, 1) (1050, 1)from sklearn.metrics import roc_auc_scorefrom sklearn.ensemble import RandomForestClassifierrf=RandomForestClassifier(random_state=2023)rf.fit(X_tr,y_tr)pred=rf.predict_proba(X_val)print(roc_auc_score(y_val,pred[:,1]))#0.654227735236709
-
미해결공공데이터로 파이썬 데이터 분석 시작하기
Swarmplot 에러
강의 회차 : [20/20] 지역별 분양가를 시각화하고 정리하기 질문 : 마지막 시각화 단계에서, boxplot, boxenplot, violinplot 다 잘 구현되는데 swarmplot만 계속 에러가 납니다. 구글에서 에러메시지 검색도 해 봤는데, 잘 해결이 안되네요.. 확인해 주실 수 있으신가요.* 에러메시지도 함께 첨부드립니다.--------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In[307], line 2 1 plt.figure(figsize=(24, 7)) ----> 2 sns.swarmplot(df, x='지역명', y='평당분양가격') File ~/anaconda3/lib/python3.10/site-packages/seaborn/categorical.py:2664, in swarmplot(data, x, y, hue, order, hue_order, dodge, orient, color, palette, size, edgecolor, linewidth, hue_norm, native_scale, formatter, legend, warn_thresh, ax, **kwargs) 2657 linewidth = size / 10 2659 kwargs.update(dict( 2660 s=size ** 2, 2661 linewidth=linewidth, 2662 )) -> 2664 p.plot_swarms( 2665 dodge=dodge, 2666 color=color, 2667 edgecolor=edgecolor, 2668 warn_thresh=warn_thresh, 2669 plot_kws=kwargs, 2670 ) 2672 p._add_axis_labels(ax) 2673 p._adjust_cat_axis(ax, axis=p.cat_axis) File ~/anaconda3/lib/python3.10/site-packages/seaborn/categorical.py:330, in _CategoricalPlotterNew.plot_swarms(self, dodge, color, edgecolor, warn_thresh, plot_kws) 321 def plot_swarms( 322 self, 323 dodge, (...) 327 plot_kws, 328 ): --> 330 width = .8 * self._native_width 331 offsets = self._nested_offsets(width, dodge) 333 iter_vars = [self.cat_axis] File ~/anaconda3/lib/python3.10/site-packages/seaborn/categorical.py:229, in _CategoricalPlotterNew._native_width(self) 226 @property 227 def _native_width(self): 228 """Return unit of width separating categories on native numeric scale.""" --> 229 unique_values = np.unique(self.comp_data[self.cat_axis]) 230 if len(unique_values) > 1: 231 native_width = np.nanmin(np.diff(unique_values)) File ~/anaconda3/lib/python3.10/site-packages/seaborn/_oldcore.py:1134, in VectorPlotter.comp_data(self) 1132 else: 1133 comp_col = pd.Series(dtype=float, name=var) -> 1134 comp_data.insert(0, var, comp_col) 1136 self._comp_data = comp_data 1138 return self._comp_data File ~/anaconda3/lib/python3.10/site-packages/pandas/core/frame.py:4786, in DataFrame.insert(self, loc, column, value, allow_duplicates) 4783 if not isinstance(loc, int): 4784 raise TypeError("loc must be int") -> 4786 value = self._sanitize_column(value) 4787 self._mgr.insert(loc, column, value) File ~/anaconda3/lib/python3.10/site-packages/pandas/core/frame.py:4877, in DataFrame._sanitize_column(self, value) 4875 return _reindex_for_setitem(value, self.index) 4876 elif is_dict_like(value): -> 4877 return _reindex_for_setitem(Series(value), self.index) 4879 if is_list_like(value): 4880 com.require_length_match(value, self.index) File ~/anaconda3/lib/python3.10/site-packages/pandas/core/frame.py:11620, in _reindex_for_setitem(value, index) 11616 except ValueError as err: 11617 # raised in MultiIndex.from_tuples, see test_insert_error_msmgs 11618 if not value.index.is_unique: 11619 # duplicate axis > 11620 raise err 11622 raise TypeError( 11623 "incompatible index of inserted column with frame index" 11624 ) from err 11625 return reindexed_value File ~/anaconda3/lib/python3.10/site-packages/pandas/core/frame.py:11615, in _reindex_for_setitem(value, index) 11613 # GH#4107 11614 try: > 11615 reindexed_value = value.reindex(index)._values 11616 except ValueError as err: 11617 # raised in MultiIndex.from_tuples, see test_insert_error_msmgs 11618 if not value.index.is_unique: 11619 # duplicate axis File ~/anaconda3/lib/python3.10/site-packages/pandas/core/series.py:4914, in Series.reindex(self, index, axis, method, copy, level, fill_value, limit, tolerance) 4897 @doc( 4898 NDFrame.reindex, # type: ignore[has-type] 4899 klass=_shared_doc_kwargs["klass"], (...) 4912 tolerance=None, 4913 ) -> Series: -> 4914 return super().reindex( 4915 index=index, 4916 method=method, 4917 copy=copy, 4918 level=level, 4919 fill_value=fill_value, 4920 limit=limit, 4921 tolerance=tolerance, 4922 ) File ~/anaconda3/lib/python3.10/site-packages/pandas/core/generic.py:5360, in NDFrame.reindex(self, labels, index, columns, axis, method, copy, level, fill_value, limit, tolerance) 5357 return self._reindex_multi(axes, copy, fill_value) 5359 # perform the reindex on the axes -> 5360 return self._reindex_axes( 5361 axes, level, limit, tolerance, method, fill_value, copy 5362 ).__finalize__(self, method="reindex") File ~/anaconda3/lib/python3.10/site-packages/pandas/core/generic.py:5375, in NDFrame._reindex_axes(self, axes, level, limit, tolerance, method, fill_value, copy) 5372 continue 5374 ax = self._get_axis(a) -> 5375 new_index, indexer = ax.reindex( 5376 labels, level=level, limit=limit, tolerance=tolerance, method=method 5377 ) 5379 axis = self._get_axis_number(a) 5380 obj = obj._reindex_with_indexers( 5381 {axis: [new_index, indexer]}, 5382 fill_value=fill_value, 5383 copy=copy, 5384 allow_dups=False, 5385 ) File ~/anaconda3/lib/python3.10/site-packages/pandas/core/indexes/base.py:4274, in Index.reindex(self, target, method, level, limit, tolerance) 4271 raise ValueError("cannot handle a non-unique multi-index!") 4272 elif not self.is_unique: 4273 # GH#42568 -> 4274 raise ValueError("cannot reindex on an axis with duplicate labels") 4275 else: 4276 indexer, _ = self.get_indexer_non_unique(target) ValueError: cannot reindex on an axis with duplicate labels
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
빅데이터 분석기사 (2회): 기출유형-작업형2 질문
안녕하세요 강사님 해당 강의를 듣던 도중 질문이 있어서 글 남깁니다. 라벨 인코딩 부분에서 cols = X_train.select_dtypes(include='object').columns으로 표현하였는데시험장에서는 그냥 info()를 통해 데이터타입 확인이후 object에 해당하는 컬럼들만 직접 수기로 입력해도 되나요?ex) cols = ['Warehouse_block', 'Mode_of_Shipment', 'Product_importance', 'Gender'] 라벨인코딩을 해야될때와 원핫인코딩을 해야될때 상황판단을 어떻게 하는지 궁금합니다. 그냥 매번 라벨인코딩만해도 무방할까요? 검증 데이터 분리시 test_size를 때에따라 0.1이나 0.2나 매번 바뀌는데 시험장에서는 성능이 더 좋은 test_size를 판단하기 위해 숫자를 바꿔가며 시도해봐야하나요? 그게 아니라면 그냥 test_size와 random_state는 0.1과 2023으로 해도 무방할지요 해당 강의와 마찬가지로 모델값들은 전부 같은 값이 나오는데 (0.7084055061812334, 0.6321275746145835, 0.7279225281811363, 0.7370938759652275)이를 이용해 예측 및 제출에서 pred를 형성하면 array안의 확률값이 다르게 나옵니다. 이유가 있을까요? 강의에서 score가 0.7정도면 괜찮은 성능이라고 하셨는데요. 시험장에서 채점기준에서 만점과 부분점수를 맞는 기준이 성능차이인가요? 만약 성능을 내지 못하고 전처리까지만 하고 csv파일을 만들지 않았다면 이는 부분점수도 못받는걸까요?? 한 질문에 여러가지 질문을 해서 죄송하게 생각합니다! 좋은 강의 감사드립니다
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
작업형1 모의문제2 강의에서 문제4
문제 4번 마지막에 데이터수를 구하기위해 sum을 할때 이런 오류가 뜹니다 ㅠㅠ 정수형이랑 수치형은 연산이 불가하다는(?) 오류인거같은데 수치형으로 바꿔보고자 int(df) int(df.sum()) 등 다양한 시도를 해봤는데 이런 식은 통하지않더라구요 ㅠㅠ 질문1) 풀이 과정에서 뭔가 잘못건드렸을까요? 왜 이런 오류가뜰까요 ㅠㅠ 질문2) 이런 오류가 떴을때 df를 수치형으로 바꾸는방법? # your codeimport pandas as pddf = pd.read_csv('members.csv')cols = df.select_dtypes('object').columnscolsdf = df[cols]df.head()df = df.fillna(0)df = df.Tdf.head()print(sum(df.sum() > 3000)) <--------이 과정에서 발생되는 오류입니다 <오류메세지> /usr/local/lib/python3.10/dist-packages/pandas/_libs/ops.pyx in pandas._libs.ops.scalar_compare() TypeError: '>' not supported between instances of 'str' and 'int'
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
2회 기출유형(작업형1) 에서 문제3
강의 듣고 혼자서 다시 풀어보는 도중에.. 질문이생겨 글남깁니다 ㅠㅠ 이상치를 벗어나는 값 찾기 cond1 = df['age'] < lowercond2 = df['age'] > upper여기까지는 이해가 가는데 여기서 이상치의 합을 구할떄 sum(cond1 + cond2) 를 하면 왜 안되는걸까요?'age'컬럼에서 lower 보다 작은것, upper보다 큰것을 더한다는 의미에서 될것같기도한데..sum(cond1 + cond2) 와 df[(cond1)|(cond2)]['age'].sum() 의 차이가 궁금합니다 ㅠㅠ 비전공자인지라 아직 개념이 부족하여 쓸데없는 질문을 많이드리는것같지만 ㅠㅠ 정확하게 공부하고싶어서 질문드립니다
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
예시문제 작업형2 질문
학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요!질문과 관련된 영상 위치를 알려주면 더 빠르게 답변할 수 있어요먼저 유사한 질문이 있었는지 검색해보세요안녕하세요! 강사님매번 강의 감사드립니다~~~다름이 아니라, 자꾸 여기서 에러가 발생하는데transform 부분에 무슨 에러가 있는 지 도저히 모르겠어서요....ㅜ
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
작업형1 모의문제3 강의중 문제7번
index '2001' 데이터(행)의 평균보다 큰 값의 수 를 구할때 df.T 실행 후 행과 열을 바꾸어서 df['2001'].mean() 으로 평균을 구하면 왜 안되는걸까요? ㅠㅠ 이런식으로 오류가 뜹니다 .오류 : KeyError: '2001'
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
작업형1 모의문제2 강의에서 문제4
문제 4번 마지막에 데이터수를 구하기위해 sum을 할때 이런 오류가 뜹니다 ㅠㅠ정수형이랑 수치형은 연산이 불가하다는(?) 오류인거같은데 수치형으로 바꿔보고자 int(df) int(df.sum()) 등 다양한 시도를 해봤는데 이런 식은 통하지않더라구요 ㅠㅠ 질문1) 풀이 과정에서 뭔가 잘못건드렸을까요? 왜 이런 오류가뜰까요 ㅠㅠ질문2) 이런 오류가 떴을때 df를 수치형으로 바꾸는방법? <작성한 코드># your code import pandas as pd df = pd.read_csv('members.csv') cols = df.select_dtypes('object').columns cols df = df[cols] df.head() df = df.fillna(0) df = df.T df.head() print(sum(df.sum() > 3000)) <--------이 과정에서 발생되는 오류입니다 <오류메세지>/usr/local/lib/python3.10/dist-packages/pandas/_libs/ops.pyx in pandas._libs.ops.scalar_compare() TypeError: '>' not supported between instances of 'str' and 'int'
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
기사 (2회): 기출유형-작업형2 풀이 오류 해석
안녕하세요.강의 잘 듣고 있습니다. 매번 질문에 답해주셔서 감사합니다.아래와 같이 코드를 짰는데데이터 프레임 만들기 submit = 에서 오류가 발생해서요.해당 오류가... 무슨 뜻인지 알려주세요.앞에서 test_id삭제하고 .pop을 빼먹었는데... 이것 땜에 발생했을까요?<오류내역>ValueError Traceback (most recent call last)<ipython-input-30-13b5884e1ac8> in <cell line: 63>()6162 # 데이터 내보내기---> 63 submit = pd.DataFrame(64 {65 'ID': X_test['ID'],/usr/local/lib/python3.10/dist-packages/pandas/core/internals/construction.py in extractindex(data)678 f"length {len(index)}"679 )--> 680 raise ValueError(msg)681 else:682 index = default_index(lengths[0])ValueError: array length 1760 does not match index length 2200<코드># 라이브러리 및 데이터 불러오기 import pandas as pd X_train = pd.read_csv("X_train.csv") y_train = pd.read_csv("y_train.csv") X_test = pd.read_csv("X_test.csv") # EDA print(X_train.head()) print(X_test.head()) print(y_train.head()) pd.set_option('display.max_columns', None) print(X_train.shape, X_test.shape, y_train.shape) # (8799, 11) (2200, 11) (8799, 2) print(X_train.info) print(X_train.describe()) print(X_train.describe(include = 'object')) # Warehouse_block, Mode_of_Shipment, Product_importance, Gender print(X_train.isnull().sum()) # 결측치 없음 print(y_train.value_counts('Reached.on.Time_Y.N')) #1 5236, 0 3563 # 데이터 전처리 # 피처엔지니어링 # 라벨 인코딩 from sklearn.preprocessing import LabelEncoder cols = ['Warehouse_block', 'Mode_of_Shipment', 'Product_importance', 'Gender'] cols1 = X_train.select_dtypes(include = 'object').columns for col in cols: la = LabelEncoder() X_train[col] = la.fit_transform(X_train[col]) X_test[col] = la.transform(X_test[col]) # 데이터 분할 from sklearn.model_selection import train_test_split X_tr, X_val, y_tr, y_val = train_test_split(X_train, y_train['Reached.on.Time_Y.N'],test_size = 0.2, random_state = 2023) print(X_tr.shape, X_val.shape, y_tr.shape, y_val.shape) #(7039, 11) (1760, 11) (7039,) (1760,) # 모델링 #분류(랜덤포레스트) from sklearn.ensemble import RandomForestClassifier model = RandomForestClassifier(random_state = 2023) model.fit(X_tr, y_tr) predict = model.predict_proba(X_val) print(predict) print(predict[:,1]) # 평가(ROC_AUC_SCORE) from sklearn.metrics import roc_auc_score pred=roc_auc_score(y_val, predict[:,1]) print(pred) # 랜덤포레스트 분류: 0.7340529818205483 # 예측 result = model.predict_proba(X_test) # 데이터 내보내기 submit = pd.DataFrame( { 'ID': X_test['ID'], 'Reached.on.Time_Y.N' : predict[:,1] } ) submit.to_csv("1111.csv", index = False)
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
독립성 검정 관련 질문
독립성검정 관련하여 코랩에서는 선생님이 하신대로 문제없이 실행되었습니다.그런데, 시험환경 체험하기에서 실행을 하다 보니 코랩에서 처럼 결과값(Chi2ContingencyResult(statistic=0.5552884615384607, pvalue=0.4561648467028253, dof=1, expected_freq=array([[47.14285714, 62.85714286], [27.85714286, 37.14285714]]))이 안나오고결과값들이 어떤 값인지 표시가 없는 상태((0.5552884615384607, 0.4561648467028253, 1, array([[47.14285714, 62.85714286], [27.85714286, 37.14285714]])) 로 나왔습니다.이렇게 나오는 이유와 개선 방법인 있는지요?하단에 시험환경에 코딩한 결과입니다.
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
데이터 전처리 IQR 이렇게 해도 되나요?
cols = list(X_train.columns[X_train.dtypes != object]) cols for col in cols: Q1 = X_train[col].quantile(.25) Q3 = X_train[col].quantile(.75) IQR = Q3-Q1 min_iqr = Q1 - 1.5*IQR max_iqr = Q3 + 1.5*IQR cnt_before = sum((X_train[col] < min_iqr) | (X_train[col] > max_iqr)) # (X_train[col] < min_iqr) | (X_train[col] > max_iqr), 주어진 조건 둘 중 하나라도 만족, 이상치를 나타내는 값을 선택하는 조건 print(f'{col}의 이상치 처리 전 이상치 개수: {cnt_before}개 입니다.') # f 접두사를 사용하여 문자열 안에서 중괄호 {} 안에 변수나 표현식을 넣을 수 있음 X_train = X_train[(X_train[col] >= min_iqr) & (X_train[col] <= max_iqr)] # (X_train[col] >= min_iqr) & (X_train[col] <= max_iqr), 주어진 조건 둘 다 만족, 이상치를 제외한 정상 범위의 데이터를 선택하는 조건 cnt_after = sum((X_train[col] < min_iqr) | (X_train[col] > max_iqr)) print(f'{col}의 이상치 처리 후 이상치 개수: {cnt_after}개 입니다.')
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
예시문제 작업형2
데이터 전처리할 때 왜 id를 삭제하나요?학습할 때 필요할 지테스트의 id값이 최종적으로 필요할 지 어떻게 아나요?
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
스케일링
안녕하세요. 자료에 따라 스케일링을 다르게 쓰시는 것 같은데요.일단 실기시험을 준비하는 입장에서는 어느 경우에 스탠다드, 민맥스, 로버스트 등을 쓰는지 잘 이해가 가지 않네요. 강사님게서 쓰시니까 그런가보다,, 하고 쓰긴 하는데 시험에서는 민맥스 스케일링 하나만 이해하고 사용해도 문제가 없을까요?
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
[예시문제 작업형2] EDA 중 이상치 처리
안녕하세요.강의 잘 듣고 있습니다.예시문제 작업형2 풀면서X_train.describe() 기초통계량 볼 때(3:56)총 구매액, 최대 구매액의 최소값이 음수여서...이상치로 판단하고 금액이 <0인 행은 drop..처리하고 했는데 괜찮은 걸까요?괜찮다면 결측치처리를 X_train, y_train 동시에 해주는 것처럼 결측치도 두 데이터에 모두 해줘야하는거죠?