Welcome back.
Now let's run our application and see if there is any error.
Here I select the Xiaomi my physical device.
Also you can select the emulators.
But in order to prevent any errors I need to test on my real device.
So here this is our application car mileage predictor.
Set the cylinders for displacement 150 horsepower, weight acceleration and the model year.
Let me test if I entered invalid model year for example 1999 okay so 90 select American predict mileage.
And here we have this error model year must be between 70 and 82.
So here our validation of errors is working fine.
Let me make it as 76.
This is good.
Select American predict mpg.
And here we go.
Predicted mileage is 8184.
This is not acceptable because we need to get, uh, data between and range between, uh, like 12 and
25 or 30.
So this is not acceptable.
Why?
Because we used data that are not scaled.
So here I want from you to understand the importance of the scaled features.
Again, guys, this is the most important thing.
You should pay attention when training machine learning and models.
You should make scales.
This is your pay attention, your application is working fine and the model is predicting data as you
need.
But there is one thing you missed that is the scaled features.
Back to our Google Colab here.
If you remember, let me scroll down before training the model, we talked about feature scaling.
This is especially crucial for neural networks and many other machine learning algorithms.
It standardizes the range of independent features in the data to a common scale.
So here the formula is very simple X, which is the data or the feature value minus mean over standard
deviation.
In this case, we need to get the mean for every feature and the standard deviation of every feature
in order to transform our data to this.
So this step is not included in our model.
We need to include it in Android Studio.
So we're going to do this as similar to this in Android Studio in order to get the correct and the exact
values.
So again guys, since we get an unacceptable data and unacceptable, um, like predictions and despite
everything is working fine because we are not using data scaling, because weight is dominating over
all the features we need to set, every feature has its own effect, has its own scale, and all the
features has a common Unit.
If you remember, guys, we talked about cylinders like in CC, horsepower in um, in HP, weight in
pounds, acceleration in second and so on.
So every feature is, has its own unit.
We need to unify all those features into one scale.
Okay.
So I need from you to, uh, to focus with me and pay attention how I need to use standard scaler,
how to use feature scaling in our Android application.
So we're going to use this step in Android Studio.
At first we need to get the standard deviation and the mean of every feature before we move to Android
Studio.
So let me scroll up here in the statistical summary.
And step number three understanding data, we get the mean and the standard deviation.
So std standard deviation and the mean.
We need to um to subtract x from mean over standard deviation.
So please pay attention cup those values the standard deviation and the mean of cylinders displacement
horsepower weight acceleration model year and so on.
So let me start with cylinders.
So let me take here Open Android Studio go to Car Mileage Predictor.
And here inside this class let me create a new variable of type array.
So here feature scaling.
This is the most important step.
So private val feature means equals to float array of.
And let's start with a cylinder.
The cylinders is 5.4
71939F.
This is for cylinders.
So let me mark it like this.
Let's continue with the others.
We can take the origin one mean similar to origin two mean and origin three mean.
Okay.
Later if we get errors we can modify those values okay.
Now let's create another variable similar to what we've done before, but this time for the feature
standard deviations.
So float array of.
Here we need to use the standard deviation of the data.
So copy this 1.7.
This is for cylinders standard deviation and so on.
Is the cylinders standard deviation.
This is for displacement.
This is for horsepower the weight acceleration model year origin one, origin two and origin three.
Those are the standard deviation and the feature means.