inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

176만명의 커뮤니티!! 함께 토론해봐요.

작업형3 예시문제 ttest_rel

해결됨

[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)

ttest_rel 파라미터 중에 a,b가 있는데요 강의에서 설명주신 건 치료 후 혈압 - 치료 전 혈압 이렇게 표시되어 있으니 순서대로 넣어야 한다고 했는데요. 치료 전 혈압 - 치료 후 혈압 이라면 stats.ttest_rel(df['bp_before'] - df['bp_after']) 위와 같이 작성해야 하는 것으로 이해했습니다. 여기서, ttest_rel 유형은 예시문제 처럼 무조건 두 집단(혹은 조치 전 집단과 조치 후 집단)이 있고, 두 집단 사이의 차이를 이용하는 게 맞을까요?! a와 b를 그냥 설명주신대로만 이해하면 되는지 문의드립니다.

  • python
  • 머신러닝
  • 빅데이터
  • pandas
  • 빅데이터분석기사
눈누난나 댓글 1 좋아요 0 조회수 590

작업형2 모의문제 1 질문2

해결됨

[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)

import pandas as pd train = pd.read_csv("train.csv") test = pd.read_csv("test.csv") from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score, roc_auc_score train 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() from sklearn.preprocessing import MinMaxScaler cols = ['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]) c_train = pd.get_dummies(c_train) c_test = pd.get_dummies(c_test) train = pd.concat([n_train, c_train], axis =1) test = pd.concat([n_test, c_test], axis =1) train = train.drop('CLIENTNUM', axis =1) test = test.pop('CLIENTNUM') from sklearn.model_selection import train_test_split X_tr, X_val, y_tr, y_val = train_test_split( train, train['Attrition_Flag'], test_size = 0.2, random_state = 2023 ) from sklearn.ensemble import RandomForestClassifier from sklearn.metrics import roc_auc_score model = RandomForestClassifier(random_state = 2023) model.fit(X_tr, y_tr) pred = model.predict(X_val) print(pred) # 정확도 print(accuracy_score(y_val, pred)) # 정밀도 print(precision_score(y_val, pred)) # 재현율 (민감도) print(recall_score(y_val, pred)) # F1 print(f1_score(y_val , pred)) 위와 같이 코드를 진행시 [0 1 0 ... 1 0 1] 1.0 1.0 1.0 1.0 이 나옵니다. pred 자체가 1차원으로만 나오고 정확도 정밀도 재현율 F1도 1.0으로만 나오는데 무엇이 잘못된건지 모르겠습니다ㅠㅠ

  • python
  • 머신러닝
  • 빅데이터
  • pandas
  • 빅데이터분석기사
김태범 댓글 2 좋아요 1 조회수 523

작업형2 모의문제1 질문

해결됨

[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)

작업형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])

  • python
  • 머신러닝
  • 빅데이터
  • pandas
  • 빅데이터분석기사
김태범 댓글 1 좋아요 1 조회수 486

회귀문제에서 이런 오류 났을 때 어떻게 해결해야 하나요?

해결됨

[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)

pred1 = pred1.astype(int) y_val = y_val.astype(int) pred1 = np.log1p(pred1) y_val = np.log1p(y_val) rmse(np.exp(y_val),np.exp(pred1)) MSE loss가 기하급수적으로 증가해서 NaN값이 발생하는 것 같은데 어떻게 해결해야할지 모르겠어요! ㅠㅠ 에러는 아래에 있습니다. <ipython-input-35-aacfc97a4692>:3: RuntimeWarning: invalid value encountered in log1p pred1 = np.log1p(pred1) --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-35-aacfc97a4692> in <cell line: 6>() 4 y_val = np.log1p(y_val) 5 ----> 6 rmse(np.exp(y_val),np.exp(pred1)) 4 frames /usr/local/lib/python3.10/dist-packages/sklearn/utils/validation.py in _assert_all_finite(X, allow_nan, msg_dtype, estimator_name, input_name) 159 "#estimators-that-handle-nan-values" 160 ) --> 161 raise ValueError(msg_err) 162 163 ValueError: Input contains NaN.

  • python
  • 머신러닝
  • 빅데이터
  • pandas
  • 빅데이터분석기사
sychang2000 댓글 1 좋아요 1 조회수 521

df['가격']을 입력해도 오류가 납니다.

해결됨

[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)

데이터 핸들링을 위한 판다스 기초1 강의에 7:33에 df['가격']을 입력해도 오류가 납니다.

  • python
  • 머신러닝
  • 빅데이터
  • pandas
  • 빅데이터분석기사
빅분기 댓글 1 좋아요 0 조회수 269

data.csv가 보이지 않습니다.

해결됨

[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)

제가 하나도 모르는데요. ㅠㅠ "데이터 핸들링을 위한 판다스 기초1"에서 아무리 찾아도 data.csv가 보이지 않습니다. 새로고침을 해도 보이지가 않네요. 그 데이터를 따로 올려주실 수 있을까요? 감사합니다.

  • python
  • 머신러닝
  • 빅데이터
  • pandas
  • 빅데이터분석기사
빅분기 댓글 1 좋아요 0 조회수 416

피처엔지니어링-n/c_train데이터로 분리 후 다시 컬럼 나열해주는 이유?

해결됨

[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)

안녕하세요. 피처엔지니어링 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의 첫번째행이 포함되는게 아닌지 궁금합니다!!

  • python
  • 머신러닝
  • 빅데이터
  • pandas
  • 빅데이터분석기사
duddl 댓글 1 좋아요 0 조회수 403

모의고사 풀어보기2 관련 질문

해결됨

[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)

선생님, '모의고사 풀어보기2'를 선생님이 알려주신 lgb 로 시험환경에서 코딩 작업을 했는데 에러가 발생해서 문의드립니다. 어떤부분에서 잘못 코딩을 한 건지요? [코딩내용] 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.shape, test.shape) # print(train.head(3)) # print(test.head(3)) # print( train.info ()) # print(train.describe()) # print(train.isnull().sum()) 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.1, random_state=2022) # print(X_tr.shape, X_val.shape, y_tr.shape, y_val.shape) from sklearn.metrics import f1_score import lightgbm as lgb model = lgb.LGBMClassifier(random_state=2022) model.fit (X_tr, y_tr) pred = model.predict(X_val) print(pred[:10]) [에러] > Makefile:6: recipe for target 'py3_run' failed make: *** [py3_run] Error 1 Traceback (most recent call last): File "/goorm/Main.out", line 40, in <module> import lightgbm as lgb ModuleNotFoundError: No module named 'lightgbm'

  • python
  • 머신러닝
  • 빅데이터
  • pandas
  • 빅데이터분석기사
ycann 댓글 1 좋아요 0 조회수 482

모의고사 풀어보기2 관련

해결됨

[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)

선생님, '모의고사 풀어보기2' 를 시험환경에서 코딩을 하는데, 선생님께서 말씀해주신 lgb 를 사용하였는데, 없다는 에러가 나와서 문의드립니다. [코딩내용] 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.shape, test.shape) # print(train.head(3)) # print(test.head(3)) # print( train.info ()) # print(train.describe()) # print(train.isnull().sum()) 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.1, random_state=2022) # print(X_tr.shape, X_val.shape, y_tr.shape, y_val.shape) from sklearn.metrics import f1_score import lightgbm as lgb model = lgb.LGBMClassifier(random_state=2022) model.fit (X_tr, y_tr) pred = model.predict(X_val) print(pred[:10]) [에러] > Makefile:6: recipe for target 'py3_run' failed make: *** [py3_run] Error 1 Traceback (most recent call last): File "/goorm/Main.out", line 40, in <module> import lightgbm as lgb ModuleNotFoundError: No module named 'lightgbm'

  • python
  • 머신러닝
  • 빅데이터
  • pandas
  • 빅데이터분석기사
ycann 댓글 1 좋아요 0 조회수 236

작업형 2 풀 때

해결됨

[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)

안녕하세요. 강의 잘 듣고 있습니다. 작업형 2 풀면서 print(df.head())로 데이터들이 어떻게 생겼는지 샘플로 확인할 때 안 보이는 칼럼은 pd.set_option~~ 쓰고 값이 너무 커서 혹은 또 너무 작아서 e가 들어가는 수치값으로 보인다면... 어떤 코드를 실행하라고 강의 중에 말씀해주신거 같은데 ㅠㅠㅠ... 어느 강의였는지 기억이 안 나서요.. 혹시.. 코드 기억하실까요?ㅠㅠ

  • python
  • 머신러닝
  • 빅데이터
  • pandas
  • 빅데이터분석기사
가보자고 댓글 1 좋아요 1 조회수 254

작업형2 모의문제3 에러 문의

해결됨

[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)

선생님!!! 작업형2 모의문제3에서 마지막에 데이터프레임을 작성하는데서 에러가 발생하는데, 원인과 수정 방법이 무엇인지 궁급합니다. [코딩내용] import pandas as pd train = pd.read _csv('train.csv') test = pd.read _csv('test.csv') print(train.shape, test.shape) train.head(3) test.head(3) train.info () train.describe() test.describe() train.isnull().sum() test.isnull().sum() train = train.drop('id', axis=1) test_id = test.pop('id') test.head(3) 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.1, random_state=2022) X_tr.shape, X_val.shape, y_tr.shape, y_val.shape from sklearn.metrics import roc_auc_score, accuracy_score, f1_score from sklearn.ensemble import RandomForestClassifier rf = RandomForestClassifier(random_state=2022, max_depth=5, n_estimators=100) rf.fit (X_tr, y_tr) pred_proba = rf.predict_proba(X_val) pred_proba[:10] print(roc_auc_score(y_val, pred_proba[:,1])) pred_proba = rf.predict_proba(test) pred_proba[:10] pd.DataFrame({'id' : test_id, 'output' : pred_proba[ : , 1]}).to_csv('0000.csv', index=False) [에러메시지] TypeError Traceback (most recent call last) <ipython-input-128-a023f69b95e2> in <cell line: 3>() 1 pred_proba = rf.predict_proba(test) 2 pred_proba[:10] ----> 3 pd.DataFrame({'id' : test_id, 'output' : pred_proba[ : , 1]}).to_csv('0000.csv', index=False) TypeError: 'dict' object is not callable

  • python
  • 머신러닝
  • 빅데이터
  • pandas
  • 빅데이터분석기사
ycann 댓글 1 좋아요 0 조회수 415

작업형1 모의문제 질문

해결됨

[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)

문제1에서 df = df[:int(len(df) * 0.7)] 부분을 df = df.loc[:int(len(df) * 0.7)] 로 코딩했더니 답이 다르게 나옵니다. loc는 인덱스가 50이 있는 행까지만 출력되기에 70%의 데이터개수를 할때는 loc가 부적합한건가요? 문제2에서 df = df.dropna(subset=['f1']) 부분을 저는 df = df['f1'].dropna() 라고 코딩했더니 df.shape이 (69,) 로 나옵니다. df = df['f1'].dropna() 이건 해당 컬럼에 결측치가 있는 행을 삭제하는게 아닌가요?

  • python
  • 머신러닝
  • 빅데이터
  • pandas
  • 빅데이터분석기사
김태범 댓글 1 좋아요 1 조회수 398

작업형2 모의문제2 라벨인코딩 과정 중 에러

해결됨

[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)

안녕하세요! 강의 진행중 코드에서 오류가 생겨 질문드립니다 ㅠㅠ 라벨인코딩 하는도중 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'] 이런 오류가 나왔습니다 ㅠㅠ 위의 작성된코드를 살펴봐도 어디가 잘못된지모르겠어서, 또 저 에러가 무슨뜻인지 이해가 안가서 질문드립니다 ㅠ 또한, 데이터 전처리 과정 중 다소 불필요한 데이터(?)컬럼(?)을 삭제하지않고 진행할경우 성능이 크게 떨어질까요? ㅠㅠ 괜히 삭제했다가 나중에 뭔가 안맞아서 결과 도출에 오류가 생길까봐 컬럼을 삭제하는게 맘에 걸려서 시험에서는 되도록 그냥 두고싶습니다 ㅠㅠ 괜찮을까요?

  • python
  • 머신러닝
  • 빅데이터
  • pandas
  • 빅데이터분석기사
ji_nhee 댓글 1 좋아요 0 조회수 1080

3회 빅데이터 분석기사 실기(작업형2) 질문

해결됨

[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)

안녕하세요 강사님 강의듣던 와중에 질문 있습니다! 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])

  • python
  • 머신러닝
  • 빅데이터
  • pandas
  • 빅데이터분석기사
김태범 댓글 1 좋아요 0 조회수 363

n개 데이터 합치기/분리하기 질문

해결됨

[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)

라이브러리 및 데이터 불러오기 그리고 EDA강의중, 17:04->데이터 합치기 19:03->데이터 분리하기 부분입니다. N개의 데이터를 합치고 분리할 때 2개가 주어진 경우와 3개가 주어진 경우를 안다고 가정하고 ['income']을 기준으로 합치거나 분리하시던데, 시험에서는 2개나 3개 중 한가지로만 주어지지 않나요? 그럴 경우 어떤 컬럼을 기준으로 합/분리하는지 어떻게 알 수 있을까요..? 같은 강의의 EDA 전반 y_train데이터에 대해서는 결측치나 타입,크기 등을 확인하지 않아도 되는건가요..? 데이터전처리 강의에서 11:00->결측치채우기 -최빈값에서 mode() [0] 을 쓰시던데 [0]이 의미하는 바가 무엇인지 알고싶습니다!

  • python
  • 머신러닝
  • 빅데이터
  • pandas
  • 빅데이터분석기사
duddl 댓글 1 좋아요 0 조회수 394

첨부자료 관련

해결됨

[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)

안녕하세요 첨부파일 압축 풀면 들어있는 MACOSX 는 무엇일까요?

  • python
  • 머신러닝
  • 빅데이터
  • pandas
  • 빅데이터분석기사
greyy 댓글 1 좋아요 0 조회수 347

3회 기출유형(작업형2)_ csv 파일 생성 오류 등

해결됨

[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)

안녕하세요. 강의 잘 듣고 있습니다. 항상 어의없을 질문에도 친절하게 답해주셔서 정말 감사드립니다. 3회 기출유형(작업형 2)에서 관련해서 문의드립니다. 1. 문제를 보고 회귀인지 분류인지 구분이 잘 안될 땐 모델링을 회귀도 해보고 분류도 해봐서 가장 성능이 좋은 걸 사용하면 되겠죠? 2. 확률을 예측할 때 분류모델이면 proba를 써야하는데 predict=model.predict_proba(x_val) 회귀모델일 경우에는 proba를 사용 안 해도 되나요? predict=model.predict(x_val) 3. Unnamed: 0 변수를 의미없는 값이라고 생각하여 데이터 전처리 과정 중에 train, test 데이터에서 모두 drop을 했습니다. 근데.... 왜 csv 파일 생성할 때, 다시 나타난 걸까요...ㅠㅠ <출력된 csv 파일..> <코드> # 라이브러리 및 데이터 불러오기 import pandas as pd train = pd.read_csv("train.csv") test = pd.read_csv("test.csv") # EDA pd.set_option('display.max_columns',None) print(train.head()) # target: TravelInsurance 포함되어 있음 print(test.head()) print(train.shape, test.shape) print(train.info()) print(train.describe()) print(train.describe(include= 'object')) # Employment Type GraduateOrNot FrequentFlyer EverTravelledAbroad print(train.isnull().sum()) print(train.value_counts('TravelInsurance')) # 0 965, 1 525 # 데이터 전처리(결측치: 없음, 의미 없는 칼럼 삭제, ID 처리: 없음) # Unnamed: 0 삭제 train = train.drop('Unnamed: 0', axis = 1) test =test.drop('Unnamed: 0', axis = 1) print(train.shape, test.shape) print(train.head()) print(test.head()) # 피처엔지니어링(범주형) from sklearn.preprocessing import LabelEncoder cols = ['Employment Type', 'GraduateOrNot', 'FrequentFlyer', 'EverTravelledAbroad'] for col in cols: la = LabelEncoder() train[col] = la.fit_transform(train[col]) test[col] = la.transform(test[col]) # 데이터 분할 from sklearn.model_selection import train_test_split x_tr, x_val, y_tr, y_val = train_test_split(train.drop('TravelInsurance', axis =1), train['TravelInsurance'], test_size = 0.2, random_state = 2023) print(x_tr.shape, x_val.shape, y_tr.shape, y_val.shape) # (1192, 8) (298, 8) (1192,) (298,) # 모델링(회귀) # import sklearn # print(sklearn.__all__) # print(sklearn.linear_model.__all__) from sklearn.linear_model import LinearRegression model = LinearRegression() model.fit(x_tr, y_tr) predict=model.predict(x_val) print(predict) # 성능평가(roc_auc_score) from sklearn.metrics import roc_auc_score r = roc_auc_score(y_val, predict) print(r) #베이스: 0.7544863861386139 # 예측 predict=model.predict(test) # 데이터 내보내기 submit = pd.DataFrame( { 'y_pred' : predict } ).reset_index().to_csv("1111.csv") df1 = pd.read_csv("1111.csv") print(df1.head())

  • python
  • 머신러닝
  • 빅데이터
  • pandas
  • 빅데이터분석기사
가보자고 댓글 1 좋아요 0 조회수 404

빅데이터 분석기사(3회): 기출유형-작업형1 문제1

해결됨

[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)

안녕하세요! df = pd.read_csv("members.csv") import pandas as pd df = df.dropna() length = int(len(df) * 0.7) df = df.head(length) df['f1'].quantile(0.25) 저는 처음에 위와 같이 풀었는데 값은 동일하게 57.0이 나오는데요! 문제를 풀때 iloc를 안쓰고 해당 방법처럼 head(length)해서 df값에 넣어도 iloc랑 문제없을까요?

  • python
  • 머신러닝
  • 빅데이터
  • pandas
  • 빅데이터분석기사
김태범 댓글 1 좋아요 1 조회수 431

작업형1 모의문제3 문제8

해결됨

[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)

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되었다고 하는데요, 이는 다른 함수로 대체되거나 아예 사라지는 것으로 알고있습니다. 시험보는 버전 내에서는 문제없이 사용해도 될까요?

  • python
  • 머신러닝
  • 빅데이터
  • pandas
  • 빅데이터분석기사
눈누난나 댓글 2 좋아요 0 조회수 568

Warning 대처방법 문의드립니다.

해결됨

[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)

작업형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()

  • python
  • 머신러닝
  • 빅데이터
  • pandas
  • 빅데이터분석기사
sayno9 댓글 2 좋아요 0 조회수 674

인기 태그

인프런 TOP Writers

주간 인기글