Logistic regression

Now we can try a more complex example implementing a logistic regression algorithm. The first step, as usual, is creating a dummy dataset:

from sklearn.datasets import make_classification>>> nb_samples = 500>>> X, Y = make_classification(n_samples=nb_samples, n_features=2, n_redundant=0, n_classes=2)

The dataset is shown in the following figure:

At this point, we can create the graph and all placeholders, variables, and operations:

import tensorflow as tf>>> graph = tf.Graph()>>> with graph.as_default():>>>    Xt = tf.placeholder(tf.float32, shape=(None, 2), name='points')>>> Yt = tf.placeholder(tf.float32, shape=(None, ...

Get Machine Learning Algorithms now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.