[Udacity] Machine Learning tools

1:quiz 1: matrix times vector 矩阵乘矢量

import numpy as np
x=[[],[],[],[]]
y=[]
x=np.array(x)
x.dot(y)

2:quiz 2:differentiate 函数求导

sudo pip install sympy
import sympy
In [2]: x=sympy.Symbol("x")
In [3]: y=sympy.Symbol("y")
In [4]: fx=sympy.exp(x)*x+5*x**2-10
In [5]: fx
Out[5]: 5*x**2 + x*exp(x) - 10
In [6]: sympy.diff(fx,x)
Out[6]: x*exp(x) + 10*x + exp(x)

3:quiz 3: count words 词频统计

import collections 
def count_words(ss,n):
    list_ss=ss.split()
    dict_ss=collections.defaultdict(int)
    for  i in list_ss:
        dict_ss[i]+=1
    tuple_ss=[]
    for key,value in dict_ss.items():
        tuple_ss.append((value,key))
    tuple_ss.sort()
    tuple_ss.reverse()
    return   tuple_ss[:n]


print (count_words("hello ab ab ab ac ad ad ac ac",3))

4:Quandl 一个开源的大数据资源站点

可以使用Quandl这个python包对这个站的数据进行读取r操作,学习大数据的必备站点
www.quandl.com

    原文作者:猫哥
    原文地址: https://segmentfault.com/a/1190000008443622
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞