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



 


相关文章
|
3月前
|
存储 人工智能 测试技术
如何使用LangChain的Python库结合DeepSeek进行多轮次对话?
本文介绍如何使用LangChain结合DeepSeek实现多轮对话,测开人员可借此自动生成测试用例,提升自动化测试效率。
457 125
如何使用LangChain的Python库结合DeepSeek进行多轮次对话?
|
3月前
|
监控 数据可视化 数据挖掘
Python Rich库使用指南:打造更美观的命令行应用
Rich库是Python的终端美化利器,支持彩色文本、智能表格、动态进度条和语法高亮,大幅提升命令行应用的可视化效果与用户体验。
219 0
|
2月前
|
数据可视化 关系型数据库 MySQL
【可视化大屏】全流程讲解用python的pyecharts库实现拖拽可视化大屏的背后原理,简单粗暴!
本文详解基于Python的电影TOP250数据可视化大屏开发全流程,涵盖爬虫、数据存储、分析及可视化。使用requests+BeautifulSoup爬取数据,pandas存入MySQL,pyecharts实现柱状图、饼图、词云图、散点图等多种图表,并通过Page组件拖拽布局组合成大屏,支持多种主题切换,附完整源码与视频讲解。
232 4
【可视化大屏】全流程讲解用python的pyecharts库实现拖拽可视化大屏的背后原理,简单粗暴!
|
2月前
|
传感器 运维 前端开发
Python离群值检测实战:使用distfit库实现基于分布拟合的异常检测
本文解析异常(anomaly)与新颖性(novelty)检测的本质差异,结合distfit库演示基于概率密度拟合的单变量无监督异常检测方法,涵盖全局、上下文与集体离群值识别,助力构建高可解释性模型。
306 10
Python离群值检测实战:使用distfit库实现基于分布拟合的异常检测
|
3月前
|
人工智能 数据安全/隐私保护 异构计算
桌面版exe安装和Python命令行安装2种方法详细讲解图片去水印AI源码私有化部署Lama-Cleaner安装使用方法-优雅草卓伊凡
桌面版exe安装和Python命令行安装2种方法详细讲解图片去水印AI源码私有化部署Lama-Cleaner安装使用方法-优雅草卓伊凡
400 8
桌面版exe安装和Python命令行安装2种方法详细讲解图片去水印AI源码私有化部署Lama-Cleaner安装使用方法-优雅草卓伊凡
|
3月前
|
数据采集 机器学习/深度学习 人工智能
Python:现代编程的首选语言
Python:现代编程的首选语言
289 102
|
3月前
|
数据采集 机器学习/深度学习 算法框架/工具
Python:现代编程的瑞士军刀
Python:现代编程的瑞士军刀
314 104
|
3月前
|
人工智能 自然语言处理 算法框架/工具
Python:现代编程的首选语言
Python:现代编程的首选语言
260 103
|
3月前
|
机器学习/深度学习 人工智能 数据挖掘
Python:现代编程的首选语言
Python:现代编程的首选语言
193 82

推荐镜像

更多