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


猫哥
305 声望44 粉丝

热衷于研究各类互联网技术,热爱学习,热爱生活!