How to apply sequentinal MSE model to data that is not binary?

1

I have been using this model with binary data to predict likely hood of play from this guide.

import tensorflow as tf
from tensorflow import keras
import numpy  as np
import pandas as pd



model = keras.Sequential()

input_layer = keras.layers.Dense(3, input_shape=[3], activation='tanh')
model.add(input_layer)

output_layer = keras.layers.Dense(1, activation='sigmoid')
model.add(output_layer)

gd = tf.train.GradientDescentOptimizer(0.01)

model.compile(optimizer=gd, loss='mse')

sess = tf.Session()  #NEW LINE

training_x = np.array([[1, 1, 0], [1, 1, 1], [0, 1, 0], [-1, 1, 0], [-1, 0, 0], [-1, 0, 1],[0, 0, 1], [1, 1, 0], [1, 0, 0], [-1, 0, 0], [1, 0, 1], [0, 1, 1], [0, 0, 0], [-1, 1, 1]])
training_y = np.array([[0], [0], [1], [1], [1], [0], [1],[0], [1], [1], [1], [1], [1], [0]])



init_op = tf.initializers.global_variables()


sess.run(init_op)  #NEW LINE

model.fit(training_x, training_y, epochs=1000, steps_per_epoch = 10)


text_x = np.array([[1, 0, 0]])
test_y = model.predict(text_x, verbose=0, steps=1)

print(test_y)

All the current data is binary and model works with binary, is there any model or way to convert non-binary data to binary predict likelihood of product_sold in the below data set?

dataset:

number_infants    cost_of_infants     estimated_cost_infants    product_sold
5                     1000               2000                         0
6                     8919               1222                         1
7                     10000              891                          1

product_sold
1 = yes
0 = no

RustyShackleford

Posted 2018-12-19T13:29:43.493

Reputation: 135

No answers