1

I'm trying to compare my predicted output and the test data using matplotlib.As I'm new to python I'm not able to find how to connect each entry with line like in this photo. I was able to write a code like this which compares the Y coordinate and entries but I'm unable to map each entry of test data with predicted output with a line

X_1 = range(len(Y_test))
plt.figure(figsize=(5,5))
plt.scatter(X_1, output, label='Y_output',alpha=0.3)
plt.scatter(X_1, Y_test, label='Y_test',alpha=0.3)
plt.title("Scatter Plot")
plt.legend()
plt.xlabel("entries")
plt.ylabel("Y value")
plt.show()

graph we are getting

1 Answer 1

1

Try something like this in addition to your code

plt.plot(np.stack((X_1,X_1)), np.stack((output,Y_test)), color="black")

In fact, to reproduce the plot you want, you need different x for output and for Y_test (for example, X_1 and X_2 that are different).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.