Re: Plotting observed versus predicted real numbers using keras

1,205 views
Skip to first unread message

Bruno Guberfain do Amaral

unread,
Jul 31, 2016, 1:20:27 PM7/31/16
to akshata bhat, Keras-users
I think that what you are looking for is a scatter plot.

In matplotlib you can do:


import matplotlib.pyplot as plt

...

Y_test_hat = model.predict(X_test)

# Plot predictions for first value (the second value is the same, but changing the 0 by1)
plt.scatter(Y_test[:,0], Y_test_hat[:,0])
plt.show()

If your model is good, then you should see a diagonal line of points.

I hope that helps
Bruno
Em dom, 31 de jul de 2016 às 12:17, akshata bhat <akshat...@gmail.com> escreveu:
Hi,

I am pretty new to deep learning and keras and trying to build by own regression model. My model has vectors of length 41 as input and output is a 2 real number. 
Its a CSV file with 43 columns 
41 columns are the input and last 2 columns are the output.


model = Sequential()
model.add(Convolution2D(64 , 3 , 1,
      border_mode = "same",
      activation="relu",
      input_shape=(1,41,1)))
model.add(Convolution2D(64 , 3 , 1,
      border_mode = "same",
      activation="relu"))
model.add(MaxPooling2D(pool_size=(3,1)))      
model.add(Convolution2D(128 , 3 , 1,
      border_mode = "same",
      activation="relu"))
model.add(Convolution2D(128 , 3 , 1,
      border_mode = "same",
      activation="relu"))
model.add(MaxPooling2D(pool_size=(2,1))) 

model.add(Convolution2D(256 , 3 , 1,
      border_mode = "same",
      activation="relu"))
model.add(Convolution2D(256 , 3 , 1,
      border_mode = "same",
      activation="relu"))
model.add(Convolution2D(256 , 3 , 1,
      border_mode = "same",
      activation="relu"))
model.add(MaxPooling2D(pool_size=(2,1))) 

model.add(Flatten())
model.add(Dense(100, activation="relu"))
model.add(Dense(2))

model.compile(loss='mean_absolute_error', optimizer='adam',  metrics=['accuracy'])
 

model.fit(X_train,Y_train,batch_size=10, nb_epoch=20 )
scores = model.evaluate(X_test, Y_test)
print((model.metrics_names[1], scores[1]*100))


I want to find a way to plot the observed versus the predicted  using a graph. I know its very basic but I need some help.I would be very grateful. 

--
You received this message because you are subscribed to the Google Groups "Keras-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keras-users...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/keras-users/c786c941-4320-415a-8704-0f3e846a621c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages