I need help

i have code:

import matplotlib.pyplot as plt
import random
# Define variables needed for plotting.
color_list = ['r-', 'm-', 'y-', 'c-', 'b-', 'g-']
color_index = 0
def show_learning(w):
    global color_index
    print('w0 =', '%5.2f' % w[0], ', w1 =', '%5.2f' % w[1],
    ', w2 =', '%5.2f' % w[2]) 
    if color_index == 0:
        plt.plot([1.0], [1.0], 'b_', markersize=12)
        plt.plot([-1.0, 1.0, -1.0], [1.0, -1.0, -1.0],
        'r+', markersize=12)
        plt.axis([-2, 2, -2, 2])
        plt.xlabel('x1')
        plt.ylabel('x2')
    x = [-2.0, 2.0]
    if abs(w[2]) < 1e-5:
        y = [-w[1]/(1e-5)*(-2.0)+(-w[0]/(1e-5)), 
        -w[1]/(1e-5)*(2.0)+(-w[0]/(1e-5))]
    else:
        y = [-w[1]/w[2]*(-2.0)+(-w[0]/w[2]), 
        -w[1]/w[2]*(2.0)+(-w[0]/w[2])]
    plt.plot(x, y, color_list[color_index])
    if color_index < (len(color_list) - 1):
        color_index += 1
# Define variables needed to control training process.
random.seed(7) # To make repeatable
LEARNING_RATE = 0.1
index_list = [0, 1, 2, 3] # Used to randomize order
# Define training examples.
x_train = [(1.0, -1.0, -1.0), (1.0, -1.0, 1.0), (1.0, 1.0, -1.0), (1.0, 1.0, 1.0)] # Inputs
y_train = [1.0, 1.0, 1.0, -1.0] # Output (ground truth)
# Define perceptron weights.
w = [0.2, -0.6, 0.25] # Initialize to some "random" numbers
# Print initial weights.
show_learning(w)
plt.show()

i want to print 4 line same image
Screenshot 2023-10-11 205108
someone can help me ;-;

Hi @Anh_Khoi24

Welcome to the community.

You have posted on the general category. What course are you referring to?

Don’t forget to check our Community Guidelines before posting. It will help you with your next queries.

Thank you.

Hi, Anh.

Welcome to the community! I edited your post to use the “</>” tool to format your code, which makes it easier to read. If you don’t do that, the problem is that symbols in the code like * and # are interpreted as “markdown” formatting which just confuses everything.

I’m not familiar with the course material there, so I’m not the right person to answer about the actual code.

Regards,
Paul

Hey @Anh_Khoi24,

Is that figure an example of the desired output?