Good evening, everybody. Am I audible? Good evening, all, please. Thank you. Okay, so we are starting our class. Thank you. In the previous class, we have seen one of the most prominent and famous neural network model in early days, that was the perceptron. And it was introduced by the Frank Rosenblatt. And further, carefully improved by the Minsky and Pepper. So these three scientists or authors in the area of neural network are very famous. Everybody should know it. And we know the initial neural network models were the Macluck-Pitts MCP model and Hebb's learning rule. Just for a knowledge purpose, it is not in our syllabus. and the perceptron is inspired or based on the MCP and Hebb's learning rule and we have seen the perceptron is the first neural network model that in real sense offer both forward propagation and the back propagation. It is used for only binary classification. It shows first time in real sense the iterative weight adjustment method and we have also experienced two versions of perceptron. First is based on the sine and step activation function and second was bipolar activation function or sine activation function. Initial perceptron having only single layer, that's we call it single layer perceptron. Later, since single layer perceptron only able to solve the linear separable problem and later it was modified and introduced a multi-layer perceptron. And here it offers the numeric weight and typical learning and training process. We have also seen some limitations of the perceptron. The first was like it is only used for classification, not for regression. And in the classification, only for binary classification. Since it does not offer any continuous activation function, that's why it cannot use for the regression purpose. Although it was an iterative method, but it is not much adaptive. Why? Because it keep on updating the weight until all the data were classified correctly. So what is the meaning of that? If you remember or recall the previous class, the perceptron, the model either will give you 100% result or it will continue to never converge. So that was the biggest problem with the perceptron. It was just that we have revisited the previous class. So the next very basic neural network model was the withdrawal learning rule or withdrawal rule we call it. It is just an extension of perceptron but that extension is very fundamental and very impactful. It is a combination of Adeline, Delta rule, very famous rule and least mean square error. First time they have introduced how to use the least mean square error. I'm not going to discuss about the Adeline. It is not a part of our course. So let's directly jump on the delta rule. What is the delta rule? Here delta rule is a combination of two things. First, it offers the continuous activation function. It offers first time gradient descent for updating the weight as an optimizer. Because of these two improvements over the perceptron, it can be used for the regression problem. So everybody must remember it. These are the only the three big improvements or differences with the perceptron. First, it offers the continuous activation function that was not the case with the perceptron. it offers first time gradient descent as an optimizer. Gradient descent is used for update the weight and it is used for a regression progress. So here least mean square error if you remember our linear regression classes. So least mean square error was the method where we try to reduce the sum of square error to find the best weight line. So that is the concept first time used in the delta rule or withdrawal of learning rule. So just let me revisit it. So this is a whole process of training where the data set is given to the withdrawal of learning rule or the network. It will go to the forward propagation. Difference is here, we have a continuous activation functions like any continuous activation function like a sigmoid function 10H function, you can use it. Here we have not straightforward to calculate the error. Here we are using sum of a square error. That's why least mean square concept has been used. Once we have the error in the form of LMS, we can apply the gradient descent. It is a better way to update the weights in the right direction. So this is our concept of withdrawal of learning rule. So yeah, this is the most important part. If you look the weight update process in withdrawal of learning rule, the formula you will find it is exactly you have seen in the perceptron. You try to remember it. What was the way of updating the the weight if you remember. So, we have seen w new is equal to w old plus learning rate t minus o x. Yeah. Yes. Are you able to recall it? Are you able to recall it? Okay. So, the same formula, the same formula. Same formula we use in Withdraw of Learning Route. Withdraw of Learning Route. Then difference is where? Difference is here. That's important part. In Perceptron, it was the class level. It was the class level if you remember. Either 0 or 1. So that's why perceptron only used for the classification. But in here, in Winterhoff learning rule, it is a continuous number. It is a continuous number. It is not a class. That is a very big difference. So here, it may be just a hypothetical example. You want to predict the salary of a particular person okay so suppose here w new will be what w old plus alpha uh correct salary is suppose 500 and my model is predicting uh 200 like that okay yeah so if you minus it you may be thinking what is the problem to keep 300 as it is it is not a right way it is not an error Error means what? You have to apply the SSE. Then square it. Then apply the least mean square error function. Least mean square function will go to the gradient descent. So gradient descent we are not covering today. It is the responsibility of the gradient descent during the backpropagation to update the weight okay so that was the only the big difference between uh perceptron this is just for your reference i kept here the the weight update formula for the perceptron and and and and this is the weight update rule uh in the withdrawal of learning rule both are identical both are differences here it is used for the regression problem so here it it will not be either plus one or minus one or zero, as we have seen in the perceptron, it is a continuous number. So we have to use a different activation function, like a sigmoid. Most of the cases, we use a sigmoid activation function. So it is all about the withdrawal of learning rule, that is the crux of withdrawal of learning rule I have discussed over here. Is it clear to everybody? Else you can visit the books and any other sources for more details. Got it? So what is the benefit of withdrawal of learning rule over the perceptron? It tries to find out the best fit, best possible solution in that situation. It does not ask, either it will perfectly classify or give you 100% result or know any result. So it is really useful in the real life applications because in machine learning where we are applying, we just not expect any any perfect solution just in the given situation what is the best possible solution somebody can get it so we are the withdrawal of learning will fit over is it clear to everybody if yes then i can move for the next topic write in the chat box okay what is the doubt okay so can you please enable my not possible whatever the doubt you can write on the chat i can pick it up these are very fundamental and basic neural network model they are not considered as advanced model okay so like uh i have promised now i'm going to introduce uh natural language processing nlp because in your syllabus most of the experiment particularly the deep learning we have a two kind of model cnn based model and rnn based model okay There are various variants. Various variants means what? Like RNN itself is a model. LSTM. I will cover it. Encoder, decoder, transformer. Those experiment if you want to conduct a code, most of the applications are with related to the NLP or text. So if you don't have any fundamental idea about the NLP, you will feel a lot of difficulty during this phase. Natural language processing, I'm going to cover it. And another category of modern deep learning models are CNN and the GAN. They are basically work with the images. So most of the lab or coding classes, we are going to use the images in the case of CNN and the GAN or in the case of RNN, LSTM, encoder, decoder because they are the sequential model. They are the sequential model. So to make that background, I'm just starting today natural language processing. You cannot say NLP is a subset of the DL. NLP is a different domain where we use the DL, deep learning model, to solve the problem. so here if you say NLP NLP means we are going to deal with the text in NLP and we want to solve the main problem of the text by using the deep learning method or by using the ML method, that is the right way because people are heavily using deep learning ML in the NLP so there may be misunderstanding nlp is a part of deep learning no deep learning ml we apply in the text to to find the patterns and and some learning purpose so nlp is the data not area okay so nlp we are going to start be with me it's very interesting uh okay one minute a lot of questions will be there i will cover one by one okay so just look uh one of the application or or one one one application in the nlp the text summarization please remember that word so this is a real life example i have taken i suppose this is the gmail editor everybody you have uh you just type some sentences in the body of the email and then go back to the subject it start suggesting something title of the subject title of the email so what it is doing based on the content you have written it is summarizing the meaning of content and accordingly suggesting the subject of the email so what it is doing text summarization everybody experience this application of the nlp i think everybody so based on the sentences paragraph you have written it understand it, summarize it with the two or three words. So this is called text summarization. Again, the moment I change the body of the text, subject also change. This is another application, a very common like a text suggestion or sentence autocompletion. again for example the moment i have entered r or e then since it knows my way of writing the email and most what kind of words or sentences i am using in the last few days or few months based on that it starts suggesting the moment i entered re it's suggesting respected sir so this is called what text suggestion and sentence autocompletion another application of NLP like that it may be possible like you are writing not interested at then your model your application may suggest it at this time so people are using this sentence autocompletion also in various coding editor like maybe python maybe cc++ where you enter the code it starts adjusting uh uh uh uh something else or some some next uh the syntax you may be required to enter okay this is the language translation i think everybody familiar with it you just enter or or translate the sentences written in one language to another language. This is the one of the greatest application in the natural language processing. Okay, language transfer. Everybody know it, everybody know it. Okay, then yeah, this is one application that may be new for you, name entity recognition, NER, but it's very famous, very famous. So what is happening over here, if If you will be given a paragraph or one page write-up, so you may have a one model, deep learning model or machine learning model that will scan your document or paragraph line by line and it finds some entity against it was already trained, understand those entity for that your model already trained, it easily recognize it. Like LOC, understand LOC means location. So wherever locations are given in the text, it can capture it and put a tag it is a location. Similarly there may be organization like IBM, like Watson, like a TCS, any such name comes in a text, it capture it and understand that these are the entity. Entity which category? Organization. Similarly, prices. Similarly, dates. Where are the dates written? So, this entity name, entity recognition heavily we use in medical field for this example. Yeah. So, suppose a lot of documents are given to you and you have a data set of medical related documents and you want to classify them, you want to search them. So document can be classified based on the symptoms. The symptoms is an entity. Okay, symptoms is an entity. So based on what kind of most frequent symptoms are being discussed in the document based on that you can retrieve it based on the disease. So, disease is a one entity. Your model may be trained to recognize the diseases, name of the diseases from the document. Similarly, it can be syntax, it can be chemical, it can be anything. So, since it is not a core course of NLP, so I am not going in detail. Just for interesting purpose, I have introduced some of the various common applications of NLP. Next one, maybe I think everybody already very much familiar with sentiment analysis. Okay, feedback analysis. Okay, review analysis. All such comes under the national language processing. Use the application, use the application. The sky is the limit. Okay, Google search is also national language processing. Whenever you search something in the Google, it comes under the national language processing or text minor. So there are huge applications of NLP or huge demand in the market. So few applications I have just discussed just for attracting your attention. So let's have some couple of definitions or sentences I got it from the internet. What is a natural language processing? So natural language processing is nothing but is a process of extracting useful information. and useful or non-trivial pattern means useful pattern from large volume of text and we know the text is unstructured data. NLP the area deep learning is a technique. Okay and like an image you are asking a question what is the difference between images and deep learning. Saurabh got it? Yeah, so NLP means where you are going to use the dataset, text only, only text. I think now everybody must be clear, NLP is a big area where we deal with the text, technique, maybe deep learning, maybe machine learning. Okay, so yeah, thank you. So here NLP is the process of extracting useful information and non-trivial pattern from the large volume of text. Intentionally, text is written. Okay, so text is unstructured data. Another bullet point says that NLP deal with specifically with unstructured text data. It extracts the useful information inside from the large amount of data. Both the sentences are same. What kind of text data? You may be worried about websites, all our text data, blogs, social media, networks, emails, documents, feedback, review, survey, logs, a lot of things. Today we are full of, surrounded by the text data only. Okay. So since we have a lot of text data and it's really difficult to understand for a machine to the text data, that's why this area become more dominant and and more boom in the field because things doesn't work easily with the text okay so you may be uh okay and again this is the some of the application already discussed about an lp like a text summarization text categorization text clustering language translation ner information retrieval searching text understanding sentiment analysis very very very list is very vast okay but big question is that sir like uh we have a data set of images or videos and we have a data set of iot or you can the csv data set and we have another category of data text data so why a big boom and and another dedicated subject like nlp and text mining how many of you listen this word text mining you can consider both of them in in in one family or just a beginning purpose both are same text mining very famous older term it is more older term actually if people are using from 1990s have you listened this word text mining yes so consider text mining and lp both are the same family so great so what is the important thing where text become challenging okay since like the data uh like uh like a numerical data okay like numerical data like image data okay like a video data okay like a CSV data these data we can directly we can directly give to ML or DL model that's important distinction but if you have a text data there are two big problem text data so any ml or dl model what they can understand they understand only this is thumb rule any dl or ml model understand only in the numerical data agree numerical data understand that part either it is an image or video or or any data it contain only the number everybody agree it contain only the numbers because image is represented with the with the matrix matrix have a pixel pixel have a sub number what it yeah so ml dl are designed or by default they have only one choice you can feed only numerical data then they can work on it but text data is not a numerical data got it okay pattern recognition basically different uh uh aspect where it more about the images and and the video in the images we try to uh understand the pattern it is more a pattern recognition is more about the computer vision more about the images where you deal with the image and video okay so the problem is what okay so uh uh nlp or uk's nlp like uh yeah what i want to say people have started to work with the text around 70 years back so initially there were rule-based nlp and we call it symbolic nlp where it was started 50s and it continued to 90s where text were handled by specifying the rules but as you know the text or sentences and paragraph and you cannot understand you cannot process with the list of rule so so they they were have a limited applications then people people started applying the machine learning for the text handling. We call that part statistical NLP. So it is hard. Date is written like 90 to 2010. You should not consider it. It is flexible. Still people today are trying to apply the ML on the text. Okay. But since text is a very complex structure. You can share your feeling by using different sentences. You can write one sentence in 100 ways. So it is a very dynamic or random way of making the sentences to convey the same meaning. So machine learning also have a limited power or limited strength as shown with the text data but the moment you start applying the neural network because of property we have seen many property it's able to handle a variety of data and able to solve the complex problem it become more successful with the text data so that's why most of the model people nowadays we are using in the NLP are based on the neural network. But ML also people are applying. So yeah. So what is the problem like we have seen in the text data? We cannot feed the data directly to the machine learning or any deep learning method because those cannot understand the text data. So what we require, very important part, we require to convert the text data into the number that that that's a very important part so we call it the text vectorization this process word embedding a lot of names are there i i dance your people have listened to this name word embedding this is a new term it is nothing but a simply a text vectorization okay so let me uh make it clear again so whenever okay come here understand this this training or part of applying mldl in the text it is a bit different in normal cases how as we know the text is the data set is given to you we you cannot feed to the model directly so in between what you require you You need to convert your text into the numeric number, text into the numeric number. So this is called feature extractor or this text will be represented in the form of vector. Vectors contain the numeric number. So this is the must part, everybody please understand in NLP or text mining, whatever the text will be given to you you need to convert must process convert into the equivalent numeric numeric representation this process this is the process understand this is the process the process we call very famous more the most famous term is a text vectorization text vectorization okay yes reg also use you are correctly reg also use the text vectorization word embedding you are correct word embedding okay feature extraction feature extraction many many names are there i have mentioned already i think yeah feature extraction also called as a text vectorization text extraction text vectorization bag of word many names are there yes we saw meaningful dense vector means what here the same thing we are doing whatever the text will be given to you whatever the text will be given to you you need to convert into the numeric representation It is nothing but it will be either matrix or single row of matrix, we call it a vector. Now, you may be able to connect it, it is a word embedding, it is a text vectorization. Just converting your text into the vector. This is the most important part. Why? Because once you convert text into the vector, it goes to the ML or DL model for the training purpose. So success of understanding of your model about the text is depend on what, how efficiently you have converted your text into the vector. So this process has become important. Because if you lose here, if you are not carefully transforming all the meaning of text into the vector if you are losing something ultimate your model will not learn all the things is it clear that's why in nlp this this state is become very important not training here in nlp you don't need to work over here because there are already very famous models you need to work over over here whole research and everything is here nlp okay in nlp if i say if i try to say nlp whatever the project you will do 90 percent work is on text vectorization then 10 percent about the modeling okay you might have listened the model like encoder decoder encoder decoder but transformer what they are doing they are doing only first they convert everything in better way to the vector only everybody do like that so people get confused they are core deep learning model yes they are deep learning model but these deep learning model first carefully convert text into the vector okay so the training process in testing same algorithm of text vectorization you have to apply in the real life text data will be given to you first you need to convert into the numeric representation the same method same size you have to use you cannot say the vector size in training was different and the vector size in the testing is different no this should be identical so what is the underlying method you have applied for text vectorization during the training same method you have to use during the testing is it clear great so yeah look somebody was asking i have just listed down natural language processing text vectorization or word embedding there are many vertical one category is deterministic based representation. Deterministic word embedding, predictive word embedding and hybrid. Deterministic word embedding based on the count and frequency and methods are one-hot encoding, I will cover it. Bag of word, I will cover it. Ngram, I will cover it. TF-IDF, I will cover it. Then there are modern and advanced word embedding and text vectorization methods like word2vec, fast text and one hybrid method that is a Glove. So I'm damn sure most of you have listened to such names like a One-Hot Encoding, Bag of Word, Ngram, DFIDF or Word2Vec and FastText. Okay? So this is the high-level understanding I have given to you. In my course, I'm just additional courses covering to introducing this vectorization method. because in your course it is written a lot of case study in NLP, practicals or coding in NLP. But what is the minimum knowledge is required so that you can run the code, I need to cover additionally. So what we are going to do? A lot of text vectorization methods are given these are very standard these are very advanced so i have a plan to cover the first four text vectorization method in this course in the next course maybe in elective or compulsory next semester there may be a hundred percent there will be an lp course where you will be exposed in detailed algorithms and methods yes more resources will be required that's why transformer, board, encoder, decoder require a lot of computational power. You are correct. Yeah, you will have, you must have NLP as elective. So you'll enjoy at that time, fundamental time covering. Okay, so before jump into the detailed discussion about NLP, there are some terms that heavily people are using, you need to understand it. So let me have a look on one by one corpus. So, the total number of words present in the whole data set is known as a corpus. Whole data set means what? For example, you have a data set of SMS, so you have a lot of SMS, SMS to dot dot dot. You have a 10,000 SMS of data set. Okay, so total number of words, whole dataset, total number of words, we call corpus. Any confusion? Very simple. Then we have a next word, vocabulary, total number of unique words. Difference is here what? Unique word. So, whatever the corpus, you just filter out or delete the duplicate word, just filter out unique words. This list we call it vocabularly. Next terminology is very simple. Document. Each individual record we call it document. So since document is misleading word and in NLP it has a different meaning. So each individual record. So this is one record SMS. this SMS may have 10 lines. Agree? So, this is a one document. This SMS may have only two lines complete. This is the one document. So, each individual record is a document. Document is clear to everybody. I don't need to discuss about what is the meaning of word okay so starting with our first method i am going to cover it that is a one hot encoding first vectorization method very simple very simple but it required to understand one hot encoding means converting your words of your document into the m dimensional binary vector or matrix important part you should notice it here binary binary means what binary means that that vector or matrix will contain either zero or either one okay either zero or either one okay so let me explain this working with very interesting example suppose i have a data set like i Please focus here. It is very interesting. Numerically, I am going to solve the working of one-hot encoding. I love movie. This is the first sentence. Another sentence in the data set, movies are good. I was good movie. So, just for understanding purpose these are the dataset you have given. So, what will be the corpus? Corpus means combination of everything like I, love, movie, movie, are, good, I, was, good, movie, okay. Comma means what? Now these independent terms in the corpus, the list of what means they are independent. The sequence does not matter. So whenever you put term in the corpus, sequence does not matter in any random way you can arrange it. It's very important. It's very important property. Please remember it. Since it is a set, it just contain the list of what in the whole data set sequence does not matter in any way you can arrange it. Got it? Now tell me the corpus you have. Now what is the vocabulary? Vocabulary will be what? Let me right here, I love movie, I love movie, movie are, are good, are good, I good movie was. Am I correct? If you check it, am I correct? I have created a unique word. Assume that this is a matrix and these are the columns. That's why we call it feature. These are the columns. Agree? These are the columns. This is the matrix. Is it clear up to this moment? now what was the first sentence i love movie now here what you have to fill if term is present in any of the column then i will mark as a one love second feature yes it is present one movies present the sentence one it is absent it is absent it is absent so this is what i am going to do converting this input i love movie the equivalent vector so now if i need to feed i love movie in any deep learning model What I need to feed? I will feed its numeric representation only. Numeric representation is what? 11100. Yes. Is it clear to everybody now? Similarly, another sentence, Movie was good. So, 0, 0, 1, 0. Yes. Important part. Here you can also change the sequence. it doesn't require to put it in any order. Whatever order you want, you can keep it here. But once you put into the column, later you cannot change it. Is it clear? So these are the terms column in any random order. You can arrange in the matrix. Once you have arranged, you should not change it. Such thing you can do anyway. It doesn't matter. Either one by one or other parallelly. it will not make any difference. Okay, Sachin? Because they are independent. These are independent vectors. So, parallelly you can do it. Important part, in real life, it is a valid, but normally we don't do it. This is not a right method. We actually convert, not sentence, we convert word. Like again, let me explain with the example. same matrix, it is identical. I, love, movie, are good, worst, are good, worst. Actually we convert word level not token level. So suppose we convert first I. So it is it is row and column both are same i love movie like that you can expand it so row and column both are same agree so we convert i like this one zero zero zero zero zero love means zero one zero zero zero zero movie means zero zero one zero zero zero got it so suppose i have a sentence i love movie so then its equivalent will be what i one zero zero zero zero zero then love will be zero one yes like that it in real sense, we do like that. Got it? You will find any book, real implementation. So, this is the more better way to convert your sentences into the vector. Got it? Because if you have a equivalent term here, then you can make many sentences. Suppose there is a new sentence, I love only. I love only. So new sentences come. It was not in data set, suppose, here. So if you are using the first method, you will see these sentences are converted into the vector. We have a new one. We cannot do it. But if you have an individual word, equal numeric value, any kind of sentence you can convert into the vector. Yes. So you are correct. Is it clear to everybody? Great. so now let's say these are the examples have given advantage of this method is what it is very intuitive it is very easy to implement but a lot of limitations. Sparsity means what in the real life example you think about a thing about YouTube. YouTube have review or feedback, review comments or you can see in the tutor example of tutor. One year data set, one year data set. Okay, you think, you tell me and suppose data set is only English, only English. What is the size of vocabulary? You tell me, just an idea. It's a very interesting discussion. In Tutor dataset, one year of data all over the world and all the tweets are in the English, what will be the size of the vocabulary? If I say 20K, it's normal, total number of unique words. It contains symbols, emojis, question mark, add the rate, everything comes as a word. So what will be the size of the matrix, you tell me? 1 to 20k. How many columns will live there? 1 to 20k. What is the average size of tweet? You tell me. Average size of tweet? 30? 30 words? Or maybe like 20 words? Hardly. So out of 20,000 features only 20 places have a some word some some some numeric number otherwise it contains zero zero zero zero zero zero zero zero so if i say 99 percent places places equal to zero am i correct everybody is correct with this yeah so it is it is it will create a sparse matrix that is one of the biggest problems. And another very famous problem in NLP, not in one-hot encoding, out of vocabulary. Very famous term, OOV problem. People ask a lot of questions, OOV problem. What is this? Out of vocabulary. So I mean to say, suppose this is your matrix. We have terms A, B, C, D, E, F. These are the features and term. Agree? Anything. During the real-time use or during the testing, some new term appear. Some new term, very, very new or fresh term that was not in training detail. Then what happened? This new term is suppose Z. So your method will try to find out where is the Z. It will not be part of your matrix feature. So it is an out of vocabulary problem. It may occur or not. Any new term, any new word during the testing, it may come sometime. People may use very unique words, symbol, text, anything and you will not find that equivalent numeric representation in your matrix so you will not be able to handle such words everybody got it this is called oov problem i think everybody agrees since we does not capture the order or sequence of the words so we will lose the cementing meaning we by by seeing the vector you cannot understanding what is the sentence so it does not capture the cementing meaning. Everybody got it? Great. Now we have a second method, bag of word and bound. It's used for text vectorization. There is only one line difference between one hot encoding. One hot encoding, what it does, one hot encoding. It captures the answer either 0 or 1. It does not capture the count. Suppose in sentence it is written, I watch movie dot. It was good movie. So movie terms appear twice in this sentence. But in one order encoding means it will say yes it is present in the sentence or not. It does not counted. Is it clear? So, it will be more useful if you are counting the number of occurrence or frequency of turn. It will be useful or not. It will be good or not for model training purpose. Yes. So, that is the only one line difference. The back of word count the occurrence of words within the document. That is a difference only. Okay. So look, this is one example. These are the three sentences. Small dog, cute, cute cat, cute dog. These sentences first you need to create other method, other process is same. This is the list of vocabulary. But here what you are maintaining whether the sentence is present yes or no plus number of occurrence of each term. So in the second term cute cute appear twice that's why the two. This is the only one difference with one-hot encoding and bag of words. Here you can maintain the count or frequency also. So what is the difference between count and frequency? Count means only the number of time each word appear. Frequency means count, you need to divide with the total number of words in the document. Is it clear the difference between count and frequency? So in bow, it is not necessary, it is non-necessary matrix will be binary. Got it? It may or may not be. It may or may not. So another difference is like advantages and disadvantages are same. It also suffer from the sparsity, it also suffer from the out of vocabulary problem, it also suffer from losing the cementing meaning. Both are other other other other property and other concept offset. Is it clear to everybody? Great. So now moving to the next part, we are going to discuss about the next vectorization method. Yeah. So we have covered one-hot encoding. We have covered bag of word. Now we'll try to cover n-gram and tf-idf. Very interesting. So what is meaning of n-gram? So n-gram can be defined as the continuous sequence of please focus on highlighted term continuous sequence of n items if you say the item tokens word all are the same meaning do not try to develop a different meaning of tokens tokens words item both are same all are same it should be continuous and any the size that you can define it For example, I have a sentence, I love reading history books and watching documentaries. This is the one input sentence. So if n is equal to one, we call it one gram. So one gram can be what? Size of token should be exactly one. So first word, independent, I, love, reading, history, books, each individual word will be token as a independent gram or token or item. So it is a one. So size of each gram will be one. Size of each gram will be one. In the moment I say, no, no, sir, I have n is equal to two. So two gram. or by gram. So what is the meaning of that? Now each gram size should be two. So first two token I have taken I love. Please focus here. What people will do? Second token they will understand since they have taken I love, the next token will be reading history. Not like that. You have to move one bit at a time. So first token, your first two gram was I love, then love reading, then love reading, then reading history, then reading history and so on. Got it now? Similarly, trigram. I love reading, love reading history like that. important discussion. Suppose I love book reading and I have a bigram I love. Then love book. there is no comma. Then book reading. Is it clear? So this is one item together. This is another item. This is another item. So you can arrange them in any order. Very important discussion. But within the gram, this is maintained. Here we maintain the order. So, what I want to say, within gram, must maintain order. Means, in this gram, I love. You cannot. So, love, I is wrong. You cannot do it. But, between gram, between gram, no order. No. order. So, this is one gram, this is one, this is another. You can, you can, these, these three, you can arrange in any way. Got it? Is it clear to everybody? Great. So, Sachin, wait a minute, I will do it. I will explain. Your answer, I will explain. So, this is again a summary. So, one gram, we, sometimes we call it unigram, then bigram, then trigram. Got it? So, yes, let me explain with, yeah, so what is the one of the very basic application of Ngram is sentence autocompletion, sentence autocompletion. Nowadays, we are not using ngram because we have a more powerful application but ngram is one of the oldest method people use for the sentence autocommission. Why? Suppose I love this is the token, this is gram, very frequently appear in your data set. So what your model will learn? will learn whenever I appear, love also appear together. So whenever you enter the I, your model may suggest love may be the next word. Is it clear? That is a one of the early days application of ngram. Okay. So suppose I love is a bigram and I love bigram appear very frequently in your data said very frequently. So you can learn means probability of love comes with I. I is very high. So whenever you enter the high I your model may predict the next word should be love. Very simple application, very simple application sentence autocompletion. Okay, so same thing I have explained, suppose these are the two words, suppose this is I, this is love, they come together most of the time, whenever w2 appear, how many times with w2, w1 also appear. If it is a higher number, means they have a very strong association between these two words. Agree? example suppose these sentence are given thank you very much for the help i really appreciate your help excuse me like that and if you do it how many times really like comes so really like comes only really like once but how many time really comes one two three so it is a one five 3. So, there is a 33% probability. If really come, like also come. But suppose in some cases, this probability is 90%, 95%, 80% means they have very strong relationship between these two words. So, this relationship we can use for predicting the word means sentence auto-completion. this idea is clear to everybody great so yeah a lot of applications of ngram I have written okay so this this con this concept we call is context context means what the relationship between the words how these two terms are related we call is context context is very important term context. Context means we start understanding the meaning of sentence. We start understanding the meaning of sentence. This is we call it context. I will pick it up in detail during the RNN discussion. What is the meaning of context? Okay, right now I am not probing. So, use of NLP I have written here, it somehow captures the context of the sentences. It improves the language modeling because it learns the association between the words, how the words are formed, how the words appear together. It learns text prediction means sentence autocompletion. It is also used in information retrieval as a basic application, as a feature extraction like we are studying right now and in many cases it is used in NLP, like Ngram. In many cases, there is one more type of Ngram. So we know we have already seen unigram, bigram, trigram, we have already seen there may be more. N is equal to 4, 5, 6. Technically N can be any number. There is a concept of character n-gram. So till this moment, we were focusing on individual word. But you can also create n-gram based on the character. So suppose individual word NLP is given. So if N is equal to 1, character 1 gram. So each individual character may become a gram. NLP, character by gram, two character at a time, NL or LP. NLP completely is a trigram. So there is a one variant of Ngram is what? Character Ngram. So character level is split also possible. Character level understanding also possible. Okay. It is clear. Character n-gram. Now come to the question. How we can use for vectorization. Somebody have asked the question. Like, okay, we have now very good understanding the n-gram. How we can use for the text vectorization. that was the question I think everybody agree so let me cover it suppose this is the sentence given to you machine learning is powerful okay so individual terms are what machine like it is a vocabulary you can say or or or or or corpus machine learning is power so if n is equal to 1 then it will behave like a one-hot encoding. Everybody agree? Each individual term will become feature in the matrix. Am I correct? If n is equal to 1, then n gram will behave like a exactly one-hot encoding. Got it? So I will not cover with n is equal to 1. Let's by gram n is equal to 2 so n is equal to 2 means we have now two words in a sequence machine learning learning is is powerful okay so suppose yeah so what we will do just very simple understanding the feature will become the gram so machine learning together will become one feature learning is become the another feature, is powerful become the another feature. Or in the given sentence, if that gram exactly in the same sequence appear in the sentence, I will say one, one, one otherwise. Got it? So that is a one difference between one hot encoding and n-gram, just feature representation change. In one gram, each individual word is a feature. Here, gram is a feature. It can be a trigram. It can be a bigram. So this gram should appear exactly in the same sequence in the given sentence. Then I will say yes, otherwise no. Yes, Saurabh, answer is yes. It will be sparse matrix. Up to this moment, things are very much clear to everybody. Yes, you can do it. Sentence level, exactly, Saurabh, either sentence level you can convert or better idea is what? First, you convert gram level encoding means rows and column will be equal convert each gram with numerical number then go for the sentence level conversion as we have seen in the one hot encoding. Is it clear? So the simple example I have made here better way is what? You gram level vectorization you can apply first then sentence level. Okay so yeah so here another example I have given you can I will upload that document you can refer it. Now we have a next method and the last vectorization method is what TF-IDF. Very famous, people ask a lot of questions. Turn frequency and inverse turn frequency. TF means turn frequency, IDF means inverse turn frequency. So here for TF-IDF you need to understand some important terms like what do you mean by turn frequency, document frequency, inverse document frequency. So t here stands for turn frequency, d stands for document frequency and d stands for number of corpus. So let me explain this everything with some example it will be helpful. Turn frequency in document d means in one record like complete sms, complete tweet. the frequency represents the number of instances of a given word t. I mean to say we can see that it becomes more relevant when words appear in the text. So what we will do in a given document d, how many times the term t appears divided by total number of words in document d. So turn frequency, how to represent turn frequency against what term, which word, which document. So you need to scan that document completely. Find out number of count of that term t divided by the size of that document. So this is called turn frequency. Okay, just let me have one example. Suppose understand about a google search. Just an idea about the google search. You have entered the term data science. Data science. This is the term you have entered and search it. And suppose for simplicity, we have three documents. There will be a lot of documents, a lot of website, a lot of documents in the internet and you calculate the turn frequency of data science. Suppose it was 15%. Turn frequency of data signs here 0.7%. Turn frequency of here 0.3%. Which document is more relevant and may be more useful for you? Once google search it, suppose there are ABCs. So term frequencies talk about means what? how term is related, how strongly related, how the term tree is related with the document D. Got it? That is use of term frequency. People use this TFID of concept, TFID of concept to compare two documents. Compare two documents. This area is called document similarity. You might have listened this word document similarity to pdf file how they are how much they are similar so people use the concept of tfid more common terms with the higher frequency means documents are more similar okay next term is what document frequency it is a bit different it is a bit different. People are very much confused with term frequency in a document frequency. This is very similar to the term frequency. The only difference is that term frequency is a frequency count for a term t in a document where document frequency is the occurrence of term t in the set of document. Another way if I try to say document frequency is the number of documents in which the word term is present. So, term frequency means a single document will be given to you. Single document. Single document. And term x. So, how many times this term x appear? That is the area of term frequency. Okay. Document frequency means what? A lot of document will be given to you. Like document D1, document D2, document D3, document D4, document D2. Now we have term x. Unity found out term x is present here. Term x present here. Term present is here. So now 3 divided by n. This is document frequency. okay. So, occurrence of term t in the document. Document frequency means occurrence of term t divided by total number of document. This is called document frequency. Okay. There is another concept of inverse document frequency. It's very interesting. IDF. DF, we understood IDF. Let me give the hint answer. Now I have a question for you. What do you will prefer? What is the more useful? Bigger or larger document frequency is useful or not? If any term like a data science, data is a term, document frequency is larger size. It's a big number. Do you want it? In another way, bigger document frequency of a term is useful or important. Are you agree? Bigger document frequency of a term is important or useful. Okay, now tell me. Suppose this is the document, this is the document, this is the document. Agree? It is about the data science. It is about the document data science. Now you tell me which case document frequency will be highest. Just an idea. I have option one an option to document frequency of data. These all are data science related documentary. Document frequency of is, which will be higher. So is it important? It is important, is an important term in the document? It is going to help you for any decision making? No. Now, sometime, the idea, rare term is sometimes important, rare term, rare term means the term that appear infrequently but may be important, but may be important, agree? Suppose you are scanning a document, this and this. Some document, we find the term bomb. It will attract more attention. Terrorist bomb and other kind of virus. They appear rarely, but more important for some time decision making. Okay. So this is the idea we implement in inverse document frequency. What it says is that while computing the term frequency, all the terms are considered equally important. Some terms like is, r, m that appear very frequently and it can be misleading. So what I want? I want to reduce or diminish the importance of very frequent terms like stopwatch. Those terms are very much frequently appear in all the documents, like three documents, this, this, this. This document has is, are, am many times. This document also has is, are, am many times. Is, are, am many times. So according to this concept, all the three documents are same. So it can mislead. So what we want? We want just opposite. We want to calculate. We want to give the more important about the rare terms. So that's why this formula appears. Inverse document frequency of term t will be log n upon document frequency of that term. So there are two formulas sometimes in denominator we do plus one, sometimes we don't. So this is a more versatile formula and means number of document. So if any of the document having highest or larger term frequency and it is a denominator to ultimate, it is going to reduce it. Some term that document frequency is very less means it is going to make the overall term bigger. So it's just to do the opposite impact. Rear term having a bigger IDF, very frequently term have a lower IDF. Is it clear to everybody? Okay, so in the next class I will take the example. Okay, let me finish here only. So TF-IDF means term frequency multiplied by inverse document frequency. So once you do it, whatever the value you will get it, you will call the term frequency of term T with respect to the document D. So this is a complete formula. People call it TF-IDF. tf idf means tf multiply idf i have covered tf separately i have covered the idf separately and you multiply it whatever you will get it will be called it tf idf i will continue hardly next five minutes i will take but in the next class to cover it uh uh to finish it tf idf Okay, vectorization, document similarity, I have given a cast. This TF-IDF also used for the text vectorization. This is topic I am covering, TF-IDF. It used for vectorization. It used for document searching, document searching, it used for check the similarity, document similarity. Many applications are there. google it okay so thank you for today we will meet again in the next week