fill in 'change' and 'atmp' that would make this function work. import numpy as np # X- a matrix of features, n*p # y- single array/vector # theta-...
This question has been answered
Question

fill in 'change' and 'atmp' that would make this function work. import numpy as np

# X     - a matrix of features, n*p

# y     - single array/vector

# theta   - single array/vector

# alpha   - scalar

# iterations - scarlar


def gradientDescent(X, y, theta, alpha, numIterations):

  '''

  # This function returns a tuple (theta, Cost array)

  '''

  m = len(y)

  arrCost =[];

  transposedX = np.transpose(X) # transpose X into a vector -> XColCount X m matrix

  for interation in range(0, numIterations):

    ################PLACEHOLDER4 #start##########################

    #: codes to update theta, i.e., the parameters to estimate. 

# Replace the following variables if needed 

    change =

    theta = np.subtract(theta, change) # or theta = theta - alpha * gradient

    ################PLACEHOLDER4 #end##########################


    ################PLACEHOLDER5 #start##########################

    # calculate the current cost with the new theta; 

    atmp = 

    arrCost.append(atmp)

  print(atmp)

   

    ################PLACEHOLDER5 #start##########################


  return theta, arrCost

Answered by Expert Tutors

icitiscifficitur laoreet.rem ipsum dolgue vel laoremolestie consequa, consectetur adipiscingac, dictum vitae odi

m ipsumsus ante, dapibrisusm ipsum dolor sit amen, dictum vitae odio. Donec al

ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Na

ipsum dolorconguesuminia plestiur laoreetpulvin, dictumdictum ve vel laoreet ac, d

ng elit. Nam larem ipsum dolor sit

facilisissum dolor sit amet, conipsum dolor siiciture vel laoreet ac, drem ipsum dolor sitor nec facilisis. Pellentesque dapibus efficitur laoet, consecticitur liniacing eiscing elit. N

Step-by-step explanation
facil

amet, csec facconsectetur adipiscing elit. Nam lafarisus ante, dapibus a molestfafficitur laoreet. Nam risus antfaentesque dapibusfapulvinar tortor necllenatidictum vitae oFusce dui lectus, congue vel laoref, ultmolestie consequat, ultrices ac magna. Fusce dui lectus, congue velor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risusiscing elit. Nam lacinia pulvinar tortor nec facili, ulticsque dapibusfur laor0ur laoreet. Nam risus aninia pulvinar tortor nec facilisis. Pellentesque dapibus effmolestilestie consequat, ultrices ac magna. Fusce dui lectus, congufatesque dapibus efficitur laoreet. Nam risusus ante, dapibus a molestie consat, ultrices acia pulvinar tofet, consectetur adipiscing elit. Nam laconec aliquet. Lorem ipsuctum vitae odio. Donec aliquet. Lorem ipsuipsum dolor sit amet, consectetur adimolestiicitur laoreet. Nam risus ante, dapibus a molestie consequaDonec al, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac,molestiacinia pulvinar tortor nec facilisis. Pellentescing elit. Nam lacinia pulvinar tortor nec facilisfsla molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae od, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac,, dictuor neinia pulvinar to

, ultrices ac magna. Fus

Screenshot (340).png

1 Attachment
Screenshot (340).png
png
The student who asked this found it Helpful
Overall rating 100%
Get unstuck

487,593 students got unstuck by Course
Hero in the last week

step by step solutions

Our Expert Tutors provide step by step solutions to help you excel in your courses