All right, let's do this.
Let's begin our implementation of the natural language processing.
Well, you know, branch of machine learning, but more.
Specifically.
Of an NLP model made for sentiment analysis.
All right.
So as usual, we're going to start as much efficiently as we can.
We're going to use our data preprocessing template.
Which I've of course prepared.
For this implementation
which contains, you know, the codes to import the libraries and import.
The dataset.
So let's quickly start with the libraries.
Here I'm going to take them.
I'm going to paste. That right.
Here in a new. Code cell.
To indeed import the essential libraries.
You know, just in case we need them.
It doesn't mean that we will necessarily.
Use. All of them, but at least we have them in case we need them.
Okay.
Then importing the data.
Set let's create a new code cell.
And now according to you. Do I have to take.
All the lines of code here or just this one to get.
The data set?
Well, as you might guess, now we're going to do some different kind
of data preprocessing.
And therefore.
We'll just take.
This line of code to indeed import the reviews inside.
Still a data set variable.
But then you will see.
That there. Will be a certain work needed.
Before creating these two features.
We will indeed create these two features at some point.
You know the matrix of features and the dependent variable, but not now.
This is too. Early.
We will have to clean the text first and prepare the bag of words model.
And in fact.
We will create these two.
Entities a matrix of features and a dependent variable vector in the.
Cell where we create the bag of.
Words model.
Okay. So let's just.
Take this for now the. Data set.
And back into our NLP implementation.
Let's paste that right here and now.
Indeed we have to adapt this a little.
Because now we're not dealing with a.
CSV file.
We're dealing with a. TSB file where the feature.
Is meaning the text and the binary variable 0 or 1.
Are separated by a. Tab instead of a comma.
So first thing.
First, let's replace this data set by the.
Right name.
You notice that I even included the extension because we'll have to change it.
So the name of. Our data set.
Let's have a look.
Again.
Is Restaurant Reviews dot CSV.
All right.
So that's exactly what we'll replace here.
Restaurant underscore reviews
dot t test v okay.
And now since it is a.
TSV we'll have to add.
Some extra parameters. To specify.
That indeed we're dealing with a T as we found instead of a comma.
Separated value file CSV.
All right.
And the way to. Do this is just to add.
One parameter. Here, which is. Delimiter.
All right.
For which the default value is actually.
The comma, meaning.
That the default data set. That we can import.
With this read underscore CSV is indeed CSV.
But you know, we can also.
Use this read.
Underscore CSV function to import.
A TSV. File. And that's exactly.
What we're about to. Do now.
But the way to specify. That we're dealing with a.
TSC file is to.
Enter the following. Value for this. Delimiter.
Parameter, which is in quotes.
This slash here backslash. N. T.
All right. That's the value. Of the delimiter.
You should enter to.
Specify that your data set is a TSC file.
But then that's not all.
We need to add one final parameter.
Very important one when you're working with text
I'm going to show you something now in not this.
Data set.
Because we couldn't see the. Whole reviews.
But I'm going to show you the whole data set inside the folder machine learning
data set, which you could download once again in the article.
Right before this tutorial. So let's. Open it.
Let's go into part seven NLP, then NLP again and Python.
And that's the whole data set.
So I'm on Mac here. So I'm going to open it.
With a classic text editor like text edit.
Perfect.
We just need to have a look at the text quickly.
So there we go.
And now I'm just going to do a command or control F to find something.
Which is a double quotes just like that okay.
And as we see we. Can see that we have many.
Double quotes. Within the. Text. All right.
And in order to.
Process this the right.
Way, you know, when our machinery models learn how to.
Read text, well, we'll have to say to.
Our model to ignore. The double quotes.
Otherwise, you know, if you don't do it, this can cause some processing
or splicing errors
which you want to avoid, you know, because this can lead to an execution error.
So I always recommend to.
Add this. Quoting parameter and set its.
Value to three.
Which means actually no quotes or, you know, ignore the quotes
so that indeed you can be free from processing errors.
You can see there are many quotes, right?
So we're.
Just going to ignore all of them as if, you know,
they're just some different characters in the.
Text.
All right.
So that's all I wanted to show you.
So now let's close. This.
And let's go back to our implementation.
And to add this final parameter we need to add here quoting equals.
And the value of this quoting parameter to ignore all the double quotes is three.
All right.
And now perfect.
That's how.
You import.
Correctly a TSV file which should.
Be the format of,
you know, a data set separating text and a binary outcome like zero one.
That's the classic way to proceed.
With sentiment analysis.
So there we go.
Well, actually let's import the data set to make sure.
Everything's all right.
So we're going to click. This folder here.
Then it's going to take a little time.
You know a few seconds to connect this notebook
to a runtime to enable file browsing.
But in a second.
We should see that upload.
Button here to indeed upload.
There we go that data set.
So let's click it.
And now please find your machine learning A to Z folder on your machine
which you had to download
either in the previous tutorial or at the beginning of each section.
So now let's go inside.
Let's go once again into part seven Natural Language Processing.
Then this section, then Python, and then Restaurant.
Reviews dot CSV.
Let's click open. Let's click okay.
And now we're going to.
Have the data.
Set inside the notebook.
All right. Perfect.
So now let's run the cells.
First this cell where.
We import. The libraries.
So simple one.
And now this cell where we import.
The data set.
Let's do this. Let's make sure everything goes well.
And there we go.
Now we have. The data set ready.
So that means we're ready for the next step.
Cleaning the text.
That's an essential step in natural language processing.
I will show you all the techniques to make your text as clean as possible.
And we will do. All this. In the next tutorial.
Until then, enjoy machine learning.