Py之mglearn:python库之mglearn简介、安装、使用方法之详细攻略

简介: Py之mglearn:python库之mglearn简介、安装、使用方法之详细攻略

mglearn简介


     mglearn库,该库集成了sklearn和数据的许多操作方法,很便捷,获取对应数据。Helper functions for the book "Introduction to Machine Learning with Python"

GitHub:https://github.com/amueller/mglearn


1、英文解释


This repository holds the code for the forthcoming book "Introduction to Machine Learning with Python" by Andreas Muellerand Sarah Guido. You can find details about the book on the O'Reilly website.


The books requires the current stable version of scikit-learn, that is 0.20.0. Most of the book can also be used with previous versions of scikit-learn, though you need to adjust the import for everything from the model_selection module, mostly cross_val_score, train_test_split and GridSearchCV.


This repository provides the notebooks from which the book is created, together with the mglearn library of helper functions to create figures and datasets.


For the curious ones, the cover depicts a hellbender.


All datasets are included in the repository, with the exception of the aclImdb dataset, which you can download from the page of Andrew Maas. See the book for details.


If you get ImportError: No module named mglearn you can try to install mglearn into your python environment using the command pip install mglearn in your terminal or !pip install mglearn in Jupyter Notebook.




mglearn安装


pip install mglearn==0.1.6


image.png




mglearn使用方法


1、Helper functions for the book "Introduction to Machine Learning with Python"


This is the mglearn package used in the book, which you can also find in the accompanying repository


You don't need this repo, all the code is there:


https://github.com/amueller/introduction_to_ml_with_python

This repository is a stand-alone package in case you really feel like you want to install mglearn into your Python environment, for some reason or another. You can install it by running


pip install mglearn

in your terminal, or by running


!pip install mglearn

in Jupyter Notebook.


In particular, installing this package is a very easy way to add it to your Python search path. Or you can just check out the notebooks from the repository above, and add the path to the mglearn subfolder to your PYTHONPATH environment variable (or set it in your IDE).



2、Setup


To run the code, you need the packages numpy, scipy, scikit-learn, matplotlib, pandas and pillow. Some of the visualizations of decision trees and neural networks structures also require graphviz. The chapter on text processing also requirs nltk and spacy.


The easiest way to set up an environment is by installing Anaconda.


Installing packages with conda:


If you already have a Python environment set up, and you are using the conda package manager, you can get all packages by running


conda install numpy scipy scikit-learn matplotlib pandas pillow graphviz python-graphviz

For the chapter on text processing you also need to install nltk and spacy:


conda install nltk spacy

Installing packages with pip


If you already have a Python environment and are using pip to install packages, you need to run


pip install numpy scipy scikit-learn matplotlib pandas pillow graphviz

You also need to install the graphiz C-library, which is easiest using a package manager. If you are using OS X and homebrew, you can brew install graphviz. If you are on Ubuntu or debian, you can apt-get install graphviz. Installing graphviz on Windows can be tricky and using conda / anaconda is recommended. For the chapter on text processing you also need to install nltk and spacy:


pip install nltk spacy

Downloading English language model


For the text processing chapter, you need to download the English language model for spacy using


python -m spacy download en



 


相关文章
|
26天前
|
JSON Shell 数据格式
使用 pipx 安装并执行 Python 应用程序 (1)
使用 pipx 安装并执行 Python 应用程序 (1)
93 17
|
2月前
|
IDE 测试技术 项目管理
【新手必看】PyCharm2025 免费下载安装配置教程+Python环境搭建、图文并茂全副武装学起来才嗖嗖的快,绝对最详细!
PyCharm是由JetBrains开发的Python集成开发环境(IDE),专为Python开发者设计,支持Web开发、调试、语法高亮、项目管理、代码跳转、智能提示、自动完成、单元测试和版本控制等功能。它有专业版、教育版和社区版三个版本,其中社区版免费且适合个人和小型团队使用,包含基本的Python开发功能。安装PyCharm前需先安装Python解释器,并配置环境变量。通过简单的步骤即可在PyCharm中创建并运行Python项目,如输出“Hello World”。
405 13
【新手必看】PyCharm2025 免费下载安装配置教程+Python环境搭建、图文并茂全副武装学起来才嗖嗖的快,绝对最详细!
|
2月前
|
人工智能 Java Python
python安装、vscode安装、conda安装:一文搞定Python的开发环境(史上最全)
尼恩架构团队推出了一系列《LLM大模型学习圣经》PDF,旨在帮助读者深入理解并掌握大型语言模型(LLM)及其相关技术。该系列包括Python基础、Transformer架构、LangChain框架、RAG架构及LLM智能体等内容,覆盖从理论到实践的各个方面。此外,尼恩还提供了配套视频教程,计划于2025年5月前发布,助力更多人成为大模型应用架构师,冲击年薪百万目标。
|
2月前
|
Shell Linux iOS开发
使用 pipx 安装并执行 Python 应用程序 (1)
使用 pipx 安装并执行 Python 应用程序 (1)
94 0
使用 pipx 安装并执行 Python 应用程序 (1)
|
10月前
|
Linux 开发工具 C语言
30天python速成-第一天(python简介及下载安装)
30天python速成-第一天(python简介及下载安装)
|
10月前
|
Linux 开发者 iOS开发
|
开发框架 数据可视化 Java
Python Qt GUI设计简介、环境下载和安装(基础篇—1)
Python Qt GUI设计简介、环境下载和安装(基础篇—1)
Python Qt GUI设计简介、环境下载和安装(基础篇—1)
|
SQL Oracle 数据可视化
Indigo | Indigo(Python)简介、安装与入门
Indigo | Indigo(Python)简介、安装与入门
484 0
Indigo | Indigo(Python)简介、安装与入门
|
机器学习/深度学习 SQL 自然语言处理
Python:pmml格式文件的简介、安装、使用方法(利用python将机器学习模型转为Java常用的pmml格式文件)之详细攻略
Python:pmml格式文件的简介、安装、使用方法(利用python将机器学习模型转为Java常用的pmml格式文件)之详细攻略
|
JSON NoSQL 数据挖掘
Python之tushare:tushare库的简介、安装、使用方法之详细攻略
Python之tushare:tushare库的简介、安装、使用方法之详细攻略
Python之tushare:tushare库的简介、安装、使用方法之详细攻略

热门文章

最新文章