Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Like this presentation? Why not share!

No Downloads

Total views

4,262

On SlideShare

0

From Embeds

0

Number of Embeds

5

Shares

0

Downloads

48

Comments

0

Likes

5

No embeds

No notes for slide

- 1. Optimization in R id:syou6162 Saturday, March 27, 2010
- 2. Agenda • • GSoC Tsukuba.R • Optimization in R(R ) • • R • Saturday, March 27, 2010
- 3. • (id:syou6162 @syou6162) • http://syou6162.sakura.ne.jp/ • => • & Saturday, March 27, 2010
- 4. Google Summer of Code • 3/29 • NoSQL interface for R • Dirk Eddelbuettel • Saturday, March 27, 2010
- 5. Tsukuba.R • ( ) R • R • (Tokyo Osaka Nagoya) • 2008 7 #6 Saturday, March 27, 2010
- 6. (1) • • plot • • R • • apply family • ggplot2 animation Saturday, March 27, 2010
- 7. (2) • • R C • openCV C R • R • • Twitter Saturday, March 27, 2010
- 8. Tsukuba.R Saturday, March 27, 2010
- 9. Saturday, March 27, 2010
- 10. Saturday, March 27, 2010
- 11. Saturday, March 27, 2010
- 12. Saturday, March 27, 2010
- 13. Saturday, March 27, 2010
- 14. • Tsukuba.R • Saturday, March 27, 2010
- 15. Optimization in R id:syou6162 Saturday, March 27, 2010
- 16. R • 2 !! • optim optimize • optim optimize 1 • ? Saturday, March 27, 2010
- 17. ? •R • => !! • • ? Saturday, March 27, 2010
- 18. : (= ) !! http://ja.wikipedia.org/wiki/ Saturday, March 27, 2010
- 19. • ( ) • • • !! Saturday, March 27, 2010
- 20. > f <- function (x) (x - 1 / 3)^2 > (xmin <- optimize(f, c(0, 1), tol = 0.0001) $minimum [1] 0.3333333 $objective [1] 0 Saturday, March 27, 2010
- 21. • • • ( ) • Saturday, March 27, 2010
- 22. R • •R log_likelihood_for_norm <- function(x){ return(function(par){ mu <- par[1] sigma2 <- par[2] - length(x) / 2 * log(sigma2) - 1 / 2 * sum((x - mu)^2) / sigma2 }) (x) μ σ } Saturday, March 27, 2010
- 23. : •R • • •R : apply family • apply tapply sapply mapply rapply eapply lapply Saturday, March 27, 2010
- 24. : sapply&rapply > invisible(sapply(1:3, function(x) { cat("x is", x, fill=TRUE) })) x is 1 x is 2 x is 3 > rapply(list(list(c("a", "b"), list(1:10)), matrix(1:10, 2, 5)), + function(x) { + class(x) + } + ) [1] "character" "integer" "matrix" Saturday, March 27, 2010
- 25. R • •R log_likelihood_for_norm <- function(x){ return(function(par){ mu <- par[1] sigma2 <- par[2] - length(x) / 2 * log(sigma2) - 1 / 2 * sum((x - mu)^2) / sigma2 }) (x) μ σ } Saturday, March 27, 2010
- 26. optim • => cars$speed > optim(par = c(5, 10), fn = log_likelihood_for_norm(cars$speed), control = list(fnscale = -1)) $par [1] 15.39812 27.40184 ( ) $value [1] -107.7636 $counts function gradient 75 NA optim $convergence fnscale=-1 [1] 0 $message NULL Saturday, March 27, 2010
- 27. ? > optim(par = c(5, 10), fn = log_likelihood_for_norm(cars$speed), control = list(fnscale = -1)) $par [1] 15.39812 27.40184 $value [1] -107.7636 > mean(cars$speed) [1] 15.4 $counts > var(cars$speed) function gradient [1] 27.95918 75 NA $convergence [1] 0 !! $message NULL Saturday, March 27, 2010
- 28. !! result <- lm(dist~speed, data=cars) plot(cars) coef <- result$coef abline(coef[1], coef[2], col="red") Saturday, March 27, 2010
- 29. > obj_func <- function(x, y) { + function(par) { + a <- par[1]; b <- par[2] + sum((y - (a + b * x))^2) + } + } > > result <- optim(par = c(0, 5), fn = obj_func(cars$speed, cars $dist)) > result$par [1] -17.579625 3.932217 > lm(dist~speed, data=cars)$coef (Intercept) speed !! -17.579095 3.932409 Saturday, March 27, 2010
- 30. ... • optim method • CG SANN B BFGS Nelder-Mead L-BFGS- • Saturday, March 27, 2010
- 31. CG( ) • • 2 • • n 2 n • CG • http://ja.wikipedia.org/wiki/ Saturday, March 27, 2010
- 32. BFGS • <= • => 2 => • • => 2 ( ) • • Saturday, March 27, 2010
- 33. Nelder-Mead • N N+1 • • • • http://ibisforest.org/index.php?Nelder-Mead Saturday, March 27, 2010
- 34. Nelder-Mead optim (method ) Saturday, March 27, 2010
- 35. R • optim • etc • Nelder-Mead SANN • BFGS CG Saturday, March 27, 2010
- 36. FAQ Saturday, March 27, 2010
- 37. R ? • • • C C++ • Tsukuba.R#4 • http://d.hatena.ne.jp/ syou6162/20090301/1235890688 Saturday, March 27, 2010
- 38. ? • CG BFGS • ( ) • optim • Saturday, March 27, 2010
- 39. • • Writing R Extentions !! Saturday, March 27, 2010
- 40. • • GSoC Tsukuba.R • Optimization in R(R ) • • R • Saturday, March 27, 2010

No public clipboards found for this slide

×
### Save the most important slides with Clipping

Clipping is a handy way to collect and organize the most important slides from a presentation. You can keep your great finds in clipboards organized around topics.

Be the first to comment