Skip to Main Content
Python 机器学习实践:测试驱动的开发方法
book

Python 机器学习实践:测试驱动的开发方法

by Matthew Kirk
January 2018
Intermediate to advanced content levelIntermediate to advanced
211 pages
8h 31m
Chinese
China Machine Press
Content preview from Python 机器学习实践:测试驱动的开发方法
168
9
命名元组
Python
中的元组基本上都是不可变数组。元组运行速度很快,在移动数据时非
常有用。但是什么是命名元组呢?
命名元组可以视为轻量级对象,我们可以使用它而无须定义新的类。在其他语言
中可能被称为结构体。
例如,假如你想查看笛卡儿图上的一个点
x,y
。我们可以说那只是一个点
(x,y)
或者我们可以用一个命名元组:
Let’s go through the process of writing our own code and then use it to map the same
data that we have from our jazz data set, then see what happens.
Our first step is to be able to initialize the cluster. If you remember we need to have
indicator variables z
t
that follow a uniform distribution. These tell us the probability
that each data point is in each cluster.
Named Tuples
Tuples in Python are basically immutable arrays. They are fast, and useful when mov‐
ing data around. But what is ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Python for Bioinformatics

Mastering Python for Bioinformatics

Ken Youens-Clark

Publisher Resources

ISBN: 9787111581666