C1 W1 Lab 04 Gradient Descent Soln Unable to plot last char

Hi I am running Jupyter Notebook on my local machine but got the following error when I tried to run the cell. Can I ask for some help? Many thanks in advance.

Hi @rebecca.mun
Welcome to the community!

This error raise because your numbers output are greater than sys.maxsize :

import sys
print(sys.maxsize)

the solution is to convert the cost list to float data type like this

import numpy as np
cost =[]
# Sample NumPy array of integers
int_array = np.array(cost )

# Convert the elements of the array to float
float_array = int_array.astype(float)

cost = list(float_array)

or change the implementation of the fuction compute cost to

#Function to calculate the cost
def compute_cost(x, y, w, b):
   
    m = x.shape[0] 
    cost = 0
    
    for i in range(m):
        f_wb = w * x[i] + b
        cost = cost + (f_wb - y[i])**2
    total_cost = 1 / (2 * m) * cost
    total_cost = float(total_cost)
    return total_cost

Best Regards,
Abdelrahman