机器学习 中的 Jupyter Notebook函数

首页 / 机器学习入门教程 / 机器学习 中的 Jupyter Notebook函数

Jupyter笔记本基本上为开发基于Python的数据科学应用程序提供了一个交互式计算环境。它们以前称为ipython笔记本。以下是Jupyter笔记本的一些功能,使其成为Python ML生态系统的最佳组件之一-

  • Jupyter笔记本可以逐步排列代码,图像,文本,输出等内容,从而逐步说明分析过程。

  • 它有助于数据科学家在开发分析过程时记录思想过程。

  • 一个人也可以将输出捕获为笔记本的一部分。

  • 借助jupyter笔记本,我们还可以与同行分享我们的工作。

安装与执行

如果您使用的是Anaconda发行版,则无需单独安装jupyter笔记本,因为它已经安装了。您只需要转到Anaconda Prompt并键入以下命令-

C:\>jupyter notebook

按Enter键后,它将在您计算机的 localhost:8888 中启动一个笔记本服务器。在以下屏幕截图中显示-

Installation

现在,单击"新建"options卡后,您将获得一个options列表。选择Python 3,它将带您进入新笔记本以开始使用它。您将在以下屏幕快照中瞥见它-

JupyterJupyter Notebook

另一方面,如果您使用的是标准Python发行版,则可以使用流行的python软件包安装程序 pip 安装jupyter notebook。

pip install jupyter

Jupyter Notebook中的单元格类型

以下是Jupyter笔记本中的三种单元格类型-

代码单元格-顾名思义,我们可以使用这些单元格来编写代码。编写代码/内容后,它将把它发送到与笔记本相关联的内核。

降价单元格-我们可以使用这些单元格来表示计算过程。它们可以包含文本,图像,Latex公式,HTML标签等内容。

原始单元格-写入其中的文本按原样显示。这些单元格基本上用于添加我们不希望通过jupyter notebook的自动转换机制转换的文本。

有关jupyter笔记本的详细研究,请转到链接 www.learnfk.com/article-jupyter

NumPy

它是另一个有用的组件,使Python成为数据科学最喜欢的语言之一。它基本上代表数值Python,由多维数组对象组成。通过使用NumPy,我们可以执行以下重要操作-

  • 对数组的数学和逻辑运算。
  • 傅立叶变换
  • 与线性代数相关的运算。

我们还可以看到NumPy替代了MatLab,因为NumPy通常与Scipy(科学Python)和Mat-plotlib(绘图库)一起使用。

安装与执行

如果使用的是Anaconda发行版,则无需单独安装NumPy,因为它已经安装了。您只需要在以下帮助下将包导入到您的Python脚本中-

import numpy as np

另一方面,如果您使用的是标准Python发行版,则可以使用流行的python软件包安装程序pip安装NumPy。

pip install NumPy

安装NumPy之后,您可以像上面一样将其导入到Python脚本中。

要对NumPy进行更详细的研究,可以转到链接 www.learnfk.com/article-numpy

大熊猫

It is another useful Python library that makes Python one of the favorite languages for Data Science. 大熊猫 is basically used for data manipulation, wrangling and analysis. It was developed by Wes McKinney in 2008. With the help of 大熊猫, in data processing we can accomplish the following five steps −

  • Load
  • Prepare
  • Manipulate
  • Model
  • Analyze

Data representation in 大熊猫

The entire representation of data in 大熊猫 is done with the help of following three data structures −

系列-基本上是带有轴标签的一维ndarray,这意味着它就像带有均质数据的简单数组。如,以下系列是整数1,5,10,15,24,25的集合。

1 5 10 15 24 25 28 36 40 89

数据框架-这是最有用的数据结构,用于熊猫中几乎所有类型的数据表示和处理。它基本上是一个二维数据结构,可以包含异构数据。通常,表格数据是通过使用数据帧表示的。如,下表显示了具有其姓名和工号,年龄和性别的学生数据。

名称 卷数 年龄 性别
Aarav 1 15 男性
Harshit 2 14 男性
卡尼卡 3 16 女性
玛雅克 4 15 男性

面板-这是一个包含异构数据的3维数据结构。用图形表示面板是非常困难的,但是可以将其说明为DataFrame的容器。

链接:https://www.learnfk.comhttps://www.learnfk.com/python-machine-learning/machine-learning-with-python-jupyter-notebook.html

来源:LearnFk无涯教程网

The following table gives us the dimension and description about above mentioned data structures used in 大熊猫 −

数据结构 维度 说明
系列 1-D 大小不变的一维均匀数据
DataFrames 2-D 表格形式的大小可变,异构数据
面板 3-D 大小可变数组,DataFrame的容器。

我们可以理解这些数据结构,因为高维数据结构是低维数据结构的容器。

安装与执行

If you are using Anaconda distribution, then no need to install 大熊猫 separately as it is already installed with it. You just need to import the package into your Python script with the help of following −

import pandas as pd

On the other hand, if you are using standard Python distribution then 大熊猫 can be installed using popular python package installer, pip.

pip install 大熊猫

After installing 大熊猫, you can import it into your Python script as did above.

Example

The following is an example of creating a series from ndarray by using 大熊猫 −

In [1]: import pandas as pd
In [2]: import numpy as np
In [3]: data=np.array(['g','a','u','r','a','v'])
In [4]: s=pd.Series(data)
In [5]: print (s)
0 g
1 a
2 u
3 r
4 a
5 v
dtype: object

For more detailed study of 大熊猫 you can go to the link www.learnfk.com/article-python_pandas.

Scikit学习

Another useful and most important python library for Data Science and machine learning in Python is Scikit学习. The following are some features of Scikit学习 that makes it so useful −

  • 它基于NumPy,SciPy和Matplotlib构建。

  • 这是一个开放源代码,可以在BSD许可下重复使用。

  • 每个人都可以使用它,并且可以在各种环境中重复使用。

  • 借助它可以实现涵盖机器学习主要领域的广泛机器学习算法,如分类,聚类,回归,降维,模型选择等。

安装与执行

If you are using Anaconda distribution, then no need to install Scikit学习 separately as it is already installed with it. You just need to use the package into your Python script. For example, with following line of script we are importing dataset of breast cancer patients from Scikit学习 −

from sklearn.datasets import load_breast_cancer

On the other hand, if you are using standard Python distribution and having NumPy and SciPy then Scikit学习 can be installed using popular python package installer, pip.

pip install -U scikit-learn

After installing Scikit学习, you can use it into your Python script as you have done above.

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

零基础学Python -〔尹会生〕

数据结构与算法之美 -〔王争〕

重学线性代数 -〔朱维刚〕

Go 语言项目开发实战 -〔孔令飞〕

说透5G -〔杨四昌〕

自动化测试高手课 -〔柳胜〕

React Native 新架构实战课 -〔蒋宏伟〕

人人都用得上的数字化思维课 -〔付晓岩〕

后端工程师的高阶面经 -〔邓明〕

好记忆不如烂笔头。留下您的足迹吧 :)