Machine Learning之Python篇(二)
文章目錄
- NumPy
- einsum
- pad
- Super Pandas
- Autograd
- Bokeh
- Chartify
- Plotly
- Yellowbrick
- mlpy
- PyFlux
- JAX
- ImagePy
- imgaug
NumPy
einsum
在實現(xiàn)一些算法時,數(shù)學(xué)表達(dá)式已經(jīng)求出來了,需要將之轉(zhuǎn)換為代碼實現(xiàn),簡單的一些還好,有時碰到例如矩陣轉(zhuǎn)置、矩陣乘法、求跡、張量乘法、數(shù)組求和等等,若是以分別以transopse、sum、trace、tensordot等函數(shù)實現(xiàn)的話,不但復(fù)雜,還容易出錯
現(xiàn)在,這些問題你統(tǒng)統(tǒng)可以一個函數(shù)搞定,沒錯,就是einsum。
einsum全稱Einstein summation convention,是愛因斯坦1916年提出的一種標(biāo)記約定。
示例:
cik=aijbjk=∑jaijbjkc_{ik}=a_{ij}b_{jk}=\sum_ja_{ij}b_{jk}cik?=aij?bjk?=j∑?aij?bjk?
c = np.einsum('ij,jk->ik', a, b)
參考:
https://zhuanlan.zhihu.com/p/71639781
一個函數(shù)打天下,einsum
pad
arr1D = np.array([1, 1, 2, 2, 3, 4])
constant: [0 0 1 1 2 2 3 4 0 0 0] edge: [1 1 1 1 2 2 3 4 4 4 4] linear_ramp: [0 0 1 1 2 2 3 4 3 1 0] maximum: [4 4 1 1 2 2 3 4 4 4 4] mean: [2 2 1 1 2 2 3 4 2 2 2] median: [2 2 1 1 2 2 3 4 2 2 2] minimum: [1 1 1 1 2 2 3 4 1 1 1] reflect: [2 1 1 1 2 2 3 4 3 2 2] symmetric: [1 1 1 1 2 2 3 4 4 3 2] wrap: [3 4 1 1 2 2 3 4 1 1 2]Super Pandas
https://mp.weixin.qq.com/s/2-Ayzmzo8tydDLoKpz1Ezw
如何用一行代碼在多CPU環(huán)境下高效并行Pandas(pandarallel)
https://mp.weixin.qq.com/s/XIQ5EpQcYLxmRBuaTCZFzg
一行代碼,Pandas秒變分布式,快速處理TB級數(shù)據(jù)(Pandas on Ray)
https://mp.weixin.qq.com/s/Jkx1K7d1ufD2S6s2cOA7Hw
如何只用一行代碼讓Pandas加速四倍?(Modin)
https://mp.weixin.qq.com/s/UJ7P6nrBijidW3U2ApMGEQ
Vaex:突破pandas,快速分析100GB大數(shù)據(jù)集
https://mp.weixin.qq.com/s/CurxDz9DcJhyj-kbnuhXJA
0.052秒打開100GB數(shù)據(jù),這個Python開源庫火爆了!
https://mp.weixin.qq.com/s/iBCYfvSJeRyKLmnKgwnTRg
有比Pandas更好的替代嗎?對比Vaex, Dask, PySpark, Modin和Julia
Autograd
一個基于numpy的自動求導(dǎo)庫。它是由Harvard Intelligent Probabilistic Systems Group開發(fā)的。
官網(wǎng):
https://github.com/HIPS/autograd
Bokeh
Bokeh是一個數(shù)據(jù)可視化的庫。它不僅提供了和Matplotlib類似的靜態(tài)圖功能,還提供了生成交互動態(tài)圖的功能。
官網(wǎng):
http://bokeh.pydata.org/en/latest/
參考:
https://mp.weixin.qq.com/s/R6NclZO1MqjScRlLJ6Vefw
Python地圖可視化三大秘密武器(bokeh、basemap、geopandas)
https://mp.weixin.qq.com/s/XKjo5Dj7bpIlBtxkbozekA
掌握這幾點,輕松玩轉(zhuǎn)Bokeh可視化
Chartify
Chartify在Bokeh的基礎(chǔ)上又封裝了一層,提供了更友好的API。
官網(wǎng):
https://github.com/spotify/chartify
Plotly
Plotly也是Matplotlib的威力加強(qiáng)版,主打交互式繪圖。
官網(wǎng):
https://plot.ly/python/
它還有一個高級封裝叫做Plotly Express。
官網(wǎng):
https://www.plotly.express/
參考:
https://www.jianshu.com/p/57bad75139ca
python plotly使用教程
https://mp.weixin.qq.com/s/RkuLhwj_to_B01RJDQsGcA
強(qiáng)烈推薦一款Python可視化神器!
https://mp.weixin.qq.com/s/9mwLGsXQkTaxIohPwgDyKw
使用Plotly創(chuàng)建帶有回歸趨勢線的時間序列可視化圖表
Yellowbrick
Yellowbrick是和Scikit-Learn配套的ML可視化庫。
官網(wǎng):
https://www.scikit-yb.org/en/latest/
mlpy
mlpy是一個開源的ML庫。只是它最近的一次更新,已經(jīng)是2012年的事情了。
官網(wǎng):
http://mlpy.sourceforge.net
PyFlux
PyFlux是Python中為處理時間序列問題而創(chuàng)建的開源庫。該庫有一系列極好的時間序列模型,包括但不限于ARIMA、GARCH和VAR模型。
官網(wǎng):
https://pyflux.readthedocs.io/en/latest/index.html
JAX
一款由谷歌團(tuán)隊打造(非官方發(fā)布),用于從純Python和Numpy機(jī)器學(xué)習(xí)程序中生成高性能加速器(accelerator)代碼,且特定于域的跟蹤JIT編譯器。
代碼:
https://github.com/google/jax
參考:
https://mp.weixin.qq.com/s/IMMdbF33ZHEz7N_XwgIhHA
試試谷歌這個新工具:說不定比TensorFlow還好用!
https://mp.weixin.qq.com/s/tZ3yWQ9–l9e81UqoUoWIQ
要替代TensorFlow?谷歌開源機(jī)器學(xué)習(xí)庫JAX
https://mp.weixin.qq.com/s/eaYwiV2LZNRwzPEeOA1XFg
新星JAX :雙挑TensorFlow和PyTorch!有望擔(dān)綱Google主要科學(xué)計算庫和神經(jīng)網(wǎng)絡(luò)庫
https://mp.weixin.qq.com/s/NhMbr_niHjSaqh2azuSaog
只知道TF和PyTorch還不夠,快來看看怎么從PyTorch轉(zhuǎn)向自動微分神器JAX
ImagePy
ImagePy是國人寫的一個圖像處理工具。
官網(wǎng):
https://github.com/Image-Py/imagepy
imgaug
imgaug是一個圖像數(shù)據(jù)增強(qiáng)方面的庫,可用于擴(kuò)充機(jī)器學(xué)習(xí)訓(xùn)練時所用的圖片數(shù)據(jù)集。
官網(wǎng):
https://imgaug.readthedocs.io/en/latest/
參考:
https://www.cnblogs.com/vincentcheng/p/9186540.html
Augmentor和imgaug——python圖像數(shù)據(jù)增強(qiáng)庫
總結(jié)
以上是生活随笔為你收集整理的Machine Learning之Python篇(二)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。