Linear Regression Health Costs Calculator Assertion Error

I keep getting an assertion error when trying to train the model

Error : InvalidArgumentError: assertion failed: [Labels must be <= n_classes - 1] [Condition x <= y did not hold element-wise:] [x (head/losses/Cast:0) = ] [[10702.6396][1242.82][3704.35]…] [y (head/losses/check_label_range/Const:0) = ] [1]
[[{{node Assert}}]]

Link :

Your browser information:

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

Challenge: Linear Regression Health Costs Calculator

Link to the challenge:

Welcome to the forums @hichammazouzi120. It looks like you posted the link to the boilerplate notebook and not yours. If you post yours, I’ll have a look.

Hi, thank you for your time.
Here s the link : Google Colaboratory

The problem is here:

linear_est = tf.estimator.LinearClassifier(feature_columns=feature_columns, n_classes=200)

where you are using a linear classifier, which sorts input into different groups, instead of a regression which computes a value (health care cost in this case) from inputs (the other data), So you need to use a regression model; you can follow and adapt the tf fuel efficiciency tutorial for this project.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.