Text Representation Basics: NLP Tutorial For Beginners - Season 2 Episode 1

codebasics · Beginner ·📊 Data Analytics & Business Intelligence ·4y ago

Key Takeaways

The video discusses text representation basics in NLP, covering topics such as feature engineering, vector space models, and text representation techniques like one-hot encoding and bag of words, using tools like cosine similarity and vector stores.

Full Transcript

in this short video we will talk about tax representation in NLP and we don't have any coding today in this playlist we had a video which covered three techniques of doing NLP these three and we covered rules and heuristic a little bit in our regular expression video will you talk about the other two approaches the NLP pipeline looks something like this and in this we already covered pre-processing by having tutorials on stemming limitation tokenization all of that in Spacey so far now we are jumping into the next big topic which is feature engineering this is one of the very important steps in machine learning Pipeline and this is the step where Engineers or data scientists spend a lot of time what exactly is features before we talk about feature engineering we want to know what is features so if you don't know the basic concepts about machine learning I'm going to give you a very Layman understanding of features let's say you're working on a property price prediction problem and trying to build a machine learning model that can predict the price of a property now when you go and buy home what are the factors that can impact price well obviously things like area facilities how old is the home location these things are called features for property price prediction problem it's a linear regression or statistical machine learning problem if you talk about dogs and cats general image classification the way this works is how humans recognize these images or in reality let's say you're walking on a road you see cat coming at you or dog coming at you how do you know it's a dog and cat and not a lion right you in your brain there is some detection happening and the way it works is if you think about properly is you will detect individual features such as nose when you look at an animal and that knows you will say yes it's a dog's nose or cat's nose eyes right so you look at cat size they're around dog's eyes are a little different dogs ears are kind of falling and cat has pointed ears although some dog also have pointed ears but you get an idea that every animal has a distinct set of features whiskers so Eyes Nose viscous yes are called features basically right it's a general Common Sense knowledge and we use neural networks for this image classification and I'm going to give you very simplistic understanding of the neural network okay this is for Layman understanding if you want to know details in YouTube search code Basics convolutional neural network I have explained things in detail and in a more accurate way but this is just to give you a general idea that when you have a neural network each of these neurons are like units and these units have a specific task one unit is saying whether the years are of cats years or not the other unit is doing a task of identifying if in the image there is cats nose or not and if you get yes answer for all all of this you can say yes in the image I have a head of a cat and if you have a head of a cat and a body of a cat it has to be cat so this is how the neural network works in layman terms let's say if if I show you image like this you know I just use Microsoft Paint and put some dogs body parts as a human when you look at it now you think it's cat's image because little bit it looks like clay cat's image but you're not 100 sure why because in your brain your brain is telling these ears and nose they don't look like cats ears and knows so you will say no in your brain this is happening you're saying no no for certain features and then if I tell you let's say if I remove everything and if I just show you the head of of this animal in the image you and I if I ask you is it cat's head you say no it is not cat said because the ears and eyes are kind of looking different they are not cats ears and nose actually hence your overall answer might be no now we talked about images and uh the property price prediction problem which was more like statistical machine learning this is more like convolutional neural network how about text let's say you have this text I have I've given you three words dhoni comments Australia now if you're following Cricket you know that the first two words are actually cricket players the third word is a country called Australia how do you represent this text into features you know how do you extract features out of it because previously see for for the image ears nose eyes their features for property price prediction area location facilities bedrooms these are the features so what are the features for word right it seems little bit tricky one way could be you can ask couple of questions you can say okay is this a person is that is he healthy or fit is it a location see I have location I have zero value means dhoni is not a location it's a person so the value of location is zero and person is one but Australia is a location so value is one and person is zero and these are like handcrafted features all right so these are the features that represent these words and I can have a feature vector so this is one of the common techniques in natural language processing where you will present a word as a vector set of numbers instead of one number there is a reason you don't want to assign just one single number if you present it as a vector you can do mathematical operations such as cosine similarity if you don't know what is cosine similarity again go to YouTube search code Basics cosine similarity I have a math and statistics playlist just for machine learning you will get your concept clear I would highly recommend actually you watch that playlist you know in YouTube type code basics or let me maybe just show you so in the YouTube let's say if you type in four basics maths statistics you will find this particular playlist my wife likes to see CID by the way so uh here you will see cosine similarity and this cosine similarly this Vector mathematics is very helpful in NLP that is one of the reason why we present uh why we present the words as vectors all right so essentially what we did is we had a word we use some technique now let's not go into detail you will be like okay how did you come up with these questions I just made it up folks for your understanding okay as we go uh as we make progress in this course you will find out but just for your understanding we use some criteria to come up with a vector for a word and you know there is a benefit of doing it this way because now when you're comparing dhoni versus human you will see lot of similarities see one one point nine point eight seven so when you do a cosine similarity between these two words dunian comments will be more similar than dhoni in Australia the cosine similarity between dhoni and Australia will not be they want these two vectors won't be that similar but the vectors of dunian cumins comments vectors is basically these numbers you know it's like a basic math if you you need to know basic math Vector math and for that I I refer you to that playlist so the cosine similarity between dhoni and comments is higher they are highly similar so now when you are doing any kind of NLP when you're working on NLP problem having similar representation for similar words is very very useful correct you are building sentiment analysis model and you have a product review let's say where you say the product is worse okay and you have built a model based on this kind of training set and let's say when you're predicting and you say if the product is bad now worse and bad are similar words so if you have this kind of vectors it will help you figure out that these are similar so here the idea is you converted a word into a vector of numbers why do we do that machine learning models do not understand text that's the fundamental thing you need to remember machine learning models need numbers they can't work on text you have to convert your text into numbers and this is one of the ways of converting text into a number which is a vector representation it is also called Vector space model so feature engineering is basically a process of extracting features from raw data so you had raw data which was dhoni you extracted all these features you know personal healthy fit you constructed this vector and this process is called feature Engineering in nnp it is also called tax representation you represented this text as a vector of numbers it is very simple folks it's not a rocket science at all and this model this mathematical model of coming up with a vector for a text and when I say text it can be word phrase sentence paragraph these are different text units when you come up with a vector for any of these text units it is called Vector space model now there are various approaches of uh coming up with a vector for a text or there are various approaches of doing text representation in NLP 140 encoding bag of words I have listed few here one hot encoding is not very very popular we have looked into this in our machine learning playlist if you watch core Basics Again YouTube if you search for Basics machine learning uh you will find my playlist uh in the next video I will tell you how many videos you need to watch uh but in the next video we are going to look at most likely bag of words and we'll do coding we'll do some a classical problem of email spam detection that's the agenda for the next tutorial but in this tutorial I just wanted to give you a brief idea on what is text representation and I want to end this session with a very important and insightful code from this book practical NLP okay I think you you should read this book this is a very good book in NLP the book says often in NLP feeding a good representation to an ordinary algorithm will get you much farther than applying top-notch algorithm to an ordinary text representation file now you understand as a data scientist or NLP engineer you should not be obsessed about what exact machine learning model you are using you should put more focus on the tax representation see if you can extract the features in a better way from the text and if you can represent tags in a good way using Vector space model 8 is going to take you very very far I hope you like this session if you did give it a thumbs up if you have any question Post in a comments box below in the next video we'll do coding we'll do emails spam detection um and we'll use a bag of words [Music]

Original Description

Machine learning models only understand numbers, they can't work on the text. In this video, we will discuss some basics of machine learning such as, 1) What are the features in machine learning? 2) What is feature engineering? 3) How text representation is used in NLP to extract features from text We will go into detail about text representation in future videos. Complete NLP Playlist: https://www.youtube.com/playlist?list=PLeo1K3hjS3uuvuAXhYjV2lMEShq2UYSwX 🔖Hashtags🔖 #nlp #nlptutorial #nlppython #spacytutorial #textrepresentationnlp #nlpfeatureengineering #textrepresentation #textrepresentationspacy Do you want to learn technology from me? Check https://codebasics.io/?utm_source=description&utm_medium=yt&utm_campaign=description&utm_id=description for my affordable video courses. Practical NLP Book In India: https://www.shroffpublishers.com/books/computer-science/artificial-intelligence/natural-language-processing/9789385889189/ Practical NLP Book Link For USA: https://amzn.to/3Aoeocm Need help building software or data analytics/AI solutions? My company https://www.atliq.com/ can help. Click on the Contact button on that website. 🎥 Codebasics Hindi channel: https://www.youtube.com/channel/UCTmFBhuhMibVoSfYom1uXEg #️⃣ Social Media #️⃣ 🔗 Discord: https://discord.gg/r42Kbuk 📸 Instagram: https://www.instagram.com/codebasicshub/ 🔊 Facebook: https://www.facebook.com/codebasicshub 📱 Twitter: https://twitter.com/codebasicshub 📝 Linkedin (Personal): https://www.linkedin.com/in/dhavalsays/ 📝 Linkedin (Codebasics): https://www.linkedin.com/company/codebasics/ 🔗 Patreon: https://www.patreon.com/codebasics?fan_landing=true
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from codebasics · codebasics · 0 of 60

← Previous Next →
1 Python Tutorial - 1. Install python on windows
Python Tutorial - 1. Install python on windows
codebasics
2 Python Tutorial - 2. Variables
Python Tutorial - 2. Variables
codebasics
3 Python Tutorial - 3. Numbers
Python Tutorial - 3. Numbers
codebasics
4 Python Tutorial - 4. Strings
Python Tutorial - 4. Strings
codebasics
5 Python Tutorial - 5. Lists
Python Tutorial - 5. Lists
codebasics
6 Python Tutorial - 6. Install PyCharm on Windows
Python Tutorial - 6. Install PyCharm on Windows
codebasics
7 PyCharm Tutorial - 7. Debug python code using PyCharm
PyCharm Tutorial - 7. Debug python code using PyCharm
codebasics
8 Python Tutorial -  8. If Statement
Python Tutorial - 8. If Statement
codebasics
9 Python Tutorial - 9. For loop
Python Tutorial - 9. For loop
codebasics
10 Python Tutorial -  10. Functions
Python Tutorial - 10. Functions
codebasics
11 Python Tutorial - 11. Dictionaries and Tuples
Python Tutorial - 11. Dictionaries and Tuples
codebasics
12 Python Tutorial - 12. Modules
Python Tutorial - 12. Modules
codebasics
13 Python Tutorial - 13. Reading/Writing Files
Python Tutorial - 13. Reading/Writing Files
codebasics
14 How to install Julia on Windows
How to install Julia on Windows
codebasics
15 Python Tutorial - 14. Working With JSON
Python Tutorial - 14. Working With JSON
codebasics
16 Julia Tutorial - 1. Variables
Julia Tutorial - 1. Variables
codebasics
17 Julia Tutorial - 2. Numbers
Julia Tutorial - 2. Numbers
codebasics
18 Python Tutorial - 15. if __name__ == "__main__"
Python Tutorial - 15. if __name__ == "__main__"
codebasics
19 Julia Tutorial - Why Should I Learn Julia Programming Language
Julia Tutorial - Why Should I Learn Julia Programming Language
codebasics
20 Python Tutorial  - 16. Exception Handling
Python Tutorial - 16. Exception Handling
codebasics
21 Julia Tutorial - 3. Complex and Rational Numbers
Julia Tutorial - 3. Complex and Rational Numbers
codebasics
22 Julia Tutorial - 4. Strings
Julia Tutorial - 4. Strings
codebasics
23 Python Tutorial -  17. Class and Objects
Python Tutorial - 17. Class and Objects
codebasics
24 Julia Tutorial - 5. Functions
Julia Tutorial - 5. Functions
codebasics
25 Julia Tutorial - 6. If Statement and Ternary Operator
Julia Tutorial - 6. If Statement and Ternary Operator
codebasics
26 Julia Tutorial - 7. For While Loop
Julia Tutorial - 7. For While Loop
codebasics
27 Python Tutorial  - 18. Inheritance
Python Tutorial - 18. Inheritance
codebasics
28 Julia Tutorial - 8. begin and (;) Compound Expressions
Julia Tutorial - 8. begin and (;) Compound Expressions
codebasics
29 Python Tutorial - 12.1 - Install Python Module (using pip)
Python Tutorial - 12.1 - Install Python Module (using pip)
codebasics
30 Julia Tutorial - 9. Tasks (a.k.a. Generators or Coroutines)
Julia Tutorial - 9. Tasks (a.k.a. Generators or Coroutines)
codebasics
31 Julia Tutorial - 10. Exception Handling
Julia Tutorial - 10. Exception Handling
codebasics
32 Python Tutorial  - 19. Multiple Inheritance
Python Tutorial - 19. Multiple Inheritance
codebasics
33 Python Tutorial - 20. Raise Exception And Finally
Python Tutorial - 20. Raise Exception And Finally
codebasics
34 Python Tutorial - 21. Iterators
Python Tutorial - 21. Iterators
codebasics
35 Python Tutorial - 22. Generators
Python Tutorial - 22. Generators
codebasics
36 Python Tutorial - 23. List Set Dict Comprehensions
Python Tutorial - 23. List Set Dict Comprehensions
codebasics
37 Python Tutorial - 24. Sets and Frozen Sets
Python Tutorial - 24. Sets and Frozen Sets
codebasics
38 Python Tutorial - 25. Command line argument processing using argparse
Python Tutorial - 25. Command line argument processing using argparse
codebasics
39 Debugging Tips - What is bug and debugging?
Debugging Tips - What is bug and debugging?
codebasics
40 Debugging Tips - Conditional Breakpoint
Debugging Tips - Conditional Breakpoint
codebasics
41 Debugging Tips - Watches and Call Stack
Debugging Tips - Watches and Call Stack
codebasics
42 Python Tutorial - 26. Multithreading - Introduction
Python Tutorial - 26. Multithreading - Introduction
codebasics
43 Git Tutorial 3:  How To Install Git
Git Tutorial 3: How To Install Git
codebasics
44 Git Tutorial 1: What is git / What is version control system?
Git Tutorial 1: What is git / What is version control system?
codebasics
45 Git Tutorial 2 : What is Github? | github tutorial
Git Tutorial 2 : What is Github? | github tutorial
codebasics
46 Git Tutorial 4: Basic Commands: add, commit, push
Git Tutorial 4: Basic Commands: add, commit, push
codebasics
47 Git Tutorial 5: Undoing/Reverting/Resetting code changes
Git Tutorial 5: Undoing/Reverting/Resetting code changes
codebasics
48 Git Tutorial 6: Branches (Create, Merge, Delete a branch)
Git Tutorial 6: Branches (Create, Merge, Delete a branch)
codebasics
49 Git Github Tutorial 10: What is Pull Request?
Git Github Tutorial 10: What is Pull Request?
codebasics
50 Git Tutorial 7: What is HEAD?
Git Tutorial 7: What is HEAD?
codebasics
51 Git Tutorial 9: Diff and Merge using meld
Git Tutorial 9: Diff and Merge using meld
codebasics
52 Difference between Multiprocessing and Multithreading
Difference between Multiprocessing and Multithreading
codebasics
53 Python Tutorial - 27. Multiprocessing Introduction
Python Tutorial - 27. Multiprocessing Introduction
codebasics
54 Python Tutorial - 28. Sharing Data Between Processes Using Array and Value
Python Tutorial - 28. Sharing Data Between Processes Using Array and Value
codebasics
55 Git Tutorial 8 - .gitignore file
Git Tutorial 8 - .gitignore file
codebasics
56 Python Tutorial - 29. Sharing Data Between Processes Using Multiprocessing Queue
Python Tutorial - 29. Sharing Data Between Processes Using Multiprocessing Queue
codebasics
57 Python Tutorial - 30. Multiprocessing Lock
Python Tutorial - 30. Multiprocessing Lock
codebasics
58 Python Tutorial - 31. Multiprocessing Pool (Map Reduce)
Python Tutorial - 31. Multiprocessing Pool (Map Reduce)
codebasics
59 What is code?
What is code?
codebasics
60 Python unit testing - pytest introduction
Python unit testing - pytest introduction
codebasics

This video teaches the basics of text representation in NLP, including feature engineering and vector space models, and provides practical examples of how to apply these concepts to machine learning models. The video is suitable for beginners and covers key topics such as one-hot encoding and bag of words. By watching this video, viewers can learn how to convert text data into numerical vectors and apply machine learning algorithms to text-based problems.

Key Takeaways
  1. Pre-process text data
  2. Extract features from text data using techniques like one-hot encoding and bag of words
  3. Convert text data to numerical vectors using vector space models
  4. Apply machine learning algorithms to text-based problems
  5. Evaluate the performance of machine learning models on text data
💡 Text representation is a critical step in NLP that enables machine learning models to understand and process text data, and there are various techniques and tools available to achieve this, including vector space models and feature engineering.

Related Reads

📰
Por qué el "precio de lista" de una tienda no vale nada (y cómo construimos un tracker honesto)
Learn why list prices in stores are often misleading and how to build a tracker to monitor honest prices, applying data analysis and programming skills to make informed purchasing decisions.
Dev.to · Edu Tor
📰
FDA Recall API: A Working Guide to openFDA Enforcement
Learn to navigate the openFDA Enforcement API to retrieve drug, device, and food recall data, overcoming common issues like the 26,000-record skip wall and silent OR bug
Dev.to · Mayd-It
📰
Common Mistakes New Data Engineers Make (And How to Avoid Them)
Learn to avoid common mistakes new data engineers make to improve data pipeline efficiency and reliability
Dev.to · Abhishek Konagalla
📰
DuckDB vs PostgreSQL: I Ran the Same Query on Both. One Finished in 12ms. The Other Timed Out.
Compare DuckDB and PostgreSQL performance by running the same query on both to determine when to use each database system
Medium · Programming
Up next
How to Prompt Your LLM Directly from SQL
Ian Wootten
Watch →