How to predict output in a regression problem?

Hi everyone :wave:
I want to use a regression model of TensorFlow for machine learning some data in my project. I studied the TensorFlow tutorial in this link:

Everything looks clear except that I Don’t know how to predict numbers with that! I mean I want to give it some numbers as input and get a number (output) as expected value based on trained model.
Could you please help me with that? Thank you!

That is covered in the tutorial. You can look back at the test_features data set to see the format of the data used in the tutorial. In general, once you have a regression model, you input new data that was not in the training set (in the same format) into the model, which then calculates your target value (MPG in the tutorial).

It’s easier to think of in terms of a linear regression, where you have a set of (x, y) coordinates that supposedly form a line which can be used to calculate a least squares regression. This would then give you a function y = mx + b, into which you could input new x values to compute new y values.

In the MPG tutorial, once you have your DNN model trained, you could input new car data (like x in a line) and it would predict MPG (like calculating y in a line).

1 Like

Thanks for your answer dear jeremy.a.gray!
I almost got what you said, but since I’m a beginner even with coding, I’m confused… I found test_features and know about dataset format, but I still don’t know how to enter the input numbers and then get the MPG.
Could you please show me the code block where I can input a new dataset and then get the output? Thanks a lot for your help.

Just take the cleaned dataset at the top of the tutorial as an example, with the columns for cylinders, displacement, horsepower, etc., and create your own new dataset in the same way. You then should be able to use it as input to your model just like the tutorial does near the bottom (that’s the link above).

1 Like