Skip to content

Instantly share code, notes, and snippets.

@b0noI
Created September 16, 2018 02:08
Show Gist options
  • Save b0noI/7f733bd191f548c1d20e87d02579012a to your computer and use it in GitHub Desktop.
Save b0noI/7f733bd191f548c1d20e87d02579012a to your computer and use it in GitHub Desktop.
import numpy as np
import tensorflow as tf
import pandas as pd
FEATURES = ["SqFt", "Bedrooms", "Offers"]
LABEL = "Price"
feature_cols = [tf.feature_column.numeric_column(k) for k in FEATURES]
estimator = tf.estimator.LinearRegressor(
feature_columns=feature_cols,
model_dir="train")
def get_input_fn(data_set):
return tf.estimator.inputs.pandas_input_fn(
x=pd.DataFrame({k: data_set[k].values for k in FEATURES}),
y=pd.Series(data_set[LABEL].values),
batch_size=10,
num_epochs=100,
shuffle=True)
estimator.train(input_fn=get_input_fn(house_pricing))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment