Đây là cách tiếp cận tốt nhất cho hầu hết người dùng. Nó sẽ cung cấp một phiên bản ổn định và các gói dựng sẵn có sẵn cho hầu hết các nền tảng
Cài đặt phiên bản scikit-learning do bạn cung cấp. Đây là một tùy chọn nhanh chóng cho những người có hệ điều hành hoặc bản phân phối Python phân phối scikit-learning. Nó có thể không cung cấp phiên bản phát hành mới nhất
Điều này là tốt nhất cho những người dùng muốn có các tính năng mới nhất và tuyệt vời nhất và không ngại chạy mã hoàn toàn mới. Điều này cũng cần thiết cho những người dùng muốn đóng góp cho dự án
Cài đặt bản phát hành mới nhất
Hệ điều hành Windows macOS Linux
Trình đóng gói pip conda
Cài đặt phiên bản 64 bit của Python 3, ví dụ từ https. //www. con trăn. tổ chức. Cài đặt Python 3 bằng cách sử dụng homebrew [
0] hoặc bằng cách cài đặt thủ công gói từ https. //www. con trăn. tổ chức. Cài đặt python3 và python3-pip bằng trình quản lý gói của Bản phân phối Linux. Cài đặt conda bằng trình cài đặt Anaconda hoặc miniconda hoặc trình cài đặt [không yêu cầu quyền quản trị viên đối với bất kỳ trình cài đặt nào trong số đó]. python3 -m pip show scikit-learn # to see which version and where scikit-learn is installedpython3 -m pip freeze # to see all packages installed in the active virtualenvpython3 -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"conda list scikit-learn # to see which scikit-learn version is installedconda list # to see all packages installed in the active conda environmentpython -c "import sklearn; sklearn.show_versions[]"
Sau đó chạy
python3 -m venv sklearn-venvpython -m venv sklearn-venvpython -m venv sklearn-venvsource sklearn-venv/bin/activatesource sklearn-venv/bin/activatesklearn-venv\Scripts\activatepip install -U scikit-learnpip install -U scikit-learnpip install -U scikit-learnpip3 install -U scikit-learnconda create -n sklearn-env -c conda-forge scikit-learnconda activate sklearn-env
Để kiểm tra cài đặt của bạn, bạn có thể sử dụng
python3 -m pip show scikit-learn # to see which version and where scikit-learn is installedpython3 -m pip freeze # to see all packages installed in the active virtualenvpython3 -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"conda list scikit-learn # to see which scikit-learn version is installedconda list # to see all packages installed in the active conda environmentpython -c "import sklearn; sklearn.show_versions[]"
Lưu ý rằng để tránh xung đột tiềm ẩn với các gói khác, bạn nên sử dụng môi trường ảo [venv] hoặc môi trường conda
Sử dụng một môi trường biệt lập như vậy giúp có thể cài đặt một phiên bản scikit-learning cụ thể với pip hoặc conda và các phần phụ thuộc của nó một cách độc lập với bất kỳ gói Python nào đã cài đặt trước đó. Đặc biệt trong Linux, không khuyến khích cài đặt các gói pip cùng với các gói được quản lý bởi trình quản lý gói của bản phân phối [apt, dnf, pacman…]
Lưu ý rằng bạn phải luôn nhớ kích hoạt môi trường bạn chọn trước khi chạy bất kỳ lệnh Python nào bất cứ khi nào bạn bắt đầu phiên cuối mới
Nếu bạn chưa cài đặt NumPy hoặc SciPy, bạn cũng có thể cài đặt chúng bằng cách sử dụng conda hoặc pip. Khi sử dụng pip, vui lòng đảm bảo rằng bánh xe nhị phân được sử dụng và NumPy và SciPy không được biên dịch lại từ nguồn, điều này có thể xảy ra khi sử dụng các cấu hình cụ thể của hệ điều hành và phần cứng [chẳng hạn như Linux trên Raspberry Pi]
Khả năng vẽ đồ thị Scikit-learning [i. e. , các hàm bắt đầu bằng “plot_” và các lớp kết thúc bằng “Display”] yêu cầu Matplotlib. Các ví dụ yêu cầu Matplotlib và một số ví dụ yêu cầu scikit-image, pandas hoặc seaborn. Phiên bản tối thiểu của các phụ thuộc Scikit-learning được liệt kê bên dưới cùng với mục đích của nó
phụ thuộc
Phiên bản tối thiểu
Mục đích
cục mịch
1. 17. 3
xây dựng, cài đặt
scipy
1. 3. 2
xây dựng, cài đặt
việc làm
1. 1. 1
Tải về
threadpoolctl
2. 0. 0
Tải về
con trăn
0. 29. 24
xây dựng
matplotlib
3. 1. 3
điểm chuẩn, tài liệu, ví dụ, bài kiểm tra
hình ảnh scikit
0. 16. 2
tài liệu, ví dụ, bài kiểm tra
gấu trúc
1. 0. 5
điểm chuẩn, tài liệu, ví dụ, bài kiểm tra
sinh ra biển
0. 9. 0
tài liệu, ví dụ
memory_profiler
0. 57. 0
điểm chuẩn, tài liệu
người khó tính
5. 3. 1
kiểm tra
pytest-cov
2. 9. 0
kiểm tra
vảy8
3. 8. 2
kiểm tra
màu đen
22. 3. 0
kiểm tra
mypy
0. 961
kiểm tra
pyamg
4. 0. 0
kiểm tra
nhân sư
4. 0. 1
tài liệu
sphinx-gallery
0. 7. 0
tài liệu
numpydoc
1. 2. 0
tài liệu, bài kiểm tra
Cái gối
7. 1. 2
tài liệu
con chó
1. 6. 0
tài liệu, ví dụ, bài kiểm tra
nhân sư-nhắc nhở
1. 3. 0
tài liệu
sphinxext-opengraph
0. 4. 2
tài liệu
âm mưu
5. 10. 0
tài liệu, ví dụ
conda-lock
1. 3. 0
bảo trì
Cảnh báo
Scikit-học 0. 20 là phiên bản cuối cùng hỗ trợ Python 2. 7 và Trăn 3. 4. Scikit-học 0. 21 Python 3 được hỗ trợ. 5-3. 7. Scikit-học 0. 22 Python 3 được hỗ trợ. 5-3. 8. Scikit-học 0. 23 - 0. 24 yêu cầu Python 3. 6 hoặc mới hơn. Scikit-học 1. 0 được hỗ trợ Python 3. 7-3. 10. Scikit-học 1. 1 trở lên yêu cầu Python 3. 8 hoặc mới hơn
Ghi chú
Để cài đặt trên PyPy, PyPy3-v5. 10+, Numpy 1. 14. 0+ và scipy 1. 1. 0+ được yêu cầu
Cài đặt trên phần cứng Apple Silicon M1
Nền tảng
python3 -m pip show scikit-learn # to see which version and where scikit-learn is installedpython3 -m pip freeze # to see all packages installed in the active virtualenvpython3 -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"conda list scikit-learn # to see which scikit-learn version is installedconda list # to see all packages installed in the active conda environmentpython -c "import sklearn; sklearn.show_versions[]"
1 được giới thiệu gần đây [đôi khi còn được gọi là python3 -m pip show scikit-learn # to see which version and where scikit-learn is installedpython3 -m pip freeze # to see all packages installed in the active virtualenvpython3 -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"conda list scikit-learn # to see which scikit-learn version is installedconda list # to see all packages installed in the active conda environmentpython -c "import sklearn; sklearn.show_versions[]"
2] yêu cầu cộng đồng nguồn mở nâng cấp cấu hình bản dựng và tự động hóa để hỗ trợ đúng cáchTại thời điểm viết bài [tháng 1 năm 2021], cách duy nhất để cài đặt scikit-learning hoạt động trên phần cứng này là cài đặt scikit-learning và các phần phụ thuộc của nó từ bản phân phối conda-forge, chẳng hạn như sử dụng trình cài đặt miniforge
https. //github. com/conda-forge/miniforge
Sự cố sau đây theo dõi tiến trình giúp cài đặt scikit-learning từ PyPI bằng pip
https. //github. com/scikit-learn/scikit-learn/issues/19137
Phân phối bên thứ ba của scikit-learning
Một số bản phân phối của bên thứ ba cung cấp các phiên bản scikit-learning được tích hợp với hệ thống quản lý gói của họ
Những thứ này có thể giúp người dùng cài đặt và nâng cấp dễ dàng hơn nhiều vì tích hợp bao gồm khả năng tự động cài đặt các phụ thuộc [numpy, scipy] mà scikit-learning yêu cầu
Sau đây là danh sách không đầy đủ các bản phân phối hệ điều hành và python cung cấp phiên bản scikit-learning của riêng chúng
Alpine Linux
Gói của Alpine Linux được cung cấp thông qua các kho lưu trữ chính thức dưới dạng
python3 -m pip show scikit-learn # to see which version and where scikit-learn is installedpython3 -m pip freeze # to see all packages installed in the active virtualenvpython3 -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"conda list scikit-learn # to see which scikit-learn version is installedconda list # to see all packages installed in the active conda environmentpython -c "import sklearn; sklearn.show_versions[]"
3 cho Python. Nó có thể được cài đặt bằng cách gõ lệnh sausudo apk add py3-scikit-learn
Vòm Linux
Gói của Arch Linux được cung cấp thông qua các kho lưu trữ chính thức dưới dạng
python3 -m pip show scikit-learn # to see which version and where scikit-learn is installedpython3 -m pip freeze # to see all packages installed in the active virtualenvpython3 -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"conda list scikit-learn # to see which scikit-learn version is installedconda list # to see all packages installed in the active conda environmentpython -c "import sklearn; sklearn.show_versions[]"
4 cho Python. Nó có thể được cài đặt bằng cách gõ lệnh sau________số 8_______
Debian/Ubuntu
Gói Debian/Ubuntu được chia thành ba gói khác nhau có tên là
python3 -m pip show scikit-learn # to see which version and where scikit-learn is installedpython3 -m pip freeze # to see all packages installed in the active virtualenvpython3 -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"conda list scikit-learn # to see which scikit-learn version is installedconda list # to see all packages installed in the active conda environmentpython -c "import sklearn; sklearn.show_versions[]"
5 [mô-đun python], python3 -m pip show scikit-learn # to see which version and where scikit-learn is installedpython3 -m pip freeze # to see all packages installed in the active virtualenvpython3 -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"conda list scikit-learn # to see which scikit-learn version is installedconda list # to see all packages installed in the active conda environmentpython -c "import sklearn; sklearn.show_versions[]"
6 [triển khai và ràng buộc cấp thấp], python3 -m pip show scikit-learn # to see which version and where scikit-learn is installedpython3 -m pip freeze # to see all packages installed in the active virtualenvpython3 -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"conda list scikit-learn # to see which scikit-learn version is installedconda list # to see all packages installed in the active conda environmentpython -c "import sklearn; sklearn.show_versions[]"
7 [tài liệu]. Chỉ có phiên bản Python 3 trong Debian Buster [bản phân phối Debian mới hơn]. Các gói có thể được cài đặt bằng cách sử dụng python3 -m pip show scikit-learn # to see which version and where scikit-learn is installedpython3 -m pip freeze # to see all packages installed in the active virtualenvpython3 -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"conda list scikit-learn # to see which scikit-learn version is installedconda list # to see all packages installed in the active conda environmentpython -c "import sklearn; sklearn.show_versions[]"
8sudo apt-get install python3-sklearn python3-sklearn-lib python3-sklearn-doc
Fedora
Gói Fedora được gọi là
python3 -m pip show scikit-learn # to see which version and where scikit-learn is installedpython3 -m pip freeze # to see all packages installed in the active virtualenvpython3 -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"python -m pip show scikit-learn # to see which version and where scikit-learn is installedpython -m pip freeze # to see all packages installed in the active virtualenvpython -c "import sklearn; sklearn.show_versions[]"conda list scikit-learn # to see which scikit-learn version is installedconda list # to see all packages installed in the active conda environmentpython -c "import sklearn; sklearn.show_versions[]"
9 cho phiên bản python 3, gói duy nhất có sẵn trong Fedora30. Nó có thể được cài đặt bằng cách sử dụng sudo apk add py3-scikit-learn
0sudo dnf install python3-scikit-learn
NetBSD
scikit-learning có sẵn thông qua pkgsrc-wip
https. //pkgsrc. se/math/py-scikit-learning
MacPorts cho Mac OSX
Gói MacPorts được đặt tên là
sudo apk add py3-scikit-learn
1, trong đó sudo apk add py3-scikit-learn
2 biểu thị phiên bản Python. Nó có thể được cài đặt bằng cách gõ lệnh sausudo port install py39-scikit-learn
Anaconda và Enthought Deployment Manager cho tất cả các nền tảng được hỗ trợ
Anaconda và Enthought Deployment Manager đều đi kèm với scikit-learning cùng với một bộ lớn thư viện khoa học python dành cho Windows, Mac OSX và Linux
Anaconda cung cấp scikit-learning như một phần của phân phối miễn phí
kênh conda của Intel
Intel duy trì một kênh conda chuyên dụng vận chuyển scikit-learning
conda install -c intel scikit-learn
Phiên bản scikit-learning này đi kèm với các bộ giải thay thế cho một số công cụ ước tính phổ biến. Những bộ giải đó đến từ thư viện DAAL C++ và được tối ưu hóa cho CPU Intel đa lõi
Lưu ý rằng những bộ giải đó không được bật theo mặc định, vui lòng tham khảo tài liệu daal4py để biết thêm chi tiết
Khả năng tương thích với bộ giải scikit-learning tiêu chuẩn được kiểm tra bằng cách chạy bộ kiểm tra scikit-learning đầy đủ thông qua tích hợp liên tục tự động như đã báo cáo trên https. //github. com/IntelPython/daal4py
WinPython cho Windows
Dự án WinPython phân phối scikit-learning dưới dạng plugin bổ sung
Xử lý sự cố
Lỗi do giới hạn độ dài đường dẫn tệp trên Windows
Có thể xảy ra trường hợp pip không thể cài đặt các gói khi đạt đến giới hạn kích thước đường dẫn mặc định của Windows nếu Python được cài đặt ở một vị trí lồng nhau, chẳng hạn như cấu trúc thư mục
sudo apk add py3-scikit-learn
3 trong thư mục chính của người dùng chẳng hạn