自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

這十個不常見但卻十分實用的Python庫,你知道幾個?

開發(fā) 后端
今天,我們將和大家分享一些用于數(shù)據(jù)科學任務的Python庫,這些庫并不常見,它們不如panda、scikit-learn、matplotlib等知名,但卻十分實用,下面就一起來看看都有哪些庫。

Python是一門神奇的語言,它是世界上發(fā)展最快的編程語言之一,尤其在數(shù)據(jù)科學方面的作用大家是有目共睹,Python的整個生態(tài)系統(tǒng)和它的庫使它成為全世界用戶(初學者和高級用戶)的最佳選擇。它的成功和流行的一個原因是背后強大的庫集合。

今天,我們將和大家分享一些用于數(shù)據(jù)科學任務的Python庫,這些庫并不常見,它們不如panda、scikit-learn、matplotlib等知名,但卻十分實用,下面就一起來看看都有哪些庫:

1. Wget

數(shù)據(jù)提取,尤其是從網(wǎng)絡中提取數(shù)據(jù),是數(shù)據(jù)科學家的重要任務之一。Wget是一個免費的工具,用于從Web下載非交互式的文件,它支持HTTP、HTTPS和FTP協(xié)議,以及通過HTTP代理進行檢索。由于它是非交互式的,所以即使用戶沒有登錄,它也可以在后臺工作。因此,她很適合用于下載一個網(wǎng)站或一個頁面的所有圖像。

(項目地址:https://pypi.org/project/wget/)

安裝:

  1. $ pip install wget 

示例:

  1. import wget 
  2. url = 'http://www.futurecrew.com/skaven/song_files/mp3/razorback.mp3' 
  3. filename = wget.download(url) 
  4. 100% [................................................] 3841532 / 3841532 
  5. filename 
  6. 'razorback.mp3' 

2. Pendulum

對于那些需要在Python項目中使用日期時間的人來說,Pendulum就是一項不錯的項目選自。它是一個用于簡化datetimes操作的Python包。它完全可以替代Python的原生類。

(項目地址:https://github.com/sdispater/pendulum)

安裝:

  1. $ pip install pendulum 

示例:

  1. import pendulum 
  2. dt_toronto = pendulum.datetime(2012, 1, 1, tz='America/Toronto'
  3. dt_vancouver = pendulum.datetime(2012, 1, 1, tz='America/Vancouver'
  4. print(dt_vancouver.diff(dt_toronto).in_hours()) 

3. imbalanced-learn

事實上,當每個類的樣本數(shù)量幾乎相同的情況下,分類算法的效果是最好的,但在實際項目中大部分的數(shù)據(jù)集是不平衡的,這些數(shù)據(jù)集對機器學習算法的學習階段和后續(xù)預測都有影響,imbalanced-learn的創(chuàng)建就是為了解決此類問題,它與scikit-learn兼容,是scikit-learn-contrib項目的一部分。下次如果你遇到不平衡的數(shù)據(jù)集時,考慮一下它。

(項目地址:https://github.com/scikit-learn-contrib/imbalanced-learn)

安裝:

  1. pip install -U imbalanced-learn 
  2. # or 
  3. conda install -c conda-forge imbalanced-learn 

4. FlashText

在NLP任務中清理文本數(shù)據(jù)通常需要替換句子中的關鍵字或從句子中提取關鍵字。這類操作一般使用正則表達式來完成,但是如果搜索的關鍵詞數(shù)量達到數(shù)千個,就會變得很麻煩。Python的FlashText模塊是基于FlashText算法,它為這種情況提供了一個合適的替代方案。FlashText最好的部分是,不管搜索詞的數(shù)量是多少,運行時都是一樣的。

(項目地址:https://github.com/vi3k6i5/flashtext)

安裝:

  1. $ pip install flashtext 

示例:

  1. from flashtext import KeywordProcessor 
  2. keyword_processor = KeywordProcessor() 
  3. # keyword_processor.add_keyword(<unclean name><standardised name>
  4. keyword_processor.add_keyword('Big Apple', 'New York') 
  5. keyword_processor.add_keyword('Bay Area') 
  6. keywords_found = keyword_processor.extract_keywords('I love Big Apple and Bay Area.') 
  7. keywords_found 
  8. ['New York', 'Bay Area'] 

關鍵詞替換:

  1. keyword_processor.add_keyword('New Delhi', 'NCR region') 
  2. new_sentence = keyword_processor.replace_keywords('I love Big Apple and new delhi.') 
  3. new_sentence 
  4. 'I love New York and NCR region.' 

5. Fuzzywuzzy

這個名字聽起來確實很奇怪,但是涉及到字符匹配時,fuzzywuzzy是一個非常有用的庫??梢钥焖賹崿F(xiàn)諸如字符串匹配度、令牌匹配度等操作。它還可以方便地匹配保存在不同數(shù)據(jù)庫中的記錄。

(項目地址:https://github.com/seatgeek/fuzzywuzzy)

安裝:

  1. $ pip install fuzzywuzzy 

示例:

  1. from fuzzywuzzy import fuzz 
  2. from fuzzywuzzy import process 
  3. # Simple Ratio 
  4. fuzz.ratio("this is a test", "this is a test!") 
  5. 97 
  6. # Partial Ratio 
  7. fuzz.partial_ratio("this is a test", "this is a test!") 
  8.  100 

6. PyFlux

時間序列分析是機器學習領域最常遇到的問題之一。PyFlux是為處理時間序列問題而構(gòu)建的Python開源庫。該庫擁有一系列優(yōu)秀的現(xiàn)代時間序列模型,包括但不限于ARIMA、GARCH和VAR模型??傊?,PyFlux為時間序列建模提供了一種高效的方法。值得嘗試。

(項目地址:https://github.com/RJT1990/pyflux)

安裝:

  1. pip install pyflux 

7. Ipyvolume

結(jié)果交流是數(shù)據(jù)科學的一個重要方面,可視化是一個很大的優(yōu)勢,IPyvolume是一個Python庫,用于在Jupyter筆記本中可視化三維圖形(如三維立體圖等),遺憾的是目前它還處于測試版本階段。

(項目地址:https://github.com/maartenbreddels/ipyvolume)

安裝:

  1. Using pip 
  2. $ pip install ipyvolume 
  3. Conda/Anaconda 
  4. $ conda install -c conda-forge ipyvolume 

示例:

8. Dash

Dash是一個用于構(gòu)建Web應用程序的高效Python框架。它是基于Flask、Plotly.js和React.js創(chuàng)建的,并結(jié)合了現(xiàn)代UI元素(如下拉框、滑塊和圖形)與用戶分析性Python代碼綁定在一起,而不需要再借助Javascript。Dash非常適合構(gòu)建數(shù)據(jù)可視化應用。然后可以在Web瀏覽器中呈現(xiàn)這些應用程序。

(項目地址:https://github.com/plotly/dash)

安裝:

  1. pip install dash==0.29.0  # The core dash backend 
  2. pip install dash-html-components==0.13.2  # HTML components 
  3. pip install dash-core-components==0.36.0  # Supercharged components 
  4. pip install dash-table==3.1.3  # Interactive DataTable component (new!) 

示例:

9. Bashplotlib

Bashplotlib是一個Python包和命令行工具,用于在終端生成基本的繪圖,使用Python編寫的,當用戶無法訪問GUI時,可視化數(shù)據(jù)就變得很方便。

安裝:

  1. pip install bashplotlib 

示例:

  1. scatter --file data/texas.txt --pch . 

  1. hist --file data/exp.txt 

10. Colorama

colorama是一個Python專門用來在控制臺、命令行輸出彩色文字的模塊,可以跨平臺使用,在windows下linux下都工作良好。它使用標準的ANSI轉(zhuǎn)義碼來著色和樣式終端輸出。(項目地址:https://github.com/tartley/colorama)

安裝:

  1. pip install colorama 

示例:

  1. import colorama 
  2. from colorama import Fore, Back, Style 
  3. colorama.init() 
  4. # Set the color semi-permanently 
  5. print(Fore.CYAN) 
  6. print("The Text will appear in cyan until it is reset") 
  7. print(Style.RESET_ALL) 
  8. # Colorize a single line and then reset 
  9. print(Fore.RED + 'Colorize a single line in RED' + Style.RESET_ALL) 
  10. # Colorize a single word in the output 
  11. print('You can also colorize a single word' + Back.GREEN + 'words' + Style.RESET_ALL + ' can be highlighted') 
  12. # Combine foreground and background color 
  13. print(Fore.BLUE + Back.WHITE) 
  14. print('Foreground, background, and styles can be combined') 
  15. print("==========            ") 
  16. print(Style.RESET_ALL) 
  17. print('Reset everything back to normal.') 

輸出如下:

以上就是我推薦的有關于處理數(shù)據(jù)科學方面任務的Python庫,不知道有沒有你喜歡的。

 

責任編輯:趙寧寧 來源: 開源最前線
相關推薦

2024-09-30 10:05:00

2023-12-15 10:42:05

2023-08-29 07:52:09

CSS庫網(wǎng)絡動畫

2022-04-24 10:12:25

Python軟件包代碼

2023-04-10 11:25:29

工程交流DX

2023-10-30 18:00:00

Docker命令開源平臺

2023-12-23 11:15:25

2024-10-15 10:40:09

2021-09-15 09:20:37

Python函數(shù)代碼

2022-03-03 23:56:29

JavaScriptArityAnonymous

2021-11-19 16:54:11

Python代碼開發(fā)

2024-05-23 11:53:24

Python代碼異常處理

2024-05-16 08:26:24

開發(fā)技巧項目

2022-11-25 14:55:43

JavaScriptweb應用程序

2022-05-16 07:48:54

Python操作類型

2017-12-12 14:50:33

數(shù)據(jù)庫MySQL命令

2019-09-26 14:20:27

JavaScript代碼編程語言

2015-09-20 16:23:27

2024-05-15 08:59:52

Python編程

2024-12-31 08:10:00

點贊
收藏

51CTO技術棧公眾號