6 Cool Python Libraries That I Came Across Recently

 Python is an integral part of machine learning and libraries make our life simpler. Recently, I came across 6 awesome libraries while working on my ML projects. They helped me save a lot of time and I am going to discuss about them in this blog.

1. clean-text

Installation

!pip install cleantext

Example

#Importing the clean text library
from cleantext import clean
# Sample texttext = """ Zürich, largest city of Switzerland and capital of the canton of 633Zürich. Located in an Al\u017eupine. (https://google.com). Currency is not ₹"""# Cleaning the "text" with clean textclean(text,
fix_unicode=True,
to_ascii=True,
lower=True,
no_urls=True,
no_numbers=True,
no_digits=True,
no_currency_symbols=True,
no_punct=True,
replace_with_punct=" ",
replace_with_url="",
replace_with_number="",
replace_with_digit=" ",
replace_with_currency_symbol="Rupees")

Output

2. drawdata

Installation

!pip install drawdata

Example

# Importing the drawdata 
from drawdata import draw_scatter
draw_scatter()

Output

Image by the author
#Reading the clipboardimport pandas as pd 
df = pd.read_clipboard(sep=",")
df

3. Autoviz

Installation

!pip install autoviz

Example

# Importing Autoviz class from the autoviz library
from autoviz.AutoViz_Class import AutoViz_Class
#Initialize the Autoviz class in a object called df
df = AutoViz_Class()
# Using Iris Dataset and passing to the default parametersfilename = "Iris.csv"
sep = ","
graph = df.AutoViz(
filename,
sep=",",
depVar="",
dfte=None,
header=0,
verbose=0,
lowess=False,
chart_format="svg",
max_rows_analyzed=150000,
max_cols_analyzed=30,
)

Output

Image by the author

4. Mito

Installation

#First install mitoinstaller in the command prompt
pip install mitoinstaller
# Then, run the installer in the command prompt
python -m mitoinstaller install
# Then, launch Jupyter lab or jupyter notebook from the command prompt
python -m jupyter lab
# Importing mitosheet and ruuning this in Jupyter labimport mitosheet
mitosheet.sheet()

Output

Image by the author
from mitosheet import * # Import necessary functions from Mito
register_analysis('UUID-119387c0-fc9b-4b04-9053-802c0d428285') # Let Mito know which analysis is being run
# Imported C:\Users\Dhilip\Downloads\archive (29)\Iris.csv
import pandas as pd
Iris_csv = pd.read_csv('C:\Users\Dhilip\Downloads\archive (29)\Iris.csv')
# Added column G to Iris_csv
Iris_csv.insert(6, 'G', 0)
# Set G in Iris_csv to =AVG(SepalLengthCm)
Iris_csv['G'] = AVG(Iris_csv['SepalLengthCm'])
# Renamed G to Avg_Sepal in Iris_csv
Iris_csv.rename(columns={"G": "Avg_Sepal"}, inplace=True)

5. Gramformer

Installation

!pip3 install -U git+https://github.com/PrithivirajDamodaran/Gramformer.git

Instantiate Gramformer

gf = Gramformer(models = 1, use_gpu = False) # 1=corrector, 2=detector (presently model 1 is working, 2 has not implemented)

Example

#Giving sample text for correction under gf.correctgf.correct(""" New Zealand is island countrys in southwestern Paciific Ocaen. Country population was 5 million """)

Output

Image by the author

6. Styleformer

Installation

!pip install git+https://github.com/PrithivirajDamodaran/Styleformer.git

Instantiate Styleformer

sf = Styleformer(style = 0)# style = [0=Casual to Formal, 1=Formal to Casual, 2=Active to Passive, 3=Passive to Active etc..]

Examples

# Converting casual to formal sf.transfer("I gotta go")
# Formal to casual 
sf = Styleformer(style = 1) # 1 -> Formal to casual
# Converting formal to casual
sf.transfer("Please leave this place")
# Active to Passive 
sf = Styleformer(style = 2) # 2-> Active to Passive
# Converting active to passive
sf.transfer("We are going to watch a movie tonight.")
# passive to active
sf = Styleformer(style = 2) # 2-> Active to Passive
# Converting passive to active
sf.transfer("Tenants are protected by leases")

Your home for data science. A Medium publication sharing concepts, ideas and codes.

TIME SERIES FROM SCRATCH

Part 3 of the Time Series from Scratch Series — Learn everything about white noise and random walks, and their importance in time series forecasting

Photo by Kai Dahms on Unsplash
  • White Noise: Theory and Implementation
  • Random Walk: Theory and Implementation
  • Conclusion

White Noise: Theory and Implementation


Post a quick thought or a long story. It's easy and free.


HANDS-ON DATA ANALYTICS WITH PYTHON

Explained with Example — .astype(), .convert_dtypes() and.to_numeric()

Photo by Chris Lawton on Unsplash

Comments

Popular posts from this blog

Flutter for Single-Page Scrollable Websites with Navigator 2.0

A Data Science Portfolio is More Valuable than a Resume

Better File Storage in Oracle Cloud