WGET
提取數(shù)據(jù),特別是從網絡中提取數(shù)據(jù)是數(shù)據(jù)科學家的重要任務之一。Wget 是一個免費的工具,用于以非交互式方式從 Web 上下載文件。它支持 HTTP、HTTPS 和 FTP 協(xié)議,通過 HTTP 代理進行檢索。由于它是非交互式的,即使用戶沒有登錄,它也可以在后臺工作。所以,如果你想下載一個網站或一個頁面上的所有圖片,wget 會幫助你。
安裝:
$ pip install wget

示例:
import wget
url = 'http://www.futurecrew.com/skaven/song_files/mp3/razorback.mp3'
filename = wget.download(url)
100% [................................................] 3841532 / 3841532
filename
'razorback.mp3'

Pendulum
對于那些在 python 中被處理datetimes困擾的人來說,Pendulum 是個好選擇。它是一個 Python 包,用于簡化 datetimes 操作。它是 Python「本機」類(native class)的代替。更多內容,請參閱文檔:https://um.eustace.io/docs/# installation。
安裝:
$ pip install pendulum

示例:
import wget
url = 'http://www.futurecrew.com/skaven/song_files/mp3/razorback.mp3'
filename = wget.download(url)
100% [................................................] 3841532 / 3841532
filename
'razorback.mp3'

IMBALANCED-LEARN
可以看出,當每個類的樣本數(shù)量相等即平衡時,大多數(shù)分類算法的工作效果最好。但現(xiàn)實生活中充滿了不平衡的數(shù)據(jù)集,這些數(shù)據(jù)集對機器學習的學習階段和后續(xù)預測都有影響。創(chuàng)建這個庫是為了解決這個問題。它與 scikit-learn 兼容,并且是 scikit-learn-contrib 項目的一部分。下次遇到不平衡的數(shù)據(jù)集時,可以嘗試一下。
安裝:
pip install -U imbalanced-learn
# or
conda install -c conda-forge imbalanced-learn

示例:
有關用法和示例,請參考:http://imbalancedlearn.org/en/stable/api.html。
FLASHTEXT
在 NLP 任務中,清理文本數(shù)據(jù)通常需要替換句子中的關鍵詞或從句子中提取關鍵詞。通常,這樣的操作可以用正則表達式來完成,但是如果要搜索的詞匯量過大,操作就會變得麻煩。Python 中基于 FlashText 算法的 FlashText 模塊,為這種情況提供了一個合適的替代方案。FlashText 最大的優(yōu)點是搜索詞數(shù)量不影響運行時長。更多相關信息請見:https://flashtext.readthedocs.io/en/latest/#。
安裝:
$ pip install flashtext

示例
提取關鍵詞:
from flashtext import KeywordProcessor
keyword_processor = KeywordProcessor()
# keyword_processor.add_keyword(<unclean name>, <standardised name>)
keyword_processor.add_keyword('Big Apple', 'New York')
keyword_processor.add_keyword('Bay Area')
keywords_found = keyword_processor.extract_keywords('I love Big Apple and Bay Area.')
keywords_found
['New York', 'Bay Area']

替換關鍵詞:
keyword_processor.add_keyword('New Delhi', 'NCR region')
new_sentence = keyword_processor.replace_keywords('I love Big Apple and new delhi.')
new_sentence
'I love New York and NCR region.'

更多使用示例,請參閱官方文檔。
FUZZYWUZZY
雖然名字聽起來很奇怪,但涉及到字符串匹配時,fuzzywuzzy 是一個非常有用的庫,可以很容易地實現(xiàn)諸如字符串比較比率、token 比率等操作。對于匹配不同數(shù)據(jù)庫中的記錄也很方便。
安裝:
$ pip install fuzzywuzzy

示例:
from fuzzywuzzy import fuzz
from fuzzywuzzy import process
# Simple Ratio
fuzz.ratio("this is a test", "this is a test!")
97
# Partial Ratio
fuzz.partial_ratio("this is a test", "this is a test!")
100

PYFLUX
時間序列分析是機器學習領域最常見的問題之一。PyFlux 是 Python 中為處理時間序列問題而創(chuàng)建的開源庫。該庫有一系列極好的時間序列模型,包括但不限于 ARIMA、 GARCH 和 VAR 模型。簡而言之,PyFlux 提供了一個時間序列建模的概率方法。值得嘗試。
安裝:
pip install pyflux

示例:
有關用法和示例,請參考:https://pyflux.readthedocs.io/en/latest/index.html。
IPYVOLUME
交流結果是數(shù)據(jù)科學的一個基本方面。能夠將結果可視化是一個很大的優(yōu)勢。IPyvolume 是一個用于在 Jupyter notebook 中可視化 3d 體積和字形(如 3d 散點圖)的 Python 庫,只需少量配置即可。然而,它目前還處于前 1.0 版。IPyvolume 的 volshow 之于 3d 數(shù)組,就像 matplotlib 的 imshow 之于 2d 數(shù)組一樣。更多相關信息請見:https://ipyvolume.readthedocs.io/en/latest/?badge=latest。
安裝:
Using pip
$ pip install ipyvolume
Conda/Anaconda
$ conda install -c conda-forge ipyvolume

DASH
Dash 是一個用于構建 web 應用程序的高效 Python 框架。它寫在 Flask、Plotly.js 和 React.js 之上,將下拉列表、滑塊和圖形等 UI 元素與你的分析性 Python 代碼直接相連,無需 javascript。Dash 非常適合構建數(shù)據(jù)可視化應用程序。然后這些應用程序可以在 web 瀏覽器中進行渲染。用戶指南請見:https://dash.plot.ly/。
安裝:
pip install dash==0.29.0 # The core dash backend
pip install dash-html-components==0.13.2 # HTML components
pip install dash-core-components==0.36.0 # Supercharged components
pip install dash-table==3.1.3 # Interactive DataTable component (new!)

示例:
下圖示例顯示了具有下拉功能的高度交互圖。當用戶在下拉列表中選擇一個值時,應用程序代碼會動態(tài)地將 Google Finance 的數(shù)據(jù)導出為 Pandas DataFrame。資源:https://gist.github.com/chriddyp/3d2454905d8f01886d651f207e2419f0。


?
GYM
來自 OpenAI 的 Gym 是一個開發(fā)和對比強化學習算法的工具包。它兼容于任何數(shù)值計算庫,如 TensorFlow 或 Theano。Gym 庫是一個測試問題的集合,也被稱為環(huán)境——可以用它來計算你的強化學習算法。這些環(huán)境有一個共享的接口,允許你寫通用算法。
安裝:
pip install gym

示例:
運行環(huán)境 CartPole-v0 的 1000 個時間步驟實例,在每個步驟渲染環(huán)境。
閱讀其他環(huán)境請見:https://gym.openai.com/。