Welcome back.
Let's use this validation errors composable in our car features form.
And here you see that we didn't use this validation errors parameter.
Scroll down to under the origin card origin chip.
And under the scope of this row let me use the validation errors.
If validation errors is not empty, go and display the validation errors composable with the validation
errors inside it.
And also you can make a spacer between the validation errors and the button or the row that here of
origin chip.
Okay so let me run.
So if the user missed anything here, there is an error displaying that you should specify the correct
input or you should specify the missing inputs.
Now I want from you to focus with me.
We finished the UI.
Now let's move to the functional coding here.
Create a new package named as predictions.
And inside this package, create a new Kotlin class.
Name it as car.
My mileage predictor.
We need to connect our user interface with the TensorFlow Lite model that we created.
We need to get those data.
And when the user clicks on the submit button, we need to get the data into TensorFlow.
And the TensorFlow will predict the mileage and display the result here.
So this is a connection.
This is a bridge between our TensorFlow and the user interface.
So I want from you to understand it like it's a bridge between TensorFlow model And user interface.
This car mileage predictor class takes into the constructor a context object.
And as we did before, let's start with the interpreter.
Interpreter.
It's from TensorFlow Lite.
It's of type TensorFlow Lite interpreter.
This line of code declares a private variable named interpreter.
That is your app engine for running TensorFlow Lite machine learning models.
TF Lite.
So you give it a model and some input data and it gives you back the predictions or results.
Okay.
The second step is to create the input shape and the output shape.
This is very important in machine learning.
We need to get the shape of our input and get the output shape of our model.
Private val input shape.
What is the shape of our model?
It's an int array of one and nine.
We need to pass one sample and nine features.
Did you remember the features?
Let me go back to here.
Car features 123, four, five, six, seven, eight and nine.
So we need to set the input shape to 1999 features and one sample.
So one sample and nine features we need to get the output shape.
So output shape equals to int array of one of one.
So here we have one sample.
And we need to get only the mileage.
So the output would be a one number.
It's the mileage of our car.
Okay.
So the output shape.
Output shape is a number.
This is very very important.
We need to understand the input and the output of our shape and our model.
Okay.
So give me nine parameters.
Nine features I'll give you one output okay.
So this is the meaning of the input and output shape here.
To solve it.
We need to use it.
Private var interpreter add late.
Initiate.
You can late initiate it okay.
Then start with init block.
We need to load that Tflite model.
So here val model equals to load model file and set the context.
The parameter interpreter equals to interpreter and pass the model.
In the next video we're going to create this function.