I am creating a simple linear regression for data from csv . Data includes weight and height values ββfor some people. The general learning process is very simple:
MAX_STEPS = 2000
features = [tf.contrib.layers.real_valued_column(feature_name) for feature_name in FEATURES_COL]
linear_regressor = tf.contrib.learn.LinearRegressor(feature_columns=features)
linear_regressor.fit(input_fn=prepare_input, max_steps=MAX_STEPS)
However, the model created by the regressor is unexpectedly bad. The result can be illustrated by the following figure:

Visualization Code (just in case):
plt.plot(height_and_weight_df_filtered[WEIGHT_COL],
linear_regressor.predict(input_fn=prepare_full_input),
color='blue',
linewidth=3)
Here is the same data given to the LinearRegression class from scikit-learn:
lr_updated = linear_model.LinearRegression()
lr_updated.fit(weight_filtered_reshaped, height_filtered)
And visualization:

An increase in the number of steps is not affected. I would suggest that I use the TensorFlow regressor incorrectly.
iPython laptop with code.
source
share