<jupyter_start><jupyter_text>TensorFlow Learn Tutorial from https://medium.com/@ilblackdragon/tensorflow-tutorial-part-1-c559c63c0cb1.9p5m28k6d<jupyter_code>from tensorflow.contrib import learn
import pandas as pd
from sklearn.cross_validation import train_test_split
from sklearn.metrics import accuracy_score
from sklearn.linear_model import LogisticRegression
df = pd.read_csv('data/titanic_train.csv')
df.shape
df.columns
df.head(1)
y, X = df['Survived'], df[['Age', 'SibSp', 'Fare']].fillna(0)<jupyter_output><empty_output><jupyter_text>With scikit-learn<jupyter_code>X_train, X_test, y_train, y_test = train_test_split(X,
                                                    y,
                                                    test_size=0.2,
                                                    random_state=42)
lr = LogisticRegression()
lr.fit(X_train, y_train)
print(accuracy_score(y_test, lr.predict(X_test)))<jupyter_output>0.664804469274<jupyter_text>With tf.learn<jupyter_code>import random
random.seed(42) # to sample data the same way
classifier = learn.TensorFlowLinearClassifier(n_classes=2,
                                              batch_size=128,
                                              steps=500,
                                              learning_rate=0.05)
classifier.fit(X_train, y_train)
print(accuracy_score(classifier.predict(X_test), y_test))<jupyter_output>0.670391061453
{'fraction_non_alphanumeric': 0.09335219236209336, 'fraction_numerical': 0.04031117397454031, 'mean_word_length': 2.5375, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '507102', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 469, 'n_tokens_neox': 439, 'n_words': 67, 'path': 'tensorflow/tflearn-logistic-regression.ipynb', 'repo_name': 'koverholt/notebooks', 'size': '1414'}