human
Can you show me a Python code to glm linear regression.
assistant
Here is a Python code to glm linear regression

import numpy as np

def glm(x, y, w=None, intercept=True):
    """
    Generalized linear model.
    """
    if w is None:
        w = np.ones(len(x))
    if intercept:
        x = np.c_[np.ones(len(x)), x]
    return np.linalg.lstsq(x, y, rcond=None)[0]

# Enter the x and y
x = [1, 2, 3, 4, 5]
y = [1, 2, 3, 4, 5]

# Enter the weight
w = [1, 1, 1, 1, 1]

# Enter the intercept
intercept = True

# Calling the function
print((glm(x, y, w, intercept)))

#Example Output
# [-1.85769119e-15  1.00000000e+00]

#Remember to inspect code for bugs.