User Tools

Site Tools


gradient_descent

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
gradient_descent [2026/03/14 10:46] – [Gradient Descent] hkimscilgradient_descent [2026/03/14 11:21] (current) – [output] hkimscil
Line 313: Line 313:
 > # we use sum of square of error which oftentimes become big > # we use sum of square of error which oftentimes become big
 > msrloss <- function(predictions, y) { > msrloss <- function(predictions, y) {
-  residuals <- (y - predictions) +    residuals <- (y - predictions) 
-  return(mean(residuals^2))+    return(mean(residuals^2))
 + } + }
  
Line 322: Line 322:
  
 > for (i in seq(from = -50, to = 50, by = 0.01)) { > for (i in seq(from = -50, to = 50, by = 0.01)) {
-  pred <- predict(x, i, b) +    pred <- predict(x, i, b) 
-  res <- residuals(pred, y) +    res <- residuals(pred, y) 
-  msr <- msrloss(pred, y) +    msr <- msrloss(pred, y) 
-  msrs <- append(msrs, msr) +    msrs <- append(msrs, msr) 
-  srs <- append(srs, mean(res)) +    srs <- append(srs, mean(res)) 
-  as <- append(as, i)+    as <- append(as, i)
 + } + }
 > length(msrs) > length(msrs)
Line 337: Line 337:
  
 > min(msrs) > min(msrs)
-[1] 7766.679+[1] 8735.055
 > min.pos.msrs <- which(msrs == min(msrs)) > min.pos.msrs <- which(msrs == min(msrs))
 > min.pos.msrs > min.pos.msrs
-[1] 5828+[1] 4896
 > print(as[min.pos.msrs]) > print(as[min.pos.msrs])
-[1] 8.27+[1] -1.05
 > summary(mo) > summary(mo)
  
Line 350: Line 350:
 Residuals: Residuals:
      Min       1Q   Median       3Q      Max       Min       1Q   Median       3Q      Max 
--259.314  -59.215    6.683   58.834  309.833 +-245.291  -67.967   -3.722   63.440  242.174 
  
 Coefficients: Coefficients:
             Estimate Std. Error t value Pr(>|t|)                 Estimate Std. Error t value Pr(>|t|)    
-(Intercept)    8.266     12.546   0.659    0.511     +(Intercept)   -1.047     14.289  -0.073    0.942     
-x             11.888      2.433   4.887 2.11e-06 ***+x             12.900      2.870   4.495 1.19e-05 ***
 --- ---
 Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
  
-Residual standard error: 88.57 on 198 degrees of freedom +Residual standard error: 93.93 on 198 degrees of freedom 
-Multiple R-squared:  0.1076, Adjusted R-squared:  0.1031  +Multiple R-squared:  0.09258, Adjusted R-squared:  0.088  
-F-statistic: 23.88 on 1 and 198 DF,  p-value: 2.111e-06+F-statistic:  20.on 1 and 198 DF,  p-value: 1.185e-05
  
 > plot(seq(1, length(msrs)), msrs) > plot(seq(1, length(msrs)), msrs)
 > plot(seq(1, length(srs)), srs) > plot(seq(1, length(srs)), srs)
 > tail(msrs) > tail(msrs)
-[1] 9504.208 9505.041 9505.875 9506.710 9507.544 9508.379+[1] 11335.75 11336.77 11337.79 11338.81 11339.84 11340.86
 > max(msrs) > max(msrs)
-[1] 11161.64+[1] 11340.86
 > min(msrs) > min(msrs)
-[1] 7766.679+[1] 8735.055
 > tail(srs) > tail(srs)
-[1] -41.68368 -41.69368 -41.70368 -41.71368 -41.72368 -41.73368+[1] -50.99705 -51.00705 -51.01705 -51.02705 -51.03705 -51.04705
 > max(srs) > max(srs)
-[1] 58.26632+[1] 48.95295
 > min(srs) > min(srs)
-[1] -41.73368 +[1] -51.04705 
->+ 
 </code> </code>
-{{:pasted:20250821-121009.png}} +{{pasted:20260314-112129.png}}
-{{:pasted:20250821-121024.png}}+
  
 ===== b값 구하기 ===== ===== b값 구하기 =====
gradient_descent.1773485215.txt.gz · Last modified: by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki