<jupyter_start><jupyter_text>http://www.bmc.com/blogs/introduction-to-tensorflow-and-logistic-regression/<jupyter_code>import pandas
import tensorflow as tf
import tempfile
hours = [0.50,0.75,1.00,1.25,1.50,1.75,1.75,2.00,2.25,2.50,2.75,3.00,3.25,3.50,4.00,4.25,4.50,4.75,5.00,5.50]
passx = [0,0,0,0,0,0,1,0,1,0,1,0,1,0,1,1,1,1,1,1]
df = pandas.DataFrame(passx)
df['hours'] = hours
df.columns = ['pass', 'hours']
h = df['hours'].apply(lambda x: x * 100).astype(int)
df['hours']=h
df
def input_fn(df):
    labels = df["pass"] 
    return tf.estimator.inputs.pandas_input_fn(x=df,
                                               y=labels,
                                               batch_size=100,
                                               num_epochs=10,
                                               shuffle=False,
                                               num_threads=5)
model_dir = tempfile.mkdtemp()
print("model directory = %s" % model_dir)
hours = tf.feature_column.numeric_column("hours")
base_columns = [hours]
m = tf.estimator.LinearClassifier(model_dir=model_dir, feature_columns=base_columns)
m.train(input_fn(df),steps=None)
results = m.evaluate(input_fn(df),steps=None)
for key in sorted(results):
    print("%s: %s" % (key, results[key]))<jupyter_output>accuracy: 0.5
accuracy_baseline: 0.5
auc: 0.805
auc_precision_recall: 0.832721
average_loss: 1.89498
global_step: 10
label/mean: 0.5
loss: 189.498
precision: 0.5
prediction/mean: 0.956125
recall: 1.0
{'fraction_non_alphanumeric': 0.15415821501014199, 'fraction_numerical': 0.08857336037863421, 'mean_word_length': 2.6633663366336635, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '256747', 'license': 'Apache-2.0', 'n_tokens_mistral': 623, 'n_tokens_neox': 550, 'n_words': 82, 'path': 'tensorflow_demo__bmc.ipynb', 'repo_name': 'researcherben/learn_machine_learning', 'size': '1479'}