Tell us what’s happening:
I am getting " InvalidArgumentError: assertion failed: [Labels must be <= n_classes - 1] [Condition x <= y did not hold element-wise:] [x (head/losses/Cast:0) = ] [[12644.5898][9715.84][3906.13]…] [y (head/losses/check_label_range/Const:0) = ] [1]" error while trying to training the model. Could you check my code?

Your code so far

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.104 Safari/537.36 OPR/74.0.3911.75.

Challenge: Linear Regression Health Costs Calculator

Welcome to the forums, @asarm. Looks like you accidentally posted the link to the boilerplate instead of your file. I think I remember generating this error at some point while working on this project, so if you can post a view link to your notebook, hopefully someone will be able to help.

I believe you are using the wrong type of model to solve the problem. The tf.estimator.LinearClassifier() will classify inputs into groups (labels), which is what the error is complaining about. Since you want to compute a number for each input and then compare the predicted and actual numbers, you are going to need to use something like tf.estimator.LinearRegressor() or some other model that calculates values and doesn’t just classify inputs into groups.

I used a keras model of several groups of dense/dropout layers and experimented with the dense size and dropout rate until I was satisfied with the model’s performance, but I am sure there are other and probably better ways. I basically adapted the TF predict fuel efficiency example for the regression model.

did the linear regression estimator model work for you? my mean error is too high and I think it’s because linear regression is not a good choice for this problem.

Yes, I even tweaked the learning rate but the highest mae I could get was 4055 which is above 3500. Multilayer model with higher learning rate gets the job done.