class tf.contrib.learn.LinearRegressor
Linear regressor model.
Train a linear regression model to predict target variable value given observation of feature values.
Example:
education = sparse_column_with_hash_bucket(column_name="education", hash_bucket_size=1000) occupation = sparse_column_with_hash_bucket(column_name="occupation", hash_bucket_size=1000) education_x_occupation = crossed_column(columns=[education, occupation], hash_bucket_size=10000) estimator = LinearRegressor( feature_columns=[occupation, education_x_occupation]) # Input builders def input_fn_train: # returns x, y ... def input_fn_eval: # returns x, y ... estimator.fit(input_fn=input_fn_train) estimator.evaluate(input_fn=input_fn_eval) estimator.predict(x=x)
Input of fit
and evaluate
should have following features, otherwise there will be a KeyError:
- if
weight_column_name
is notNone
: key=weight_column_name, value=aTensor
- for column in
feature_columns
:- if isinstance(column,
SparseColumn
): key=column.name, value=aSparseTensor
- if isinstance(column,
WeightedSparseColumn
): - if isinstance(column,
RealValuedColumn
): key=column.name, value=aTensor
- - -
- if isinstance(column,
Please login to continue.