How to create word embedding using FastText ?

FastText is one of the popular names in Word Embedding these days. In short, It is created by FaceBook. Still, FastText is open source so you don’t have to pay anything for commercial use. You may use FastText in many ways like test classification and text representation etc. While under this article , We will only explore the text representation . Basically for any Machine Learning algorithms on Text , You need to convert them into numbers vectors so you can categorize and find sense of the text. Lets understand How to create word embedding using FastText ?

Using FastText own Implementation –

Yes! FastText has its own implementation for word embedding . Here I am sharing the official link  for FastText own implementation for word embedding .

FastText Word embedding
FastText Word embedding

Here you can use FastText pre train model as well as you may train your own model of embedding with fastText algorithms . For implementation prospective I will suggest you to visit the official FastText tutorial on embeddings .

Gensim for FastText Implementation (fasttext word embeddings tutorial) –

create word embedding using FastText
create word embedding using FastText

How to Train FastText Embeddings –

Gensim provide the another way to apply FastText Algorithms and create word embedding .Here is the simple code example –

from gensim.models import FastText  
from gensim.test.utils import common_texts
model_FastText = FastText(size=4, window=3, min_count=1)
model_FastText .train(sentences=common_texts, total_examples=len(common_texts), epochs=10)

The above example is of 4 line implementation. Let’s understand one by one –

  1. Import required modules.
  2. You need some corpus for training. Here the corpus must be a list of lists tokens. The regular text must contain sentences. you need to create the tokens out of it. Hence every element of the list will be a sentence token. Now any text data must contain multiple sentences. So there will be a corresponding list for each sentence. So the final data structure will be a list of lists.
  3. Create the object for FastText with the required parameters. Here size is a number of feature or embedding dimensions. For more clarification 4 represents that each word will be represented in 4 columns. For more details, Please have look here –
  4. create word embedding using FastText paramters
    create word embedding using FastText paramters

    4. The fourth line gives the last train command syntax for FastText .

Fast Text Pre Trained Model –

When you read this title, you must have a question. Embedding on your training data or FastText Pre-trained Model. Actually, this is one of the big question points for every data scientist. Actually, there is a very clear line between these two. Let’s understand them one by one. See FastText is not a model, It’s an algorithm or Library which we use to train sentence embedding. However Pre train Fast Text Models are the ready-made solution ( models ) on some large corpus. This is the only beneficiary for generalize data itself.

See Training on large data involves heavy computation cost. Also, any deep learning model like FastText etc needs too much data.

Conclusion (FastText embeddings python) –

Friends, how did you find this article – How to create word embedding using FastText? Please write your views on this topic. Apart from this article, There are some other key terms that you should understand when it comes to word embedding. Word Embedding is a very vast and hot research topic. So keep on the reading-related the latest content on this.   Please refer to the below article for reference and basic understanding  –

Word Embedding in Python : Different Approaches

Prediction Based Word Embedding Techniques

Which is the Best Word Embedding Technique with Domain Data ?

I hope this tutorial has helped you in understanding FastText in detail. If you have any queries then you can contact us for more help and information.

Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for signup. A Confirmation Email has been sent to your Email Address.

Something went wrong.

Source link

Brightness_range Keras : Data Augmentation with ImageDataGenerator

Brightness_range Keras is an argument in ImageDataGenerator class of keras.preprocessing.image package. We can use it to adjust the brightness_range of any image for Data Augmentation. This article will explain to you the term Data Augmentation. In addition, We will also see how can we achieve Data Augmentation using brightness_range in Keras.

Data Augmentation with brightness_range –

Firstly, let’s understand the term Data Augmentation. Well! when you have less data for training or you want to add more variety of data in the dataset. You may generate more data by cropping, adding brightness, padding of existing data(Image). This technique is Data Argumentation in image processing.

As I have already mentioned that increasing and decreasing the brightness of the image. Also comes into the data Argumentation in Image processing.

Brightness_range TensorFlow Syntax-


Here is the syntax for the brightness_range argument in Tensorflow API. Basically, TensorFlow 2.0 is having a similar syntax to Keras under its package tensorflow.keras. 

from tensorflow.keras.preprocessing.image import ImageDataGenerator
imageDataGenerator_obj= ImageDataGenerator(brightness_range=(0.2, 0.8))

Here the range starts from zero which signifies no brightness of the image. Also, the upper range is 1 which signifies the maximum range of the brightness.


Brightness_range Keras Syntax –

Let’s see the implementation of brightness_range in core Keras API.

from keras.preprocessing.image import ImageDataGenerator

datagen = ImageDataGenerator(brightness_range=[0.2,1.0])

There is a big difference in the parameter of Tensorflow brightness_range with this API. In Keras, 1.0 is the neutral brightness. If you go down to 1 it will start darkening the image. And if you go above to 1 ( value) it will start brightening the image.

In the above syntax example, We have used the brightness_range=[0.2,1.0]. This will darken the image in this range.


Step by step Implementation of brightness_range Keras –

Let’s implement the data argumentation with it.

Step 1:

Import the relevant packages.

from numpy import expand_dims
from keras.preprocessing.image import load_img
from keras.preprocessing.image import img_to_array
from keras.preprocessing.image import ImageDataGenerator
from matplotlib import pyplot
from io import BytesIO
from PIL import Image


Step 2:

Image loading and conversion into the array. I am working over google colab. Hence please change the code if you are doing it locally.

#specific to Google Colab only

from google.colab import files
uploaded = files.upload()

#Loading the image and converting into Byte

For instance, we have taken the sample image "lamborghini_660_140220101539.jpg", you may change at your convenience.

Step 3:

Data argumentation for the above image.

# dimesion adjustment
sam = expand_dims(img_array, 0)
# create image data augmentation generator
imageDataGenerator_obj = ImageDataGenerator(brightness_range=[0.3,0.9])

Step 4:

Now we will plot  the image.

iterator = imageDataGenerator_obj.flow(sam, batch_size=1)
for j in range(6):

	pyplot.subplot(330 + 1 + j)
	chunk =

	sub_img = chunk[0].astype('uint8')

Full code with output-

Above all,  Here is the complete code from each step.

from numpy import expand_dims
from keras.preprocessing.image import load_img
from keras.preprocessing.image import img_to_array
from keras.preprocessing.image import ImageDataGenerator
from matplotlib import pyplot
from io import BytesIO
from PIL import Image
#Loading the image and coverting into Byte
# dimesion adjustment
sam = expand_dims(img_array, 0)
# create image data augmentation generator
imageDataGenerator_obj = ImageDataGenerator(brightness_range=[0.3,0.9])
# image ploting
iterator = imageDataGenerator_obj.flow(sam, batch_size=1)
for j in range(6):

	pyplot.subplot(330 + 1 + j)
	chunk =

	sub_img = chunk[0].astype('uint8')

After that, Let’s see the output for the full code.


Above all, As you can see, We have generated the six different images from a single one. Just by changing the brightness. data argumentation also helps to stop overfitting the model.


Data Science Learner Team

Other Questions

These are the question asked on the Keras by the data science reader.

Q: I am getting No module named keras Import error. How to fix it?

This error comes where you have not install Keras module and importing it. It can be solved if you install it. To install you can use the pip command.

pip install Keras

There is a dedicated step-by-step fix to remove No module named keras error.

Q 2: How to install  TensorFlow in PyCharm

Kera requires TensorFlow to be installed in your system. So before implementing deep learning you have to install TensorFlow. You can install tensorflow using the pip command.

pip install --upgrade tensorflow

It will install TensorFlow on your system. There is a dedicated tutorial on how to install TensorFlow in pycharm. Please read it to know more.

Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for signup. A Confirmation Email has been sent to your Email Address.

Something went wrong.

Source link

Must know for Data Scientist

PDFQuery python library

As a Data Scientist, You may not stick to data format. PDFs are a good source of data. Most of the organization release their data in PDFs only. As AI is growing, We need more data for prediction and classification. Hence ignoring PDFs as data sources could be a blunder. Actually, PDF processing is a little difficult but we can leverage the below API for making it easier. This article [ Best Python PDF Library: Must know for Data Scientist ] will give a brief on PDF processing using Python.

Before we start this article, I have something really amazing for you. Have you checked out trail version for Amazon Audible book on Python . Don’t say You have not checked out , See ! without books in-depth knowledge is not possible. This audible books gives you the knowledge of book with minimal efforts . Do checkout this.

Best Python PDF Library-

1. PDFMiner-

Amazing Library for PDF processing in Python. Easy to install and use. Here is the link for the official Documentation for PDFMiner. A community is never great without their supporter. Here is the community link for PDFMiner. You can use a link to leverage community users. PDFMiner provides command utility for Non Programmers and API interface for programmers.


This Python PDF Library is quite extensible. You may extract text from pdf, crop, and merge PDF Document with Encryption and decryption feature. There are so many versions of PyPDF. Actually, before PyPDF4,  PyPDF2 was more trendy. It is still there but PyPDF4 is the latest version for this. Here is the official documentation of PyPDF4.

Examples are always best. Let’s see  How to Extract Text from PDF File Using Python with example.

3. pdfrw-

Quite similar to the above two mentions. Apart from that similarity, pdfrw has its own USPs (Unique Selling Points). Actually, the requirement of API depends on the use case. Get a full description of pdfrw.

4.Slate –

It is wrapper Implementation of PDFMiner. No API is perfect, There were few shortcomings in PDFMiner. Slate beautifully address them. Here is the complete code description for Slate.

python pdf library slate

5. pikepdf –

This pikepdf library is an emerging python library for PDF processing. It is Python + QPDF = “py” + “qpdf” = “pyqpdf”. If you look at the comparison between PyPDF2 and pdfrw, You will see, It provide some feature which is not available in both of them.


This PDFQuery is one of the fastest python scrapping library. Use the below command to install the PDFQuery package and use it.

pip install pdfquery


7. Others Libraries –

I always stuck in this place. Where I have to decide which is the best place holder for this rank. Actually, No library is perfect. This choice should be in the use case. Its requirement oriented. The choices for you at this position are –


Why Python for PDF processing –

As you know PDF processing comes under text analytics. Most of the Text Analytics libraries or frameworks are designed in Python only. This gives leverage to text analytics. One more thing you can never process a pdf directly in existing frameworks of Machine Learning or Natural Language Processing. Unless they are proving explicit interface for this. We have to convert pdf to text first. We can easily achieve this using any of the above mention libraries.

How is java for PDF processing –

Truly! telling when it comes to PDF processing Java is awesome.  At Data Science Learner we have created a brief article on java pdf library. Actually, PDF Processing Involves so many processes. Like text, image extraction from pdf, merging document, pdf document metadata extraction, etc. Few java pdf libraries are all in one. I mean you can perform most of the PDF tasks using a single Library.

Conclusion –

How did you find this article? If you know any python library which should be mention with others. Please let us know. The above list is dynamic which may vary on future releases of the existing library or new arrival in this category.


Data Science Learner Team 

Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for signup. A Confirmation Email has been sent to your Email Address.

Something went wrong.

Source link

Tony Lopez Age Height Girlfriend Family

Tony Lopez Photo
Tony Lopez

Tony Lopez is a famous American dancer, social media star who gained popularity through TikTok videos and Instagram. He is the most excellent TikTok star in the USA, and he has 22.5 million TikTok followers. Also, he has 1.1 Billion likes on his TikTok. Tony Lopez’s brother Xavier Lopez and Ondreaz Lopez have a YouTube channel called Lopez Brothers.

Tony Lopez New Pic
New Pic

Bio / Wiki

90Full name: Antonio Levi Lopez
Nickname: Tony Lopez
Profession: Social Media Star, TikTok, and YouTube.
Years of active: 2013 (YouTube)
Gender: Male
Religion: Cristian
Nationality: American
American flag
Date of birth: 19 August 1999
Birthplace: Las Vegas, Nevada, United States.
Age now: 22–Years (Update 2021)
Zodiac Sign: Leo
Tony Lopez New Photo
New Photo

Height Weight & Body Facts

Height: In Feet: 5 feet 7 inches
In Centimeters: 170 cm
In Meters: 1.70 m
Weight: In pounds: 136 LBS
In Kilogram: 62 KG
Chest: 38 inches
Biceps: 12 inches
Waist: 30 inches
Hair Color: Brown
Eye Color: Brown
Skin tone: Fair
Dress size: Large ( US standard)
Shoe size: 10 (US)
Tattoo: Will Update
Tony Lopez Images

Early Life

Antonio Levi Lopez (well-known as Tony Lopez) was born on 19 August 1999 in Las Vegas, Nevada, United States. His parent’s name is unknown, and he has a two brothers name Xavier Lopez and Ondreaz Lopez (Ondreaz Lopez is a TikTok star). He spent his childhood in Las Vegas, Nevada, with his family and was interested in dancing and acting from childhood.

Tony Lawrence studied at Junior High School, Las Vegas, Nevada, United States. After that, he was admitted to Local Private College, Las Vegas, Nevada, United States, and graduated.

Tony Lopez with her brother's Photo
with her brothers

Family & Relative

Father’s name: Will Update
Mother’s name: Will Update
Siblings: Three
Brother: Xavier Lopez (older Brother)
Ondreaz Lopez (older Brother)
Sister: Not Known
Marital status: Unmarried
Married date: Will Update
Wife’s Name: Will Update
Girlfriend’s Name: Sarah-Jade Bleau

Personal Life

Starting in 2021, Tony Lopez doesn’t have any lovers. He is an old buddy with numerous other social media stars, and we don’t know if he is currently dating anybody. The Lopez siblings are individuals from the famous social media group “The Hype House.” The gathering contains other social media characters and stars like Chase Hudson and Charli D’Amelio. However, there is a rumor on social media that Tony Lopez’s girlfriend, Sarah-Jade Bleau.

Education / Contact

Qualification: Graduated
School: Junior High School, Las Vegas, Nevada, United States
Collage / University: Local Private College, Las Vegas, Nevada, United States
Phone No: Not Published
Email Address: Will Update
Home Address: Las Vegas, United States.
Official Website: Will Update

Social Media Profiles

As of August 2021, Tony has more than 449.5K Twitter followers, 5.8 million Instagram followers, and 22.5 million followers on TikTok(1.1 Billion likes). His joint YouTube channel with his sibling, The Lopez Brothers, has more than 1.66 million endorsers.

Tony Lopez Syles Photo
Syles Photo

Tony Lopez Net Worth

As of 2021, Tony Lopez’s net worth is $7 million approx. Tony mainly earns through his YouTube channel, TikTok account, and sponsorships and advertisements on his different social media titles.

Tony Lopez Picture

Favorite Thing Of Tony Lopez

Favorite actors: Morgan Freeman, Tom Hanks, Jerry Rig, and Harrison Ford.
Favorite food:  Texas Barbecue, Clam Chowder, Apple Pie, The Hamburger, and Deep-Dish Pizza.
Favorite color:  Red, White, and Black.
Favorite actress: Lexi Boling, Nadia Hilker, Gigi Hadid, Lily Collins, and Taylor Hill.
Favorite Dancer: Michael Jackson
Favorite Perfume: Scent & Calvin Klein
Favorite place: New York, Washington, and the Florida United States.
Favorite Sports: Rugby Ball
Favorite Players: Ray Lewis
Tony Lopez Pics


Tony Lopez first rose to popularity on the video-sharing platform TikTok. Since joining the stage, he has become one of the best successful users of TikTok. Both Tony and his brother are famous on TikTok; however, his sibling has a more significant number of followers than he does. The two brothers appear in one another’s videos often.

Tony Lopez and his brother Ondreaz are the two individuals from the TikTok collective “Hype House,” where a portion of TikTok’s most great stars team up and make content together. The house was open in December 2019! As a way for the stars to use their substance and develop their followings. The Promotion House boasts individuals like Avani Gregg and Pursue Hudson.

Both Tony Lopez and his brother Ondreaz inhabit the original Promotion House in Los Angeles; however, they invest strength at home in Las Vegas when not in Los Angeles. In 2019, the star facilitated a Dance Workshop in Las Vegas, his hometown.

In addition to his TikTok page, Tony Lopez runs a YouTube page with his brother where they post various videos, including dance videos, comedic videos, and challenge videos.

Source link