So let us begin with the solution for this particular problem.
So in this problem, we have a very highly imbalanced data that there's a lot of transactions are for
the normal actions and very few transactions are pressing.
But we are trying to focus on different transaction detection.
We want to find out the fraud immediately.
And that is the reason why we will be focusing towards the more sensitivity and precision in this particular
implementation.
I will be using this.
You can use any of the reboarded.
You can stack algorithms together.
The process would remain the same.
You just need to try different legal teams, compare them, find out which algorithm was the best,
and then find you on that particular and got.
So here we import the required libraries and after importing those libraries, we see the effect here
that the site contains column names as we run the three and so on.
So we don't really know which of variable depicts.
What about the transaction?
We just know that these are the we will only have certain values associated with that.
And you can see these values are also skilled in nature.
So we cannot determine anything specific from that, from the top level, at least have a few columns
as dying among them, plus classes that are variable that we have and the amount in the amount of praise
for which the transaction has happened or something of that.
Here we have the value.
So time is of the transcontinental values.
Other than that, all of the values are usually ranging from a negative, some negative value minus
five to some positive values of five 10.
So these are basically they knew from minus two plus then.
So I feel that these are actually already standardized in nature.
So we don't need to perform any skilling in this particular dataset.
Now, if you see this data, so we have zero point two percent for transactions and ninety nine point
eight percent transactions are genuine in nature.
A lot of the time to see if there is any particular named associated with the time it set, so we are
plotting time.
So here we have the transaction and this is the time which we have.
So based on the time you can see these are the genuine transactions and these are the transactions.
So you can see there are specific spikes in the transactions and they occur immediately on the lower
side.
So they literally happen in a particular point of time.
Only these transactions are more than enough.
So the time feature shows that the rate of transaction is picking up during the day, but the number
of transactions have almost similar dependence on time of the day.
What would the classes, what would the classes of this bring down and going up, then going down and
going up, similarly, down and up and down.
So the trend remains the same, but during the day, the number of transactions increased.
OK, so this feature does not give much predictive value to us, but we based our leader so far.
No, we will drop the dime from our particular deposit and keep only the name as one of the features.
Next, what we do is we will check the feature amount.
So for a moment you can see the genuine transactions arranging for a higher value as well.
But for different transactions, they are actually for less than a month or so, the transaction occurred
more number of small transactions, small amount transactions.
So this shows that oil transaction amount greater than 10000 are genuine class only.
All right.
Also, this Amand feature is not on some scale as Principal Confidential will standardize the value
of a feature using this time scale, because this is the only goal which was not standardized in nature,
along with so many days, this amount.
So we have standardized this amount volume and we have found out that the transactions are usually a
small little.
Next, we will check the coalition and shapes of 25 principal components, so for each feature, we
will be bringing the coalition for that.
So here we are flaunting the January antifraud transaction, the plot forward.
So if you see these a little reading, these are also kind of video.
So we are basically finding out what actually overlaps.
So for the features, we are the genuine and for transactions are almost overlapping like this one and
this one.
This shows that this feature is not much relevant to us because it is not giving any specific facts.
But when we see here, this shows that for a genuine transaction, this would be a little different
from the fraud transaction.
So we can see there is a slight difference between the types of transactions.
So we will keep only the features, which will give us some different back then.
So again, for this particular feature, you can see there is some difference in the back.
We will keep only those types of features.
So let's go further.
These are all different transactions so you can easily find out what is overlapping and what will happen
so far to some of the features, what the classes have similar distribution.
So we don't expect them to contribute towards classifying flavor of the month.
OK, so it is best to drop those and reduce the complexity and hence we will reduce the chances of opening
those and we will check the assumption and we will check also invalidate this thing again.
Actually, they have some importance or some input towards the classification.
So now we have brought certain volumes, certain features, and now we will split the methane doing
beauty that is 20 percent best and 80 percent bringing us in.
Now we have distributed and we have set a strike.
If they will do so, the strike, if we will delay, does what is it will basically give equal distribution.
So in my estimate that also there will be equal percentage of the frog transactions as it is in the
training business.
So if might open of for transactions, I assume then in the spring I told you there will be two percent
transaction and in the best details that we would do, pushing for transactions.
So here we have created one function which will give us the predictions in the form of a confusion matrix,
and this particular function will give us those false.
So now we are implementing because you need this and we are training the model in everything.
After training the model, you can make no different pieces.
So the first cases when we drop back again, we get the results out of it.
So this is what we get in the brain set.
This is a diffusion matrix.
Let's have a look at the U.S. media report so you can see that he is ninety six point three.
And let's look at the record, which is zero point eight four.
And you can see the precision is quite low.
And if one spot is already here, next is when they are dropping some of the principal components of
a job, similar distributions.
So then we have a look at this.
You can see the precision has improved, the precision has improved.
The precision was five percent, but now the precision is eight percent, which is not much of an improvement.
But still, there is a slight improvement.
If reporters have been pushing here, their goal was 10 percent.
So there is a slight improvement and accuracy is a little boy named it, which is just the same.
And we can see an improvement in the which is improvement here.
So here we have got some improvement.
Right.
So next, let us have a look.
I mean, drop some principal companies and also paint.
So we are dropping also in this case.
So what we see here is that equal school has improved, accuracy has improved.
If one school was zero point one five four and it is zero point one five percent, accuracy is zero
point ninety three for accuracy.
Still, the same precision is also the same.
So we can see that it's not helping us.
The damage that is not helping much to us.
So we will remove Tamaz with.
The next case is when we are dropping the principle of opening, dropping time and also the dropping
the skilled amount.
So now if they see the recall is zero point eight seven seven, it's still the same.
Precision is zero point.
If six improvement, then we have a Funspot zero point one five seven.
Still a little improvement.
The accuracy zero point nine need here.
Accuracy, two point ninety six zero point nine six one one here the in six zero point nine six one
three.
Not much difference, but maybe a little bit.
So we can see case for gives us a better model sensitivity and precision as compared to this one.
So dropping some of the redundancy just will help us.
Right.
So this is the improved one.
So here we can see that we have got a good result out of this entire thing.
So what we can do is we can simply, again, train this and then the logic of it.
So when we do it, check again, we define definers.
But now let's check the score for logistic regression instead.
What logistic regression?
So we need logistic regression.
These are the results.
So you can see the ROIC has improved zero point nine seven, but the one has reduced and so has front
for every school has also improved, but the recall has declined.
So as we see by learning from fully imbalanced dataset, this Deepali logistic regression is performing
very poorly because the vehicle is very we don't want this slowly equal.
It's not remembering anything.
It is just a hunch which it is having.
So now let us try to balance out the glasses and then.
Right, so here we will give them the indexes for the flawed engineering classes and then either sample
the entire data.
When we understand the entire data, we have another sample in the lead up to 90 before transfer transactions.
And now the genuine transactions are between five and zero for this actually to confirm that this number
of transactions.
So when we run this particular model with the 80, 20 string samples, we see that the Odyssey is zero
point nine eight, which is a huge improvement, but equal to zero point nine five, which is again
a huge improvement.
So we can see, as expected, it has performed very well.
Now, next, what we will be doing is we will be checking the performance of this particular model on
the entire dataset, thus he will beat it.
So we will run this and we will check the predictions and we can see that the goal is still zero point
ninety one and the precision is zero point four.
So we can say that it is a good model.
Now, we will compare the scores for this war and the Gulf War, which we have created, and we can
see here the legal score is zero point nine.
So we can see that these are almost all good models.
And the logistic regression which we created later on, that understandably gave us a very better result
in comparison to the other one.
So no doubt logistic regression will give better models instead of being bad for positive predictive
value for my business that more than double.
So my business is performing better.
So you can compare and you can find out which one works better for you.
If you are only concerned about the goal, then yes, logistic regression is performing better.
But if you are looking at two people in position, it then we should be picking up the might the solution.
This is just one of the solutions.
You can think of any solution and you can try different combinations and create your own solution for.