묻고 답해요
161만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
미해결[개정판] 파이썬 머신러닝 완벽 가이드
lightgbm 3.3.2가 설치되지 않습니다.
맥북m2 사용중입니다. venv환경에서 pip install lightgbm==3.3.2를 했지만 아래와 같은 오류가 나옵니다.3.3.2없이 가장 최신 버젼이 4.5.0은 아주 쉽게 잘 설치가 됩니다. 혹시 강의를 수강할 때 3.3.2가 꼭필요한가요? conda 환경으로 설치를 진행해도 3.3.2는 설치가 안되더라구요ㅠㅠ 구글링을 해서 하라는 것은 다 했는데 해결이 안나와서 문의 드립니다..==========================================pip install lightgbm==3.3.2Collecting lightgbm==3.3.2 Using cached lightgbm-3.3.2.tar.gz (1.5 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... doneCollecting wheel (from lightgbm==3.3.2) Using cached wheel-0.44.0-py3-none-any.whl.metadata (2.3 kB)Requirement already satisfied: numpy in ./study/lib/python3.9/site-packages (from lightgbm==3.3.2) (1.24.3)Requirement already satisfied: scipy in ./study/lib/python3.9/site-packages (from lightgbm==3.3.2) (1.13.1)Requirement already satisfied: scikit-learn!=0.22.0 in ./study/lib/python3.9/site-packages (from lightgbm==3.3.2) (1.0.2)Requirement already satisfied: joblib>=0.11 in ./study/lib/python3.9/site-packages (from scikit-learn!=0.22.0->lightgbm==3.3.2) (1.4.2)Requirement already satisfied: threadpoolctl>=2.0.0 in ./study/lib/python3.9/site-packages (from scikit-learn!=0.22.0->lightgbm==3.3.2) (3.5.0)Using cached wheel-0.44.0-py3-none-any.whl (67 kB)Building wheels for collected packages: lightgbm Building wheel for lightgbm (pyproject.toml) ... error error: subprocess-exited-with-error × Building wheel for lightgbm (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [83 lines of output] INFO:root:running bdist_wheel INFO:root:running build INFO:root:running build_py INFO:root:creating build/lib/lightgbm INFO:root:copying lightgbm/callback.py -> build/lib/lightgbm INFO:root:copying lightgbm/compat.py -> build/lib/lightgbm INFO:root:copying lightgbm/plotting.py -> build/lib/lightgbm INFO:root:copying lightgbm/__init__.py -> build/lib/lightgbm INFO:root:copying lightgbm/engine.py -> build/lib/lightgbm INFO:root:copying lightgbm/dask.py -> build/lib/lightgbm INFO:root:copying lightgbm/basic.py -> build/lib/lightgbm INFO:root:copying lightgbm/libpath.py -> build/lib/lightgbm INFO:root:copying lightgbm/sklearn.py -> build/lib/lightgbm INFO:root:running egg_info INFO:root:writing lightgbm.egg-info/PKG-INFO INFO:root:writing dependency_links to lightgbm.egg-info/dependency_links.txt INFO:root:writing requirements to lightgbm.egg-info/requires.txt INFO:root:writing top-level names to lightgbm.egg-info/top_level.txt INFO:root:reading manifest file 'lightgbm.egg-info/SOURCES.txt' INFO:root:reading manifest template 'MANIFEST.in' WARNING:root:no previously-included directories found matching 'build' WARNING:root:warning: no files found matching '*.so' under directory 'lightgbm' WARNING:root:warning: no files found matching '*.so' under directory 'compile' WARNING:root:warning: no files found matching '*.dll' under directory 'compile/Release' WARNING:root:warning: no files found matching '*.dll' under directory 'compile/windows/x64/DLL' WARNING:root:warning: no previously-included files matching '*.py[co]' found anywhere in distribution WARNING:root:warning: no previously-included files found matching 'compile/external_libs/compute/.git' INFO:root:adding license file 'LICENSE' INFO:root:writing manifest file 'lightgbm.egg-info/SOURCES.txt' INFO:root:copying lightgbm/VERSION.txt -> build/lib/lightgbm INFO:wheel:installing to build/bdist.macosx-10.9-universal2/wheel INFO:root:running install INFO:LightGBM:Starting to compile the library. INFO:LightGBM:Starting to compile with CMake. Traceback (most recent call last): File "<string>", line 95, in silent_call File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 373, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['cmake', '/private/var/folders/q_/cgds3zcd57z43n2hc_mfsklr0000gn/T/pip-install-_35mq2ue/lightgbm_4b238c34e6dd4d93979880ebb06cf41d/compile']' returned non-zero exit status 1. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/ike/py3-9/study/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module> main() File "/Users/ike/py3-9/study/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main json_out['return_val'] = hook(**hook_input['kwargs']) File "/Users/ike/py3-9/study/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 251, in build_wheel return buildbackend().build_wheel(wheel_directory, config_settings, File "/private/var/folders/q_/cgds3zcd57z43n2hc_mfsklr0000gn/T/pip-build-env-nmcdsyxm/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 421, in build_wheel return self._build_with_temp_dir( File "/private/var/folders/q_/cgds3zcd57z43n2hc_mfsklr0000gn/T/pip-build-env-nmcdsyxm/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 403, in buildwith_temp_dir self.run_setup() File "/private/var/folders/q_/cgds3zcd57z43n2hc_mfsklr0000gn/T/pip-build-env-nmcdsyxm/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 503, in run_setup super().run_setup(setup_script=setup_script) File "/private/var/folders/q_/cgds3zcd57z43n2hc_mfsklr0000gn/T/pip-build-env-nmcdsyxm/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 318, in run_setup exec(code, locals()) File "<string>", line 334, in <module> File "/private/var/folders/q_/cgds3zcd57z43n2hc_mfsklr0000gn/T/pip-build-env-nmcdsyxm/overlay/lib/python3.9/site-packages/setuptools/__init__.py", line 117, in setup return distutils.core.setup(**attrs) File "/private/var/folders/q_/cgds3zcd57z43n2hc_mfsklr0000gn/T/pip-build-env-nmcdsyxm/overlay/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 183, in setup return run_commands(dist) File "/private/var/folders/q_/cgds3zcd57z43n2hc_mfsklr0000gn/T/pip-build-env-nmcdsyxm/overlay/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 199, in run_commands dist.run_commands() File "/private/var/folders/q_/cgds3zcd57z43n2hc_mfsklr0000gn/T/pip-build-env-nmcdsyxm/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 954, in run_commands self.run_command(cmd) File "/private/var/folders/q_/cgds3zcd57z43n2hc_mfsklr0000gn/T/pip-build-env-nmcdsyxm/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 950, in run_command super().run_command(command) File "/private/var/folders/q_/cgds3zcd57z43n2hc_mfsklr0000gn/T/pip-build-env-nmcdsyxm/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 973, in run_command cmd_obj.run() File "/private/var/folders/q_/cgds3zcd57z43n2hc_mfsklr0000gn/T/pip-build-env-nmcdsyxm/overlay/lib/python3.9/site-packages/setuptools/_vendor/wheel/bdist_wheel.py", line 403, in run self.run_command("install") File "/private/var/folders/q_/cgds3zcd57z43n2hc_mfsklr0000gn/T/pip-build-env-nmcdsyxm/overlay/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command self.distribution.run_command(command) File "/private/var/folders/q_/cgds3zcd57z43n2hc_mfsklr0000gn/T/pip-build-env-nmcdsyxm/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 950, in run_command super().run_command(command) File "/private/var/folders/q_/cgds3zcd57z43n2hc_mfsklr0000gn/T/pip-build-env-nmcdsyxm/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 973, in run_command cmd_obj.run() File "<string>", line 248, in run File "<string>", line 198, in compile_cpp File "<string>", line 99, in silent_call Exception: Please install CMake and all required dependencies first The full version of error log was saved into /Users/ike/LightGBM_compilation.log [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for lightgbmFailed to build lightgbmERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (lightgbm)==========================================
-
미해결[개정판] 파이썬 머신러닝 완벽 가이드
XGBoost.fit() 파라미터 질문입니다.
안녕하세요. 강의 정말 잘 듣고 있습니다.다름이 아니라 XGBoost 실습 시에 사이킷런 wrapper XGBClassifier.fit()파라미터가 바뀐 것 같아서 건의 드립니다.공식 python API를 들어가보면 xgboost.XGBClassifier parameter에 early_stopping_rounds와 eval_metrics가 포함된 것 같습니다..fit()메소드가 아닌 xgb 객체에 들어가는 파라미터로 바뀐 것 같습니다.아마 버전이 바뀌면서 파라미터 위치도 바뀐 것 같습니다.이 부분은 소스코드가 수정되어야 할 것 같습니다.
-
미해결확률과 통계 기초
bernoulli RV의 합으로 Hypergeometric RV를 나타내는 과정 질문있습니다.
P(X_k = 1)= p = b / (b + r) 이라고 하셨는데,각각의 시행에서 독립적이 아니라 확률이 변하지 않나요?예를 들어, P(X_1 = 1) = b / (b + r)가 맞지만P(X_2 = 1)은 X_1의 결과에 따라 달라지지 않나요? X_1, X_2 ... 는 독립적이지 않은 베르누이 확률변수 아닌가 하는 의문이 들었습니다.
-
미해결[개정판] 파이썬 머신러닝 완벽 가이드
scikit learn 1.0.2 version 다운로드 진행 오류
안녕하세요! 항상 수고많으십니다.다름이 아니라 scikit learn 1.0.2 version을 다운로드 할때 아래의 오류가 발생하는데 해결법이 있을까요?감사합니다. (base) C:\Windows\system32>pip install scikit-learn==1.0.2Collecting scikit-learn==1.0.2 Using cached scikit-learn-1.0.2.tar.gz (6.7 MB) Installing build dependencies ... done Getting requirements to build wheel ... error error: subprocess-exited-with-error × Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> [33 lines of output] Traceback (most recent call last): File "C:\Users\Admin\anaconda3\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module> main() File "C:\Users\Admin\anaconda3\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main json_out['return_val'] = hook(**hook_input['kwargs']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Admin\anaconda3\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 112, in get_requires_for_build_wheel backend = buildbackend() ^^^^^^^^^^^^^^^^ File "C:\Users\Admin\anaconda3\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 77, in buildbackend obj = import_module(mod_path) ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Admin\anaconda3\Lib\importlib\__init__.py", line 90, in import_module return bootstrap.gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<frozen importlib._bootstrap>", line 1387, in gcdimport File "<frozen importlib._bootstrap>", line 1360, in findand_load File "<frozen importlib._bootstrap>", line 1310, in findand_load_unlocked File "<frozen importlib._bootstrap>", line 488, in callwith_frames_removed File "<frozen importlib._bootstrap>", line 1387, in gcdimport File "<frozen importlib._bootstrap>", line 1360, in findand_load File "<frozen importlib._bootstrap>", line 1331, in findand_load_unlocked File "<frozen importlib._bootstrap>", line 935, in loadunlocked File "<frozen importlib._bootstrap_external>", line 995, in exec_module File "<frozen importlib._bootstrap>", line 488, in callwith_frames_removed File "C:\Users\Admin\AppData\Local\Temp\pip-build-env-7t2zd14d\overlay\Lib\site-packages\setuptools\__init__.py", line 16, in <module> import setuptools.version File "C:\Users\Admin\AppData\Local\Temp\pip-build-env-7t2zd14d\overlay\Lib\site-packages\setuptools\version.py", line 1, in <module> import pkg_resources File "C:\Users\Admin\AppData\Local\Temp\pip-build-env-7t2zd14d\overlay\Lib\site-packages\pkg_resources\__init__.py", line 2172, in <module> register_finder(pkgutil.ImpImporter, find_on_path) ^^^^^^^^^^^^^^^^^^^ AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'? [end of output] note: This error originates from a subprocess, and is likely not a problem with pip.error: subprocess-exited-with-error× Getting requirements to build wheel did not run successfully.│ exit code: 1╰─> See above for output.note: This error originates from a subprocess, and is likely not a problem with pip.(base) C:\Windows\system32>
-
미해결[개정판] 파이썬 머신러닝 완벽 가이드
anconda 에서 LightGBM 3.3.2 이 Setup 후 OpenMP 라이브러리에 의존하는데, 해당 라이브러리가 MacOS에 설치되지 않았기 때문에 발생하는 문제
안녕하세요 강사님 강의 모두 결제해서 듣고 있는 13년차 직장인 겸 학생입니다. MAC OS 아나콘다 환경에서 현재 4.4.5가 기본으로 깔리는데 처음문제는 early_stopping_rounds=50 였습니다. 그래서 3.3.2로 버전을 맞춰서 import lightgbm 하는데 문제가 생겨서 몇시간동안 헤매대가 결국 해결책을 찾아서 공유합니다.1. . MacOS에서 OpenMP를 설치하고 LightGBM이 이를 참조할 수 있도록 설정해야 합니다.1. Homebrew 설치먼저 Homebrew가 설치되어 있는지 확인하세요. Homebrew는 Mac에서 패키지를 관리하는 도구입니다. Homebrew가 설치되지 않았다면, 아래 명령어로 설치할 수 있습니다/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 2. libomp 설치libomp는 OpenMP 라이브러리입니다. Homebrew를 통해 쉽게 설치할 수 있습니다. brew install libomp이 명령어는 libomp를 설치하여, LightGBM이 OpenMP에 접근할 수 있게 만듭니다.3. Anaconda 환경에서 환경 변수 설정설치된 libomp 경로를 Anaconda 환경에서 참조하도록 설정해야 합니다. ~/.bash_profile 또는 ~/.zshrc 파일에 다음을 추가하세요. export PATH="/usr/local/opt/libomp/bin:$PATH"export LDFLAGS="-L/usr/local/opt/libomp/lib"export CPPFLAGS="-I/usr/local/opt/libomp/include"**팁Homebrew를 통해 설치된 libomp의 경로를 확인하려면 다음 명령어를 터미널에 입력하세요:brew --prefix libomp그 후 터미널에서 다음 명령어를 실행해 환경 변수를 적용하세요: source ~/.bash_profile # 또는 ~/.zshrc 4. LightGBM 재설치pip uninstall lightgbmpip install lightgbm==3.3.2~ 끝 ~ 강사님 항상 업데이트 잘해주셔서 저도 도움이 되고자 올립니다.
-
미해결[개정판] 파이썬 머신러닝 완벽 가이드
graphviz 오류
안녕하세요 선생님구글에 graphviz 다운로드 후 pip install을 해야하나모르고 pip install 먼저하고 구글 다운로드 후 다시 pip install 하니 중복되서 프롬프트에서 graphviz가 중복됬다고 실행이 안됩니다 ㅠㅠ혹시 해결방법이 있을까요 ?
-
미해결[개정판] 파이썬 머신러닝 완벽 가이드
5.9 Regression실습-Bike Sharing Demand _nameError
안녕하세요.. 질문 자주 올리네요^^버전 numpy==1.22.5 pandas==1.3.4 다운그레이했어요..사이킷런 1.0.2 파이썬 3.9.18 입니다.
-
미해결[개정판] 파이썬 머신러닝 완벽 가이드
안녕하세요 교수님.. 로그 변환, 피처 인코딩, 모델 학습/예측/평가_ 에러메시지가 납니다.
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 강의 내용을 질문할 경우 몇분 몇초의 내용에 대한 것인지 반드시 기재 부탁드립니다. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요.
-
미해결[개정판] 파이썬 머신러닝 완벽 가이드
LinearRegression() 에러입니다^^
안녕하세요. 교수님 너무 좋은 강의 잘 듣고 있습니다.바쁘실텐데 바로바로 답변해주셔서 너무 감사드려요^^Bike Sharing Demend 예제소스 에러 질문이 있어서요..최근에 설치했는데.. 에러가 많이나서 사이킷런 1.0.2 파이썬 3.9.18으로 다운그레이했습니다. 넘파이는 몇버전으로 해야 할까요?아래는 에러내용입니다.[ 로그 변환, 피처 인코딩, 모델 학습/예측/평가 ] from sklearn.model_selection import train_test_split , GridSearchCV from sklearn.linear_model import LinearRegression , Ridge , Lasso y_target = bike_df['count'] X_features = bike_df.drop(['count'],axis=1,inplace=False) X_train, X_test, y_train, y_test = train_test_split(X_features, y_target, test_size=0.3, random_state=0) lr_reg = LinearRegression() lr_reg.fit(X_train, y_train) pred = lr_reg.predict(X_test) evaluate_regr(y_test ,pred)에러 --------------------------------------------------------------------------- DTypePromotionError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_19124\3974685920.py in <module> 11 lr_reg = LinearRegression() 12 ---> 13 lr_reg.fit(X_train, y_train) 14 pred = lr_reg.predict(X_test) 15 D:\dev03\anaconda\lib\site-packages\sklearn\linear_model\_base.py in fit(self, X, y, sample_weight) 660 accept_sparse = False if self.positive else ["csr", "csc", "coo"] 661 --> 662 X, y = self._validate_data( 663 X, y, accept_sparse=accept_sparse, y_numeric=True, multi_output=True 664 ) D:\dev03\anaconda\lib\site-packages\sklearn\base.py in _validate_data(self, X, y, reset, validate_separately, **check_params) 579 y = check_array(y, **check_y_params) 580 else: --> 581 X, y = check_X_y(X, y, **check_params) 582 out = X, y 583 D:\dev03\anaconda\lib\site-packages\sklearn\utils\validation.py in check_X_y(X, y, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, multi_output, ensure_min_samples, ensure_min_features, y_numeric, estimator) 962 raise ValueError("y cannot be None") 963 --> 964 X = check_array( 965 X, 966 accept_sparse=accept_sparse, D:\dev03\anaconda\lib\site-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) 663 664 if all(isinstance(dtype, np.dtype) for dtype in dtypes_orig): --> 665 dtype_orig = np.result_type(*dtypes_orig) 666 667 if dtype_numeric: DTypePromotionError: The DType <class 'numpy.dtypes.
-
미해결[개정판] 파이썬 머신러닝 완벽 가이드
LinearRegression() 에러
안녕하세요. 너무 좋은 강의 잘 듣고 있습니다.Bike Sharing Demend 예제소스 에러 질문이 있어서요..[ 로그 변환, 피처 인코딩, 모델 학습/예측/평가 ]from sklearn.model_selection import train_test_split , GridSearchCVfrom sklearn.linear_model import LinearRegression , Ridge , Lassoy_target = bike_df['count']X_features = bike_df.drop(['count'],axis=1,inplace=False)X_train, X_test, y_train, y_test = train_test_split(X_features, y_target, test_size=0.3, random_state=0)lr_reg = LinearRegression()lr_reg.fit(X_train, y_train)pred = lr_reg.predict(X_test)evaluate_regr(y_test ,pred)에러--------------------------------------------------------------------------- DTypePromotionError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_19124\3974685920.py in <module> 11 lr_reg = LinearRegression() 12 ---> 13 lr_reg.fit(X_train, y_train) 14 pred = lr_reg.predict(X_test) 15 D:\dev03\anaconda\lib\site-packages\sklearn\linear_model\_base.py in fit(self, X, y, sample_weight) 660 accept_sparse = False if self.positive else ["csr", "csc", "coo"] 661 --> 662 X, y = self._validate_data( 663 X, y, accept_sparse=accept_sparse, y_numeric=True, multi_output=True 664 ) D:\dev03\anaconda\lib\site-packages\sklearn\base.py in _validate_data(self, X, y, reset, validate_separately, **check_params) 579 y = check_array(y, **check_y_params) 580 else: --> 581 X, y = check_X_y(X, y, **check_params) 582 out = X, y 583 D:\dev03\anaconda\lib\site-packages\sklearn\utils\validation.py in check_X_y(X, y, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, multi_output, ensure_min_samples, ensure_min_features, y_numeric, estimator) 962 raise ValueError("y cannot be None") 963 --> 964 X = check_array( 965 X, 966 accept_sparse=accept_sparse, D:\dev03\anaconda\lib\site-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) 663 664 if all(isinstance(dtype, np.dtype) for dtype in dtypes_orig): --> 665 dtype_orig = np.result_type(*dtypes_orig) 666 667 if dtype_numeric: DTypePromotionError: The DType <class 'numpy.dtypes.
-
해결됨[개정판] 파이썬 머신러닝 완벽 가이드
안녕하세요(머린이 질문)
안녕하세요 선생님다름이 아니라, 머신러닝 수강중 궁금한게 있어 질문드립니다X1, X2 ,X3 ,X4 ~... Y가 있을 때 회귀예측을 진행한다고 하면만약 타겟 Y값 목표가 100이라고 가정 했을 때X1,X2,X3,X4들이 어느정도 값에 있는걸 추천한다 ? , 권장한다 ? 라는 분석기법도 있을까요 ? Q1) Y가 목표값이 있을 때, 각 X1~X4 범위 , 그에 따른 Y값의 신뢰구간 ㅠ 그냥 이 질문은 ML이 아니고 회귀분석 일까요 ??
-
미해결[개정판] 파이썬 머신러닝 완벽 가이드
안녕하세요. 9장 질문입니다. 아래와 같은 에러가 발생했어요..
소스코드:movies_df['genres_literal'] = movies_df['genres'].apply(lambda x : (' ').join(x))count_vect = CountVectorizer(min_df=0, ngram_range=(1,2))genre_mat = count_vect.fit_transform(movies_df['genres_literal'])print(genre_mat.shape)에러 코드:InvalidParameterError Traceback (most recent call last) Cell In[99], line 10 8 count_vect = CountVectorizer(min_df=0, ngram_range=(1,2)) 9 # print(movies_df['genres_literal']) ---> 10 genre_mat = count_vect.fit_transform(movies_df['genres_literal']) File D:\dev03\anaconda\Lib\site-packages\sklearn\base.py:1467, in _fit_context.<locals>.decorator.<locals>.wrapper(estimator, *args, **kwargs) 1462 partial_fit_and_fitted = ( 1463 fit_method.__name__ == "partial_fit" and _is_fitted(estimator) 1464 ) 1466 if not global_skip_validation and not partial_fit_and_fitted: -> 1467 estimator._validate_params() 1469 with config_context( 1470 skip_parameter_validation=( 1471 prefer_skip_nested_validation or global_skip_validation 1472 ) 1473 ): 1474 return fit_method(estimator, *args, **kwargs) File D:\dev03\anaconda\Lib\site-packages\sklearn\base.py:666, in BaseEstimator._validate_params(self) 658 def _validate_params(self): 659 """Validate types and values of constructor parameters 660 661 The expected type and values must be defined in the `_parameter_constraints` (...) 664 accepted constraints. 665 """ --> 666 validate_parameter_constraints( 667 self._parameter_constraints, 668 self.get_params(deep=False), 669 caller_name=self.__class__.__name__, 670 ) File D:\dev03\anaconda\Lib\site-packages\sklearn\utils\_param_validation.py:95, in validate_parameter_constraints(parameter_constraints, params, caller_name) 89 else: 90 constraints_str = ( 91 f"{', '.join([str(c) for c in constraints[:-1]])} or" 92 f" {constraints[-1]}" 93 ) ---> 95 raise InvalidParameterError( 96 f"The {param_name!r} parameter of {caller_name} must be" 97 f" {constraints_str}. Got {param_val!r} instead." 98 ) InvalidParameterError: The 'min_df' parameter of CountVectorizer must be a float in the range [0.0, 1.0] or an int in the range [1, inf). Got 0 instea
-
해결됨[개정판] 파이썬 머신러닝 완벽 가이드
머린이 (k-fold) 질문
안녕하세요 선생님 머린이 질문드립니다 ㅠk-fold 검증하는거에 대해 궁금한게 있습니다X_train, X_val, y_train, y_test = train_test_split(x,y,test_size= 0.3) 으로 햇을 때만약 100개 데이터가 있으면 30개 데이터를 가지고 질문1) fit -> x_train, y_train : 30개 데이터를 가지고훈련한다. )70개 데이터에 대해 pred : x_val 후 -> accuracy (y_val, pred) 맞춰본다(모의고사를 푼다)-> 이제 fit한 데이터를 가지고 실제 수능을 푼다 (real test data)가 맞을까요 ??질문2) 이게 맞다면 k-폴드 교차검증은 (k=5일떄)fit 활동 -> 30개 데이터 셋 fit을 5번 수행 실시 후70개의 pred : x_val 활동을 한다 가 맞을까요 ? '^',,
-
해결됨[개정판] 파이썬 머신러닝 완벽 가이드
머린이(머신러닝 어린이) 질문
안녕하세요 선생님 ㅎ ㅠ 강의중2.4 model selection 모듈소개에서 from sklearn.datasets import load_iris 내장된데이터셋을 불러온 후 head()랑 shape을 바로 파악하고싶은데예를들어 df = pd.read_csv("~~.csv")df.head() 하면 x1, x2 , x3, target (물론 본인이 x,y 파악) 데이터 셋을바로 파악할 수 있는데 내장 데이터는iris_df = pd.DataFrame(iris_data.data, columns=iris_data.feature_names)iris_df['target']=iris_data.target이런 작업이 필요한걸까요 ㅠㅠ?..
-
해결됨통계 분석 마스터 클래스
다중 선형회귀 분석 등
안녕하세요 해당 관련 강의를 듣고 있는 수강생입니다.수업을 듣고 있는 중에.. 엑셀로 회귀 분석을 진행하는데매크로를 사용해서 진행하는 것만 나오네요?각각의 분석값을 어떻게 계산하는지는 설명이 없는 거 같아서요.. 예를 들면 2차회귀에서의 결정계수, 상관계수, P값(분산분석)아니면 중회귀에서의 P값 등... 구하는 공식 등을 그냥 엑셀에서의 매크로를 통해 보여주기만 하네요.. 혹 이런 값들의 계산식들을 알 수가 있을까요?
-
미해결[개정판] 파이썬 머신러닝 완벽 가이드
색션2 강의 재생 문제
안녕하세요. 섹션2 강의 재생이 안됩니다. 섹션1 강의는 제대로 재생되어 테스트도 해보았는데 섹션2 강의가 재생이 안되네요. 확인 부탁드려요
-
미해결[개정판] 파이썬 머신러닝 완벽 가이드
early_stopping_rounds,eval_metric 오류 관련 질문있습니다.
분류 강의 위스콘신 유방암 예측 실습강의 코드입니다.from xgboost import XGBClassifierxgb_wrapper = XGBClassifier(n_estimators=400, learning_rate=0.05, max_depth=3)evals = [(X_tr, y_tr), (X_val, y_val)]xgb_wrapper.fit(X_tr, y_tr, early_stopping_rounds=50, eval_metric="logloss", eval_set=evals, verbose=True)ws50_preds = xgb_wrapper.predict(X_test)ws50_pred_proba = xgb_wrapper.predict_proba(X_test)[:, 1] --------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[36], line 5 3 xgb_wrapper = XGBClassifier(n_estimators=400, learning_rate=0.05, max_depth=3) 4 evals = [(X_tr, y_tr), (X_val, y_val)] ----> 5 xgb_wrapper.fit(X_tr, y_tr, early_stopping_rounds=50, eval_metric="logloss", 6 eval_set=evals, verbose=True) 8 ws50_preds = xgb_wrapper.predict(X_test) 9 ws50_pred_proba = xgb_wrapper.predict_proba(X_test)[:, 1] File ~\anaconda3\Lib\site-packages\xgboost\core.py:726, in require_keyword_args.<locals>.throw_if.<locals>.inner_f(*args, **kwargs) 724 for k, arg in zip(sig.parameters, args): 725 kwargs[k] = arg --> 726 return func(**kwargs) TypeError: XGBClassifier.fit() got an unexpected keyword argument 'early_stopping_rounds'위 코드를 입력하였을때 이러한 오류가 뜨는데 무엇이 원인인지 잘모르겠습니다. Xgboost 버전은 2.1.0이고 파이썬버전같은경우는 3.1.1입니다. 아래는 인터넷에 검색하여 찾아낸 방법으로 입력한 코드입니다from xgboost import XGBClassifierxgb_wrapper=XGBClassifier(n_estimators=400,learning_rate=0.05,max_depth=3,early_stopping_rounds=50,eval_metric="logloss")evals=[(X_tr,y_tr),(X_val,y_val)]xgb_wrapper.fit(X_tr,y_tr, eval_set=evals,verbose=True)ws50_preds=xgb_wrapper.predict(X_test)ws50_pred_proba=xgb_wrapper.predict_proba(X_test)[:,1] 아래는 위 코드에 대한 결과값입니다.오차 행렬 [[35 2] [ 2 75]] 정확도: 0.9649, 정밀도: 0.9740, 재현율: 0.9740, F1: 0.9740, AUC:0.9961 아래는 책에 있는 코드를 입력하였을때의 결과값입니다.오차 행렬 [[35 3] [ 2 75]] 정확도: 0.9561, 정밀도: 0.9615, 재현율: 0.9740, F1: 0.9677, AUC:0.9933 제 생각에는 버전차이에 따른 문제같은데 수정된 코드를 사용하였을때 결과값은 도출되지만 기존 강의에서 사용하신 코드의 결과값과는 다릅니다. 수정된 코드를 그대로 사용하는게 맞을지 아니면 다른 방법이 있는지 궁금합니다.
-
미해결[개정판] 파이썬 머신러닝 완벽 가이드
GridSearchCV 관련 질문
grid_dtree = GridSearchCV(dtree, param_grid=parameters, cv=3, refit=True, return_train_score=True)grid_dtree.fit(X_train, y_train) 강의에서는 지금까지 정확도를 도출할때 이미 훈련 데이터로 학습된 모델을 통해 X_test 데이터의 예측값을 구하고 이를 실제 y_test 값과 비교하여 일치도를 구하는 방식으로 하였습니다. 하지만 위의 코드에서는 test 데이터 없이 train 데이터만 grid_dtree에 넣었는데 어떻게 파라미터별 정확도를 평가할 수 있는건지 이해가 안갑니다!! GridSearchCV를 통한 파라미터별 정확도는 어떻게 도출되는것인가요?
-
미해결[개정판] 파이썬 머신러닝 완벽 가이드
원-핫 인코딩 get_dummies()질문
안녕하세요 ! import pandas as pd df = pd.DataFrame({'item':['TV','냉장고','전자렌지','컴퓨터','선풍기','선풍기','믹서','믹서']}) pd.get_dummies(df) 이렇게 실행하니 0,1값대신 True/False값이 결과로 출력되는데 문제점이 뭔지 모르겠습니다 ㅜ실행결과 사진입니다.
-
미해결[개정판] 파이썬 머신러닝 완벽 가이드
섹션2 Grid Search 예제에서 Test data분리시 계층 적용 여부
섹션2의 Grid Search 예제에서 학습/테스트 데이터 분리시 train_test_split()함수에서 stratify옵션없이 사용되었는데요, 계층 분할을 위해 stratify=iris_data.target 옵션을 넣어야 하는거 아닌가요?stratify옵션 넣고 테스트해보니 학습데이터 score는 강의동영상의 점수보다 낮았는데, test data에 대한 스코어는 강의 동영상과 동일하게 나왔습니다.