Welcome back.
Now let's use this class in our main activity.
So here inside the main activity create private late initiate var tf Lite helper.
It's of type TF Lite helper class.
And then inside our Oncreate function let's initialize our TF Lite helper tf Lite helper and pass the
context.
This set the content prediction and pass the TF Lite helper.
I need to change the parameters of the house price screen prediction function takes into the parameter
tf Lite helper instance.
Okay, later we're going to use this tf Lite helper with on click.
But follow me now okay, so set content tf Lite helper instance.
Also there is another function to override which is on destroy.
So on destroy we need to call the close function that we create.
So tf Lite helper dot close.
Important to release the model.
Closing the interpreter when the activity is destroyed.
Okay, this is a very important step.
Now let's move to the the, uh, house prediction price prediction function.
And here we need to scroll down to the button.
And on click we have this button.
When I click on this I need to get the result and display a text for the price of the house.
We have a variable x which is the size input of uh the the house.
Here, if x does not equal to null val y equals to tf lite helper dot predict.
You can see I am using the predict function that we create here in the TF Lite helper.
It takes a float.
So I need to pass a float which is y variable y.
Now I need to store the result which is uh, which is uh x sorry, it's the input is X and the Y is
the result.
If y does not equal to null, then what we need to do predict the price.
And we need to set the format like this and else failed to predict.
And the result is the output result.
So price output equals to.
If y doesn't equals to null then go and set the price output to predicted price and get y.
Otherwise print fail to predict.
Then we need to use this price output here inside the text or under the text.
If output price is not blank, make a spacer and create a text setting the price output.
So here the price of the house is price output and set the style to material theme typography.
Body medium.
Okay, let's run our application.