묻고 답해요
161만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
작업형1 모의문제
import numpy as npdf['f3'] = df['f3'].replace(np.nan,0).replace('silver',1).replace('gold',2).replace('vip',3)라고 하셨는데 df['f3'] = df['f3'].fillna(0)df['f3'] = df['f3'].replace("silver", 1).replace("gold", 2).replace("vip", 3) 이렇게 해도 답이 133으로 똑같이 나오더라구요!이렇게 해도 되나용?
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
전체 열을 한번에 주석 # 처리하는 방법이 뭔가요?
3-6. 강의에서모델 최적화를 하는 과정에서스케일러를from sklearn.preprocessing import StandardScalerscaler = StandardScaler()cols = ['age', 'bmi']train[cols] = scaler.fit_transform(train[cols])test[cols] = scaler.transform(test[cols])에서 #from sklearn.preprocessing import StandardScaler#scaler = StandardScaler()#cols = ['age', 'bmi']#train[cols] = scaler.fit_transform(train[cols])#test[cols] = scaler.transform(test[cols]) 이렇게 한번에 주석(#)처리하셨는데,어떻게 하신건가요?alt+#shift+#ctrl+# 했는데 다 안되네요ㅠ
-
미해결[리뉴얼] 처음하는 파이썬 데이터 분석 (쉽게! 전처리, pandas, 시각화 전과정 익히기) [데이터분석/과학 Part1]
조건 산식 표현 관련 질문 (~개 이상)
아래와 같이 연습문제에서 "~개 이상" 이라는 조건에서선생님께서는 >= 등호를 사용하지 않으시고 > 만 사용하시더라고요.저는 >= 로 알고 있었는데.. 혹시 제가 잘못 알고 있었던건가요?ㅠㅠ
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
원핫인코딩 질문
3-4. 의 원핫인코딩에서는c_train = pd.get_dummies(c_train[cols])c_test = pd.get_dummies(c_test[cols]) 3-6. 의 원핫인코딩에서는train = pd.get_dummies(train, columns=cols)test = pd.get_dummies(test, columns=cols)라고 되어 있네요ㅠ 3-6에서도 3-4처럼train = pd.get_dummies(train[cols])test = pd.get_dummies(test[cols])로 실행해 봤는데 결과가 다르게 나오네요! 왜 3-4에서는 [cols] 라고 하고,3-6에서는 columns=cols라고 하는건가요?ㅠ
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
시계열 데이터 수업 자료 어디에?
시계열 데이터를 다루는 수업을 현재 보고 있는데, 관련 자료가 어디에 있나요?제가 일일히 쳐서 하기가 어려워서 데이터 프레임을 받고싶은데,,, 어디에 있는지 못찾겠어요.
-
해결됨5분빨리 퇴근하자! 파이썬 데이터 분석, 시각화, 웹 대시보드 제작하기
button과 checkbox 조건문과 함수
버튼과 체크박스 모두 조건문을 사용할 때는 바로 아래에 텍스트가 출력되는데, 함수를 사용하면 대시보드 맨 위에 텍스트가 호출되는 것은 왜 그런건가요?(맨 위에 텍스트가 호출되어 출력된 부분이 전부 다 한 칸 씩 밀리게 됨)
-
미해결파이썬 무료 강의 (활용편5) - 데이터 분석 및 시각화
IN[ ] 번호 질문
IN[ ] 번호가 이어지지않고 1234567123 되어서 자꾸 오류가 나는데 해결 방법 아는 분 없나요? 강사님처럼 미리 셀을 다수 개를 준비했을 때 오류가 나기 때문에 run 하면서 하나 씩 해나가면 오류가 발생하지 않아요, 하루 동안 애 먹다가 발견했습니다. 강사님은 대충 몇개 셀이 필요한지 알기 때문에 오류가 발생하지 않지만, 초보자는 123412 나올때 정의 되어 있지 않다고 리절트 됩니다. 저처럼 오류가 나는 분이 계실 까봐 지우지 않았습니다.
-
해결됨5분빨리 퇴근하자! 파이썬 데이터 분석, 시각화, 웹 대시보드 제작하기
annot 수치 표현
age_bin_list = np.arange(10, 80, 10) df['age_bin'] = pd.cut(df['age'], bins = age_bin_list) pivot_df = df.pivot_table( index = 'age_bin', columns = 'region', values = 'charges', aggfunc = 'median' # 각 구간에 해당하는 값을 중간값을 사용하겠다. ) pivot_df # 각각의 값들에 대해 크기를 가늠할 수 있게끔 시각화(주로 색상)하는 방법 # 2D 형식으로 준비된 데이터를 Seaborn heatmap으로 시각화 # annot 인자를 통해 각 셀의 값 표현 가능 fig, ax = plt.subplots() sns.heatmap(pivot_df, ax = ax, annot = True)코드 똑같이 따라했는데 왜 저는 표에 수치가 다 표현이 안되는 건가요?
-
미해결[리뉴얼] 처음하는 파이썬 머신러닝 부트캠프 (쉽게! 실제 캐글 문제 풀며 정리하기) [데이터분석/과학 Part2]
Bayesian Optimization에서 optimizer.maximize()함수를 더이상 지원 안한다고 합니다.
- 본 강의 영상 학습 관련 문의에 대해 답변을 드립니다. (어떤 챕터 몇분 몇초를 꼭 기재부탁드립니다)- 이외의 문의등은 평생강의이므로 양해를 부탁드립니다- 현업과 병행하는 관계로 주말/휴가 제외 최대한 3일내로 답변을 드리려 노력하고 있습니다- 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. import numpy as np from xgboost import XGBClassifier from bayes_opt import BayesianOptimization from sklearn.model_selection import cross_val_score pbounds = { 'learning_rate': (0.01, 0.5), 'n_estimators': (100, 1000), 'max_depth': (3, 10), 'min_child_weight': (0, 10), 'subsample': (0.5, 1.0), 'colsample_bytree': (0.5, 1.0) # 'reg_lambda': (0, 1000), # 'reg_alpha': (0, 1.0) } def lgbm_hyper_param(learning_rate, n_estimators, max_depth, min_child_weight, subsample, colsample_bytree): max_depth = int(max_depth) n_estimators = int(n_estimators) clf = LGBMClassifier( max_depth=max_depth, min_child_weight=min_child_weight, learning_rate=learning_rate, n_estimators=n_estimators, subsample=subsample, colsample_bytree=colsample_bytree, random_state=1 # reg_lambda=reg_lambda, # reg_alpha=reg_alpha ) return np.mean(cross_val_score(clf, train_importance, train_answer, cv=5, scoring='accuracy')) # cv 도 숫자로 작성하여, 내부적으로 (Stratified)KFold 사용함 optimizer = BayesianOptimization( f=lgbm_hyper_param, pbounds=pbounds, verbose=1, random_state=1) optimizer.maximize(init_points=10, n_iter=100, acq='ei', xi=0.01) 위 코드를 실행하면 아래와 같은 에러가 발생합니다.--------------------------------------------------------------------------- Exception Traceback (most recent call last) Cell In[44], line 34 31 return np.mean(cross_val_score(clf, train_importance, train_answer, cv=5, scoring='accuracy')) # cv 도 숫자로 작성하여, 내부적으로 (Stratified)KFold 사용함 33 optimizer = BayesianOptimization( f=lgbm_hyper_param, pbounds=pbounds, verbose=1, random_state=1) ---> 34 optimizer.maximize(init_points=10, n_iter=100, acq='ei', xi=0.01) File ~\miniconda3\Lib\site-packages\bayes_opt\bayesian_optimization.py:288, in BayesianOptimization.maximize(self, init_points, n_iter, acquisition_function, acq, kappa, kappa_decay, kappa_decay_delay, xi, **gp_params) 286 old_params_used = any([param is not None for param in [acq, kappa, kappa_decay, kappa_decay_delay, xi]]) 287 if old_params_used or gp_params: --> 288 raise Exception('\nPassing acquisition function parameters or gaussian process parameters to maximize' 289 '\nis no longer supported. Instead,please use the "set_gp_params" method to set' 290 '\n the gp params, and pass an instance of bayes_opt.util.UtilityFunction' 291 '\n using the acquisition_function argument\n') 293 if acquisition_function is None: 294 util = UtilityFunction(kind='ucb', 295 kappa=2.576, 296 xi=0.0, 297 kappa_decay=1, 298 kappa_decay_delay=0) Exception: Passing acquisition function parameters or gaussian process parameters to maximize is no longer supported. Instead,please use the "set_gp_params" method to set the gp params, and pass an instance of bayes_opt.util.UtilityFunction using the acquisition_function argument "set_gp_params" method을 사용하라고 하는데gpt에 물어봐도 제대로 된 코드를 주지 않아서 어려움이 있습니다. 제가 설치한 라이브러리는 아래 목록과 같습니다..Package Version ---------------------------- ------------ absl-py 2.1.0 anyio 3.5.0 archspec 0.2.1 argon2-cffi 21.3.0 argon2-cffi-bindings 21.2.0 asttokens 2.0.5 astunparse 1.6.3 async-lru 2.0.4 attrs 23.1.0 Babel 2.11.0 bayesian-optimization 1.4.3 beautifulsoup4 4.12.2 bleach 4.1.0 boltons 23.0.0 Brotli 1.0.9 cachetools 5.3.2 certifi 2023.11.17 cffi 1.16.0 charset-normalizer 2.0.4 colorama 0.4.6 comm 0.1.2 conda 23.11.0 conda-content-trust 0.2.0 conda-libmamba-solver 23.12.0 conda-package-handling 2.2.0 conda_package_streaming 0.9.0 contourpy 1.2.0 cryptography 41.0.7 cv 1.0.0 cycler 0.12.1 debugpy 1.6.7 Note: you may need to restart the kernel to use updated packages. decorator 5.1.1 defusedxml 0.7.1 distro 1.8.0 executing 0.8.3 fastjsonschema 2.16.2 flatbuffers 23.5.26 fonttools 4.47.2 gast 0.5.4 google-auth 2.26.2 google-auth-oauthlib 1.2.0 google-pasta 0.2.0 grpcio 1.60.0 h5py 3.10.0 idna 3.4 ipykernel 6.25.0 ipython 8.20.0 ipywidgets 8.0.4 jedi 0.18.1 Jinja2 3.1.2 joblib 1.3.2 json5 0.9.6 jsonpatch 1.32 jsonpointer 2.1 jsonschema 4.19.2 jsonschema-specifications 2023.7.1 jupyter 1.0.0 jupyter_client 8.6.0 jupyter-console 6.6.3 jupyter_core 5.5.0 jupyter-events 0.8.0 jupyter-lsp 2.2.0 jupyter_server 2.10.0 jupyter_server_terminals 0.4.4 jupyterlab 4.0.8 jupyterlab-pygments 0.1.2 jupyterlab_server 2.25.1 jupyterlab-widgets 3.0.9 keras 2.15.0 kiwisolver 1.4.5 libclang 16.0.6 libmambapy 1.5.3 lightgbm 4.3.0 Markdown 3.5.2 MarkupSafe 2.1.3 matplotlib 3.8.2 matplotlib-inline 0.1.6 menuinst 2.0.1 mistune 2.0.4 ml-dtypes 0.2.0 nbclient 0.8.0 nbconvert 7.10.0 nbformat 5.9.2 nest-asyncio 1.5.6 notebook 7.0.6 notebook_shim 0.2.3 numpy 1.26.3 oauthlib 3.2.2 opencv-python 4.9.0.80 opt-einsum 3.3.0 overrides 7.4.0 packaging 23.1 pandas 2.2.0 pandocfilters 1.5.0 parso 0.8.3 pillow 10.2.0 pip 23.3.2 platformdirs 3.10.0 pluggy 1.0.0 ply 3.11 prometheus-client 0.14.1 prompt-toolkit 3.0.43 protobuf 4.23.4 psutil 5.9.0 pure-eval 0.2.2 pyasn1 0.5.1 pyasn1-modules 0.3.0 pycosat 0.6.6 pycparser 2.21 Pygments 2.15.1 pyOpenSSL 23.2.0 pyparsing 3.1.1 PyQt5 5.15.10 PyQt5-sip 12.13.0 PySocks 1.7.1 python-dateutil 2.8.2 python-json-logger 2.0.7 pytz 2023.3.post1 pywin32 305.1 pywinpty 2.0.10 PyYAML 6.0.1 pyzmq 25.1.0 qtconsole 5.5.0 QtPy 2.4.1 referencing 0.30.2 requests 2.31.0 requests-oauthlib 1.3.1 rfc3339-validator 0.1.4 rfc3986-validator 0.1.1 rpds-py 0.10.6 rsa 4.9 ruamel.yaml 0.17.21 scikit-learn 1.4.0 scipy 1.12.0 Send2Trash 1.8.2 setuptools 68.2.2 sip 6.7.12 six 1.16.0 sniffio 1.3.0 soupsieve 2.5 stack-data 0.2.0 tensorboard 2.15.1 tensorboard-data-server 0.7.2 tensorflow 2.15.0 tensorflow-estimator 2.15.0 tensorflow-intel 2.15.0 tensorflow-io-gcs-filesystem 0.31.0 termcolor 2.4.0 terminado 0.17.1 threadpoolctl 3.2.0 tinycss2 1.2.1 tornado 6.3.3 tqdm 4.65.0 traitlets 5.7.1 truststore 0.8.0 typing_extensions 4.7.1 tzdata 2023.4 urllib3 1.26.18 wcwidth 0.2.5 webencodings 0.5.1 websocket-client 0.58.0 Werkzeug 3.0.1 wheel 0.41.2 widgetsnbextension 4.0.5 win-inet-pton 1.1.0 wrapt 1.14.1 xgboost 2.0.3 zstandard 0.19.0 궁극적인 질문은앞으로 파이썬은 계속 업데이트가 될텐데 그때마다어디를 찾아봐야하는지 어떻게 검색해야하는지에 관해서도 알려주시면 감사하겠습니다..
-
미해결[리뉴얼] 처음하는 파이썬 머신러닝 부트캠프 (쉽게! 실제 캐글 문제 풀며 정리하기) [데이터분석/과학 Part2]
Bayesian Optimization LightGBM 적용
import numpy as npfrom xgboost import XGBClassifierfrom bayes_opt import BayesianOptimizationfrom sklearn.model_selection import cross_val_scorepbounds = { 'learning_rate': (0.01, 0.5), 'n_estimators': (100, 1000), 'max_depth': (3, 10), 'min_child_weight': (0, 10), 'subsample': (0.5, 1.0), 'colsample_bytree': (0.5, 1.0) # 'reg_lambda': (0, 1000), # 'reg_alpha': (0, 1.0)}def lgbm_hyper_param(learning_rate, n_estimators, max_depth, min_child_weight, subsample, colsample_bytree): max_depth = int(max_depth) n_estimators = int(n_estimators) clf = LGBMClassifier( max_depth=max_depth, min_child_weight=min_child_weight, learning_rate=learning_rate, n_estimators=n_estimators, subsample=subsample, colsample_bytree=colsample_bytree, random_state=1 # reg_lambda=reg_lambda, # reg_alpha=reg_alpha ) return np.mean(cross_val_score(clf, train_importance, train_answer, cv=5, scoring='accuracy')) # cv 도 숫자로 작성하여, 내부적으로 (Stratified)KFold 사용함optimizer = BayesianOptimization( f=lgbm_hyper_param, pbounds=pbounds, verbose=1, random_state=1)optimizer.maximize(init_points=10, n_iter=100, acq='ei', xi=0.01)에서| iter | target | colsam... | learni... | max_depth | min_ch... | n_esti... | subsample | ------------------------------------------------------------------------------------------------- [LightGBM] [Info] Number of positive: 273, number of negative: 439 [LightGBM] [Info] Auto-choosing row-wise multi-threading, the overhead of testing was 0.000185 seconds. You can set force_row_wise=true to remove the overhead. And if memory is not enough, you can set force_col_wise=true. [LightGBM] [Info] Total Bins 90 [LightGBM] [Info] Number of data points in the train set: 712, number of used features: 45 [LightGBM] [Info] [binary:BoostFromScore]: pavg=0.383427 -> initscore=-0.475028 [LightGBM] [Info] Start training from score -0.475028 [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf같은 오류가 발생합니다...
-
해결됨5분빨리 퇴근하자! 파이썬 데이터 분석, 시각화, 웹 대시보드 제작하기
groupby 경고 질문
groupby를 사용하면 에러는 아니고 경고가 뜹니다. FutureWarning: The default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.chatGPT:이 경고는 Pandas의 value_counts() 메서드를 사용할 때 발생하는 것으로 보입니다. 이 경고는 현재 버전의 Pandas에서는 observed 매개변수의 기본값이 False이지만, 향후 버전에서는 True로 변경될 것이라는 것을 알려주는 것입니다. 즉, 향후에는 observed=False를 명시적으로 지정하지 않으면 경고가 표시될 것입니다.이러한 경고를 피하려면 value_counts()를 호출할 때 observed=False를 명시적으로 전달하면 됩니다. 예를 들어:import pandas as pd # 예제 데이터프레임 생성 df = pd.DataFrame({'Category': ['A', 'B', 'A', 'C', 'B', 'A']}) # value_counts() 호출 시 observed 매개변수 명시 counts = df['Category'].value_counts(observed=False) print(counts)이렇게 하면 경고가 발생하지 않습니다. 하지만 향후 Pandas 버전에서는 이러한 변경이 기본 동작이 되므로 observed 매개변수를 사용하여 코드를 업데이트하는 것이 좋습니다.-> 근데 이게 무슨 말인지 모르겠습니다! 뭐... 대충 업데이트 할 건데, 오류가 생길 수 있으니 미리 대비를 해라~ 이런 거 같은데 정확히 무슨 뜻인지 모르겠습니다!
-
미해결비트코인 알고리즘 트레이딩 봇 개발
ta 모듈을 못 찾습니다
ta 를 계속 못 찾아서 install 한 lib 를 삭제하고 다시 설치했는데 같은 오류가 발생합니다
-
해결됨5분빨리 퇴근하자! 파이썬 데이터 분석, 시각화, 웹 대시보드 제작하기
print()
파이썬에서는 print() 구문이 굉장히 중요하다고 들었는데, 주피터랩에서는 print 없이 df만 써도 표가 나오는 이유는 왜인가요? print(df)를 했을 때는 표가 아니라 글로 나오네요.! 차이가 궁금해서 질문 남깁니다.
-
미해결비트코인 알고리즘 트레이딩 봇 개발
데이터수집하기 오류
실행하면 해당 오류 발생합니다. requests2.25.1 입니다
-
미해결공공데이터로 파이썬 데이터 분석 시작하기
stamen toner 오류 : ValueError: Custom tiles must have an attribution.
선생님너무 즐겁게 강의를 수강하고, 다시 듣고 있는 수강생입니다.[9/10] folium의 CircleMarker로 매장위치 표현하고 타일로 스타일 바꾸기강좌에서 과거에는 선생님 예제 처럼 하면 잘 동작했는데 지금은 오류가 납니다. 어떻게 해야 될까요?문제지점 : folium 지도 설정에 tiles 를 stamen toner를 지정하면 ValueError: Custom tiles must have an attribution. 이런 오류가 발생합니다. 바쁘시겠지만, 한번 살펴 주시면 다른 수강생들에게도 도움이 될 거라 생각합니다. 감사합니다.
-
미해결파이썬 기초 라이브러리부터 쌓아가는 머신러닝
섹션 4-2 13:57 보라색, 연두색 선?
안녕하십니까 교수님.만들어 주신 영상 덕분에 잘 학습하고 있습니다.감사합니다.아래 왼쪽 그림을 보면 보라색, 연두색 선이 있는데 저 선들이 왜 저런 위치에 그려져 있는지에 대한 이유랑 어떤 영향을 미치는지 잘 모르겠습니다.
-
미해결파이썬(Python)으로 데이터 기반 주식 퀀트 투자하기 Part1
강의 5.9 질문있습니다.
df['date'] = pd.to_datetime(df['date']) df['price'] = df['price'].astype(float) df.set_index('date', inplace=True) df = df.loc["2017-12-31"] # 비록 DatetimeIndex이지만, 날짜를 문자열 string으로 표현하여 loc을 이용한 range indexing이 가능합니다. df.rename(columns={'title_x':'name', 'title_y':'title'}, inplace=True) df['price_grp'] = pd.cut(df['price'], [0, 5000, 15000, 200000], labels=["저가", "중가", "고가"])7:51 분경의 강의 내용에서 이 코드가 에러가 발생하는데 어떻게 해결해야 하는지 알수 있을까요?4 df.set_index('date', inplace=True)이 부분에서 에러가 발생하는 것으로 보입니다.
-
미해결[리뉴얼] 처음하는 파이썬 머신러닝 부트캠프 (쉽게! 실제 캐글 문제 풀며 정리하기) [데이터분석/과학 Part2]
하이퍼 파라미터 튜닝 기법 적용하기 실행값이 미묘하게 달라요.
사소하긴 한데, 궁금해서 질문 남겨요.위의 코드를 실행하면 svc 실습 동영상에 나온 값과 약간의 차이가 있어서요. 컴퓨터 성능에 따라서 값의 차이가 미묘하게 다를 수 있나요? 통계패키지도 가끔 돌릴때마다 값이 미묘하게 달라지기는 한데, 그 이유를 조금 구체적으로 알고 싶어서요. 참고로 저는 m1 chip mac을 사용중입니다.
-
미해결공공데이터로 파이썬 데이터 분석 시작하기
안녕하세요 질문있습니다!
안녕하세요! 아래처럼 에러가뜨고 표가 보이지가 않아요 ㅠㅠ다운로드 받은 파일을 열어보면 아래처럼 알수없는 문자가 나오는데 그것 때문일까요?? 어떻게 해결해야 하나요??답변 부탁드립니다!
-
해결됨[퇴근후딴짓] 빅데이터 분석기사 실기 (작업형1,2,3)
LabelEncoder를 실행하면 'ValueError: y should be a 1d array, got an array of shape (1818, 10) instead.라는 error가 발생합니다.
안녕하세요? 아래와 같이 LabelEncoder를 실행하면 'ValueError: y should be a 1d array, got an array of shape (1818, 10) instead.라는 error가 발생합니다. '왜 그럴까요? df2라는 데이터프레임에서 object인 column만 선택해서 똑같이 했습니다. 어떻게 해야 하는지 알려주시면 대단히 감사하겠습니다. from sklearn.preprocessing import LabelEncodercols=['Gender', 'family_history_with_overweight', 'FAVC', 'CAEC', 'SMOKE', 'SCC', 'CALC', 'MTRANS', 'NObeyesdad', 'transportation'] le=LabelEncoder()for col in [cols]: df2[col]=le.fit_transform(df2[col])