작업형1 모의문제3 의 9번 문제를 풀었는데 답에 '대구'만 나오지 않고 밑에 다른 설명이 나오는데, 무슨 의미이고 왜 나오는지 궁금합니다. [코딩 내용] import pandas as pd df = pd.read _csv('members.csv') # print(df.shape) # print(df.head(10)) df = df.fillna(method = 'bfill') df.head() df = df.groupby(['city', 'f2']).sum().reset_index() df.head() df = df.sort_values('views', ascending=False) df.head() print(df.iloc[2,0]) [답안내용] 대구 <ipython-input-102-fa90dbbb01dd>:7: 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()
안녕하세요. 강의 잘 듣고 있습니다. 보통 작업형2 실행시 train 데이터 id drop하고, test 데이터 id pop처리 했는데 (작업형2 모의문제1 에서는 CLIENTNUM 드롭 및 팝처리 함) 5회 작업형 2에서는 실시 안 하셨길래... 다른 이유라도 있으신지 궁금합니다. submit으로 내보내기해야하는 값에 price만 있어서 그런가요? 언제 해야하고.. .언제 안 해야하는지.. 넘 헷갈려서요. model을 없애고 돌린게.. rmse가 더 높긴 하더라구요.... ^^;; train = train.drop('model', axis = 1) test_model = test.pop('model')
ttest_rel 파라미터 중에 a,b가 있는데요 강의에서 설명주신 건 치료 후 혈압 - 치료 전 혈압 이렇게 표시되어 있으니 순서대로 넣어야 한다고 했는데요. 치료 전 혈압 - 치료 후 혈압 이라면 stats.ttest_rel(df['bp_before'] - df['bp_after']) 위와 같이 작성해야 하는 것으로 이해했습니다. 여기서, ttest_rel 유형은 예시문제 처럼 무조건 두 집단(혹은 조치 전 집단과 조치 후 집단)이 있고, 두 집단 사이의 차이를 이용하는 게 맞을까요?! a와 b를 그냥 설명주신대로만 이해하면 되는지 문의드립니다.
작업형2 문제마다 어떤문제들은 n_train, c_train, n_test, c_test로 나누는 문제들이 있고 그렇지 않은 문제들이 있어서 헷갈리는데요. 수치형변수를 스케일링하는 과정을 거치려면 n_train, c_train, n_test, c_test로 나눠야 하고, 스케일링 과정을 생략하고 범주형 변수 인코딩 과정만을 진행할때는 나눌필요가 없는게 맞나요? 작업형 모의문제 1을 혼자 풀어보는 와중 MinMaxScaler로 스케일링을 해보는중인데 from sklearn.preprocessing import MinMaxScaler cols = ['CLIENTNUM', 'Customer_Age','Dependent_count', 'Months_on_book', 'Total_Relationship_Count', 'Months_Inactive_12_mon', 'Contacts_Count_12_mon', 'Credit_Limit', 'Total_Revolving_Bal', 'Avg_Open_To_Buy', 'Total_Amt_Chng_Q4_Q1', 'Total_Trans_Amt', 'Total_Trans_Ct', 'Total_Ct_Chng_Q4_Q1', 'Avg_Utilization_Ratio'] scaler = MinMaxScaler() for col in cols: n_train[col] = scaler.fit_transform(n_train[col]) n_test[col] = scaler.transform(n_test[col]) ValueError Traceback (most recent call last) <ipython-input-38-b70edfd82bf0> in <cell line: 5>() 4 scaler = MinMaxScaler() 5 for col in cols: ----> 6 n_train[col] = scaler.fit_transform(n_train[col]) 7 n_test[col] = scaler.transform(n_test[col]) 8 5 frames /usr/local/lib/python3.10/dist-packages/sklearn/utils/validation.py in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, estimator, input_name) 900 # If input is 1D raise error 901 if array.ndim == 1: --> 902 raise ValueError( 903 "Expected 2D array, got 1D array instead:\narray={}.\n" 904 "Reshape your data either using array.reshape(-1, 1) if " ValueError: Expected 2D array, got 1D array instead: array=[0.58522152 0.08465774 0.60121236 ... 0.06531669 0.06194963 0.52375209]. Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample. 위와 같은 오류가 발생합니다. 혹시 어떤 부분이 잘못된걸까요? 반면에 아래와 같이 실행할 경우 오류가 발생하지않습니다. 강의에서는 cols안에 컬럼값이 여러개이므로 반복문을 써야한다고 배웠는데 제가 잘못알고있는걸까요? from sklearn.preprocessing import MinMaxScaler cols = ['CLIENTNUM', 'Customer_Age','Dependent_count', 'Months_on_book', 'Total_Relationship_Count', 'Months_Inactive_12_mon', 'Contacts_Count_12_mon', 'Credit_Limit', 'Total_Revolving_Bal', 'Avg_Open_To_Buy', 'Total_Amt_Chng_Q4_Q1', 'Total_Trans_Amt', 'Total_Trans_Ct', 'Total_Ct_Chng_Q4_Q1', 'Avg_Utilization_Ratio'] scaler = MinMaxScaler() n_train[cols] = scaler.fit_transform(n_train[cols]) n_test[cols] = scaler.transform(n_test[cols])
안녕하세요. 피처엔지니어링 10:33~ 이후 질문입니다! 수치형/범주형데이터를 먼저 나누고 print(c_train.head())등을 해보았을 때 범주형컬럼이 있는 걸 알 수 있는데, 라벨 인코딩/원핫인코딩 전에 cols=['~,~,~']으로 범주형컬럼을 재설정해주는 이유가 궁금합니다 ~~! (수치형은 id 컬럼을 빼기위해라고 이해했습니다) 라벨인코딩에서 from sklearn.preprocessing import LabelEncoder le=LabelEncoder() cols=['~~~'] for col in cols: le=LabelEncoder() 로 <-이 부분을 두번 적어주는 이유가 무엇일까요? train,test 데이터의 카테고리가 다르면 두 개를 합친 다음->인코딩->분리해야한다고 하셨는데 두개가 다른건 .unique()등으로 눈으로 직접 확인해야 하는건가요..? 같은 부분에서 iloc는 찾을값 -1 로 [ ] 안에 적는다고 알고 있는데 (ex.kaggle t1-23번에서 10번째 값을 찾을 때 iloc[9]로 찾음) line=int(X_train.shape[0] X_train=all.iloc[line: ~~] 로 적으면 test의 첫번째행이 포함되는게 아닌지 궁금합니다!!
안녕하세요. 강의 잘 듣고 있습니다. 작업형 2 풀면서 print(df.head())로 데이터들이 어떻게 생겼는지 샘플로 확인할 때 안 보이는 칼럼은 pd.set_option~~ 쓰고 값이 너무 커서 혹은 또 너무 작아서 e가 들어가는 수치값으로 보인다면... 어떤 코드를 실행하라고 강의 중에 말씀해주신거 같은데 ㅠㅠㅠ... 어느 강의였는지 기억이 안 나서요.. 혹시.. 코드 기억하실까요?ㅠㅠ
안녕하세요! 강의 진행중 코드에서 오류가 생겨 질문드립니다 ㅠㅠ 라벨인코딩 하는도중 cols = train.select_dtypes(include='object').columns cols 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() 이렇게 작성하였으나 TypeError: Encoders require their input to be uniformly strings or numbers. Got ['int', 'str'] 이런 오류가 나왔습니다 ㅠㅠ 위의 작성된코드를 살펴봐도 어디가 잘못된지모르겠어서, 또 저 에러가 무슨뜻인지 이해가 안가서 질문드립니다 ㅠ 또한, 데이터 전처리 과정 중 다소 불필요한 데이터(?)컬럼(?)을 삭제하지않고 진행할경우 성능이 크게 떨어질까요? ㅠㅠ 괜히 삭제했다가 나중에 뭔가 안맞아서 결과 도출에 오류가 생길까봐 컬럼을 삭제하는게 맘에 걸려서 시험에서는 되도록 그냥 두고싶습니다 ㅠㅠ 괜찮을까요?
안녕하세요 강사님 강의듣던 와중에 질문 있습니다! 2회 작업형2에서는 수치형변수 스케일링 과정이 없었고 이번 3회작업형2에서는 수치형변수 스케일링 과정이 있네요. 혹시 이유가 있을까요? 또 3회에서 MinMaxScaler나 StandardScaler를 쓰는것 또한 저의 재량인지 궁금합니다.\ 2회에서는 copy의 과정이 없었는데 3회에서는 copy를 한 이유가 있나요? 시험장에서 어떤방식으로 밀고나가야할지 혼란스러워요ㅠ 괄호안에 ' ' 와 " " 는 동일한가요? 검증데이터 분리시 train_test_split(train.drop('TravelInsurance', axis =1), train['TravelInsurance'] 에서 TravelInsurance를 drop한 이유가 뭔가요? 2회 작업형2에서는 ID를 drop한건 학습할때 필요가 없어서로 알고있는데 해당 문제에서는 Unnamed를 drop해야하는것 아닐까요? 헷갈리네요ㅠㅠ 수치형 변수 스케일링 과정에서 cols = ['Age', 'AnnualIncome', 'FamilyMembers', 'ChronicDiseases'] display(n_train.head()) n_train[cols] = scaler.fit_transform(n_train[cols]) n_test[cols] = scaler.transform(n_test[cols]) n_train.head() 이 부분에서 2회 작업형 2번처럼 cols안에 여러개가 들어있으므로 아래와 같이 반복문을 쓰거나 for col in cols: le = LabelEncoder() X_train[col] = le.fit_transform(X_train[col]) X_test[col] = le.transform(X_test[col]) 아래와 같이 일일히 col을 설정해줘야 오류가 안생기지 않나요? # col = 'Warehouse_block' # le = LabelEncoder() # X_train[col] = le.fit_transform(X_train[col]) # X_test[col] = le.transform(X_test[col]) # col = 'Mode_of_Shipment' # le = LabelEncoder() # X_train[col] = le.fit_transform(X_train[col]) # X_test[col] = le.transform(X_test[col]) # col = 'Product_importance' # le = LabelEncoder() # X_train[col] = le.fit_transform(X_train[col]) # X_test[col] = le.transform(X_test[col]) # col = 'Gender' # le = LabelEncoder() # X_train[col] = le.fit _transform(X_train[col]) # X_test[col] = le.transform(X_test[col])
마지막 전처리 전후의 표준편차값을 출력할때 제가 혼자 했을때는 print(df['distance'].std()) print(df_af['distance'].std()) 로 하였는데 출력결과 275.2191532793011 267.2360034486679 이와 같이 나왔습니다. 강의에서 나온바와 같이 print(np.std(df['distance'])) print(np.std(df_af['distance'])) 넘파이를 활용하여 계산하였는데 결과는 강의와 동일하게 275.0161144074897 267.05138442597666 이와 같이 나왔습니다 1) 넘파이 라이브러리를 사용한 것과 안한 것의 차이가 나타나는 이유는 무엇인가요? 2) 작업유형1 의 경우, 출력결과는 정수형으로 나타내야 하는것으로 알고 있습니다. 두가지 경우, int함수를 사용하면 결과값이 같게 나오는데 이경우에도 풀이는 다르지만 결과 출력값만 동일하면 정답으로 인정되나요?