## 研究现状

Bagging (Leo Breiman， 1994，Technical Report No. 421.)

Boosting (Schapire, Robert E，1990 ，“The Strength of WeakLearnability”. Machine Learning (Boston, MA: Kluwer Academic Publishers)

AdaBoost (Yoav Freund and Robert Schapire，2003)

## 不容错过的Python小贴士—技巧, 风格和最佳实践

### 1. Dict的for循环中避免使用低效的iteritems() 和 keys()

In [1]:
a = {}
for i in xrange(0, 1000000):
a[i] = i
print(type(a))
print(len(a))
<type 'dict'>
1000000

In [2]:
def for_func1():
for x in a:
pass

def for_func2():
for x in a.keys():
pass

def for_func3():
for x,v in a.iteritems():
pass
In [3]:
import timeit
print(timeit.timeit(for_func1, number=100))
print(timeit.timeit(for_func2, number=100))
print(timeit.timeit(for_func3, number=100))
1.22459793091
2.30621099472
2.17837190628


### 2. for循环中获得index神器: enumerate

In [4]:
students = ('James', 'Andrew', 'Mark')
In [5]:
for i, student in enumerate(students):
print i, student
0 James
1 Andrew
2 Mark

In [6]:
students = {'James': 'male', 'Andrew':'male', 'Alice':'female'}
In [7]:
for i, student in enumerate(students):
print i, student
0 James
1 Andrew
2 Alice


### 3. 想确定for循环完整结束, 用else吧…

In [8]:
for ele in ['a', 'b', 'c']:
if ele == 'b':
break
else: # no break
print('for循环完整结束')
In [9]:
for ele in ['a', 'b', 'c']:
if ele == 'd':
break
else: # no break
print('for循环完整结束')
for循环完整结束


## Brief History of Machine Learning 机器学习简史

Since the initial standpoint of science, technology and AI, scientists following Blaise Pascal and Von Leibniz ponder about a machine that is intellectually capable as much as humans. Famous writers like Jules

Machine Learning is one of the important lanes of AI which is very spicy hot subject in the research or industry. Companies, universities devote many resources to advance their knowledge. Recent advances in the field propel very solid results for different tasks, comparable to human performance (98.98% at Traffic Signs – higher than human-).

Here I would like to share a crude timeline of Machine Learning and sign some of the milestones by no means complete. In addition, you should add “up to my knowledge” to beginning of any argument in the text.

First step toward prevalent ML was proposed by Hebb , in 1949, based on a neuropsychological learning formulation. It is called Hebbian Learning theory. With a simple explanation, it pursues correlations between nodes of a Recurrent Neural Network (RNN). It memorizes any commonalities on the network and serves like a memory later. Formally, the argument states that;

Let us assume that the persistence or repetition of a reverberatory activity (or “trace”) tends to induce lasting cellular changes that add to its stability.… When an  axon  of cell  A is near enough to excite a cell  B and repeatedly or persistently takes part in firing it, some growth process or metabolic change takes place in one or both cells such that  A’s efficiency, as one of the cells firing  B, is increased.[1]

In 1952 , Arthur Samuel at IBM, developed a program playing Checkers . The program was able to observe positions and learn a implicit model that gives better moves for the latter cases. Samuel played so many games with the program and observed that the program was able to play better in the course of time.

## [转] Ubuntu14.04LTS安装TensorFlow

1. Pip

$sudo apt-get install python-pip python-dev python-setuptools build-essential$ sudo pip install --upgrade pip $sudo pip install --upgrade virtualenv 为了检测是否安装好，可以查看pip的版本： $ pip --version
pip 8.1.2 from /usr/local/lib/python2.7/dist-packages (python 2.7)

2. Tensorflow

# Ubuntu/Linux 64-bit, CPU only:
\$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl

## 入门

$$P\left(\theta\middle|X_{train}\right) = \frac{P\left(X_{train}\middle|\theta\right)P\left( \theta\right)}{P\left(X_{train}\right)}$$

“频率学派”认为, 后验概率和先验概率都是不存在的, 模型 $$\theta$$ 不论简单复杂, 参数已经是上帝固定好了的, 只要根据大数定理, 当训练数据足够大, 我们就能找到那个最好的 $$\theta$$ . 于是公式变为:

$$P\left(X_{train}\right) = P\left(X_{train}\middle|\theta\right)$$

“贝叶斯学派”认为, 人类的知识是有限的, 我们不知道上帝的安排, 就先假设一个先验(我们已有的知识), 再根据训练数据或抽样数据, 去找到后验分布, 就能知道模型最可能是个什么样子. 继续阅读#2 大话机器学习中的贝叶斯 Bayesian

## 朴素贝叶斯：

1. 如果给出的特征向量长度可能不同，这是需要归一化为统一长度的向量（这里以文本分类为例），比如说是句子单词的话，则长度为整个词汇量的长度，对应位置是该单词出现的次数。

2. 计算公式如下：

3. 如果$$P\left(w\middle|c_i\right)$$中的某一项为0，则其联合概率的乘积也可能为0，即2中公式的分子为0，为了避免这种现象出现，一般情况下会将这一项初始化为1，当然为了保证概率相等，分母应对应初始化为2（这里因为是2类，所以加2，如果是k类就需要加k，术语上叫做laplace光滑, 分母加k的原因是使之满足全概率公式）。