Permalink
Browse files

changed all pdf to png

  • Loading branch information...
1 parent 900d7aa commit 14850c0107f9eda01b43740144817a122ef5ae28 @jbrownlee committed Feb 9, 2012
Showing with 87 additions and 115 deletions.
  1. +1 −1 book/a_optimization/bfgs.tex
  2. BIN book/a_optimization/bfgs_result.pdf
  3. BIN book/a_optimization/bfgs_result.png
  4. +1 −1 book/a_optimization/conjugate_gradient.tex
  5. BIN book/a_optimization/conjugate_gradient_result.pdf
  6. BIN book/a_optimization/conjugate_gradient_result.png
  7. +1 −1 book/a_optimization/golden_section_search.tex
  8. BIN book/a_optimization/golden_section_search_result.pdf
  9. BIN book/a_optimization/golden_section_search_result.png
  10. +1 −1 book/a_optimization/gradient_descent.tex
  11. BIN book/a_optimization/gradient_descent_result.pdf
  12. BIN book/a_optimization/gradient_descent_result.png
  13. +1 −1 book/a_optimization/nelder_mead.tex
  14. BIN book/a_optimization/nelder_mead_result.pdf
  15. BIN book/a_optimization/nelder_mead_result.png
  16. +1 −1 book/a_regression/locally_estimated_scatterplot_smoothing.tex
  17. BIN book/a_regression/locally_estimated_scatterplot_smoothing_result.pdf
  18. BIN book/a_regression/locally_estimated_scatterplot_smoothing_result.png
  19. +1 −1 book/a_regression/logistic_regression.tex
  20. BIN book/a_regression/logistic_regression_result.pdf
  21. BIN book/a_regression/logistic_regression_result.png
  22. +1 −1 book/a_regression/multivariate_adaptive_regression_splines.tex
  23. BIN book/a_regression/multivariate_adaptive_regression_splines_result.pdf
  24. BIN book/a_regression/multivariate_adaptive_regression_splines_result.png
  25. +1 −1 book/a_regression/ordinary_least_squares_regression.tex
  26. BIN book/a_regression/ordinary_least_squares_regression_result.pdf
  27. BIN book/a_regression/ordinary_least_squares_regression_result.png
  28. +1 −1 book/a_regression/stepwise_regression.tex
  29. BIN book/a_regression/stepwise_regression_result.pdf
  30. BIN book/a_regression/stepwise_regression_result.png
  31. +8 −8 src/algorithms/optimization/gradient_descent.R
  32. +11 −11 src/algorithms/optimization/stats_bfgs.R
  33. +11 −11 src/algorithms/optimization/stats_conjugate_gradient.R
  34. +6 −6 src/algorithms/optimization/stats_golden_section_search.R
  35. +13 −13 src/algorithms/optimization/stats_nelder_mead.R
  36. +3 −3 src/algorithms/regression/stats_logistic_regression.R
  37. +5 −5 src/algorithms/regression/stats_ordinary_least_squares.R
  38. +12 −12 src/algorithms/regression/stats_stepwise_linear_regression.R
  39. +8 −36 web/generate.rb
View
2 book/a_optimization/bfgs.tex
@@ -69,7 +69,7 @@ \subsection{Code Listing}
\begin{figure}[htp]
\centering
-\includegraphics[scale=0.45]{a_optimization/bfgs_result.pdf}
+\includegraphics[scale=0.45]{a_optimization/bfgs_result.png}
\caption{Contour plot of the Rosenbrock function with the located minimum highlighted.}
\label{plot:bfgs_result}
\end{figure}
View
BIN book/a_optimization/bfgs_result.pdf
Binary file not shown.
View
BIN book/a_optimization/bfgs_result.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
2 book/a_optimization/conjugate_gradient.tex
@@ -66,7 +66,7 @@ \subsection{Code Listing}
\begin{figure}[htp]
\centering
-\includegraphics[scale=0.45]{a_optimization/conjugate_gradient_result.pdf}
+\includegraphics[scale=0.45]{a_optimization/conjugate_gradient_result.png}
\caption{Contour plot of the Rosenbrock function with the located minimum highlighted.}
\label{plot:conjugate_gradient_result}
\end{figure}
View
BIN book/a_optimization/conjugate_gradient_result.pdf
Binary file not shown.
View
BIN book/a_optimization/conjugate_gradient_result.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
2 book/a_optimization/golden_section_search.tex
@@ -64,7 +64,7 @@ \subsection{Code Listing}
\begin{figure}[htp]
\centering
-\includegraphics[scale=0.45]{a_optimization/golden_section_search_result.pdf}
+\includegraphics[scale=0.45]{a_optimization/golden_section_search_result.png}
\caption{Plot of the basin function in one-dimension with the located minimum highlighted.}
\label{plot:golden_section_search_result}
\end{figure}
View
BIN book/a_optimization/golden_section_search_result.pdf
Binary file not shown.
View
BIN book/a_optimization/golden_section_search_result.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
2 book/a_optimization/gradient_descent.tex
@@ -65,7 +65,7 @@ \subsection{Code Listing}
\begin{figure}[htp]
\centering
-\includegraphics[scale=0.45]{a_optimization/gradient_descent_result.pdf}
+\includegraphics[scale=0.45]{a_optimization/gradient_descent_result.png}
\caption{Contour plot of the basin function with the located minimum highlighted.}
\label{plot:gradient_descent_result}
\end{figure}
View
BIN book/a_optimization/gradient_descent_result.pdf
Binary file not shown.
View
BIN book/a_optimization/gradient_descent_result.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
2 book/a_optimization/nelder_mead.tex
@@ -64,7 +64,7 @@ \subsection{Code Listing}
\begin{figure}[htp]
\centering
-\includegraphics[scale=0.45]{a_optimization/nelder_mead_result.pdf}
+\includegraphics[scale=0.45]{a_optimization/nelder_mead_result.png}
\caption{Contour plot of the Rosenbrock function with the located minimum highlighted.}
\label{plot:nelder_mead_result}
\end{figure}
View
BIN book/a_optimization/nelder_mead_result.pdf
Binary file not shown.
View
BIN book/a_optimization/nelder_mead_result.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
2 book/a_regression/locally_estimated_scatterplot_smoothing.tex
@@ -68,7 +68,7 @@ \subsection{Code Listing}
\begin{figure}[htp]
\centering
-\includegraphics[scale=0.45]{a_regression/locally_estimated_scatterplot_smoothing_result.pdf}
+\includegraphics[scale=0.45]{a_regression/locally_estimated_scatterplot_smoothing_result.png}
\caption{Plot 2D showing the predicted line of best fit for the test dataset.}
\label{plot:locally_estimated_scatterplot_smoothing_result}
\end{figure}
View
BIN book/a_regression/locally_estimated_scatterplot_smoothing_result.pdf
Binary file not shown.
View
BIN book/a_regression/locally_estimated_scatterplot_smoothing_result.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
2 book/a_regression/logistic_regression.tex
@@ -69,7 +69,7 @@ \subsection{Code Listing}
\begin{figure}[htp]
\centering
-\includegraphics[scale=0.45]{a_regression/logistic_regression_result.pdf}
+\includegraphics[scale=0.45]{a_regression/logistic_regression_result.png}
\caption{Plot 2D training dataset with the line of best fit.}
\label{plot:logistic_regression_result}
\end{figure}
View
BIN book/a_regression/logistic_regression_result.pdf
Binary file not shown.
View
BIN book/a_regression/logistic_regression_result.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
2 book/a_regression/multivariate_adaptive_regression_splines.tex
@@ -78,7 +78,7 @@ \subsection{Code Listing}
\begin{figure}[htp]
\centering
-\includegraphics[scale=0.45]{a_regression/multivariate_adaptive_regression_splines_result.pdf}
+\includegraphics[scale=0.45]{a_regression/multivariate_adaptive_regression_splines_result.png}
\caption{Plot 2D showing the line of best fit.}
\label{plot:multivariate_adaptive_regression_splines_result}
\end{figure}
View
BIN book/a_regression/multivariate_adaptive_regression_splines_result.pdf
Binary file not shown.
View
BIN book/a_regression/multivariate_adaptive_regression_splines_result.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
2 book/a_regression/ordinary_least_squares_regression.tex
@@ -67,7 +67,7 @@ \subsection{Code Listing}
\begin{figure}[htp]
\centering
-\includegraphics[scale=0.45]{a_regression/ordinary_least_squares_regression_result.pdf}
+\includegraphics[scale=0.45]{a_regression/ordinary_least_squares_regression_result.png}
\caption{Plot 2D training dataset with the line of best fit.}
\label{plot:ordinary_least_squares_regression_result}
\end{figure}
View
BIN book/a_regression/ordinary_least_squares_regression_result.pdf
Binary file not shown.
View
BIN book/a_regression/ordinary_least_squares_regression_result.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
2 book/a_regression/stepwise_regression.tex
@@ -68,7 +68,7 @@ \subsection{Code Listing}
\begin{figure}[htp]
\centering
-\includegraphics[scale=0.45]{a_regression/stepwise_regression_result.pdf}
+\includegraphics[scale=0.45]{a_regression/stepwise_regression_result.png}
\caption{Plot 2D training dataset with the line of best fit.}
\label{plot:stepwise_regression_result}
\end{figure}
View
BIN book/a_regression/stepwise_regression_result.pdf
Binary file not shown.
View
BIN book/a_regression/stepwise_regression_result.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
16 src/algorithms/optimization/gradient_descent.R
@@ -30,15 +30,15 @@ gradient_descent <- function(func, derv, start, step=0.05, tol=1e-8) {
# locate the minimum of the function using the Gradient Descent method
result <- gradient_descent(
- basin, # the function to optimize
- derivative, # the gradient of the function
- c(runif(1,-3,3), runif(1,-3,3)), # start point of the search
- 0.05, # step size (alpha)
- 1e-8) # relative tolerance for one step
+ basin, # the function to optimize
+ derivative, # the gradient of the function
+ c(runif(1,-3,3), runif(1,-3,3)), # start point of the search
+ 0.05, # step size (alpha)
+ 1e-8) # relative tolerance for one step
# display a summary of the results
-print(result) # coordinate of fucntion minimum
-print(basin(result)) # response of fucntion minimum
+print(result) # coordinate of fucntion minimum
+print(basin(result)) # response of fucntion minimum
# dispaly the function as a contour plot
x <- seq(-3, 3, length.out=100)
@@ -49,4 +49,4 @@ contour(x, y, matrix(z, length(x)), xlab="x",ylab="y")
points(result[1], result[2], col="red", pch=19)
# draw a square around the optima to highlight it
rect(result[1]-0.2, result[2]-0.2, result[1]+0.2,
- result[2]+0.2, lwd=2)
+ result[2]+0.2, lwd=2)
View
22 src/algorithms/optimization/stats_bfgs.R
@@ -17,18 +17,18 @@ derivative <- function(v) {
# locate the minimum of the function using the BFGS method
result <- optim(
- c(runif(1,-3,3), runif(1,-3,3)), # start at a random position
- rosenbrock, # the function to minimize
- derivative, # no function gradient
- method="BFGS", # use the BFGS method
- control=c( # configure BFGS
- maxit=100, # maximum iterations of 100
- reltol=1e-8)) # response tolerance over-one step
+ c(runif(1,-3,3), runif(1,-3,3)), # start at a random position
+ rosenbrock, # the function to minimize
+ derivative, # no function gradient
+ method="BFGS", # use the BFGS method
+ control=c( # configure BFGS
+ maxit=100, # maximum iterations of 100
+ reltol=1e-8)) # response tolerance over-one step
# summarise results
-print(result$par) # the coordinate of the minimim
-print(result$value) # the function response of the minimum
-print(result$counts) # the number of function calls performed
+print(result$par) # the coordinate of the minimim
+print(result$value) # the function response of the minimum
+print(result$counts) # the number of function calls performed
# dispaly the function as a contour plot
x <- seq(-3, 3, length.out=100)
@@ -39,4 +39,4 @@ contour(x, y, matrix(log10(z), length(x)), xlab="x", ylab="y")
points(result$par[1], result$par[2], col="red", pch=19)
# draw a square around the optima to highlight it
rect(result$par[1]-0.2, result$par[2]-0.2, result$par[1]+0.2,
- result$par[2]+0.2, lwd=2)
+ result$par[2]+0.2, lwd=2)
View
22 src/algorithms/optimization/stats_conjugate_gradient.R
@@ -17,19 +17,19 @@ derivative <- function(v) {
# locate the minimum of the function using the Conjugate Gradient method
result <- optim(
- c(runif(1,-3,3), runif(1,-3,3)), # start at a random position
- rosenbrock, # the function to minimize
- derivative, # no function gradient
- method="CG", # use the Conjugate Gradient method
- control=c( # configure Conjugate Gradient
- maxit=100, # maximum iterations of 100
- reltol=1e-8, # response tolerance over-one step
- type=2)) # use the Polak-Ribiere update method
+ c(runif(1,-3,3), runif(1,-3,3)), # start at a random position
+ rosenbrock, # the function to minimize
+ derivative, # no function gradient
+ method="CG", # use the Conjugate Gradient method
+ control=c( # configure Conjugate Gradient
+ maxit=100, # maximum iterations of 100
+ reltol=1e-8, # response tolerance over-one step
+ type=2)) # use the Polak-Ribiere update method
# summarise results
-print(result$par) # the coordinate of the minimim
-print(result$value) # the function response of the minimum
-print(result$counts) # the number of function calls performed
+print(result$par) # the coordinate of the minimim
+print(result$value) # the function response of the minimum
+print(result$counts) # the number of function calls performed
# dispaly the function as a contour plot
x <- seq(-3, 3, length.out=100)
View
12 src/algorithms/optimization/stats_golden_section_search.R
@@ -11,14 +11,14 @@ basin <- function(x) {
# # locate the minimum of the function using a Golden Section Line Search
result <- optimize(
- basin, # the function to be minimized
- c(-5, 5), # the bounds on the function paramter
- maximum=FALSE, # we are concerned with the function minima
- tol=1e-8) # the size of the final bracketing
+ basin, # the function to be minimized
+ c(-5, 5), # the bounds on the function paramter
+ maximum=FALSE, # we are concerned with the function minima
+ tol=1e-8) # the size of the final bracketing
# display the results
-print(result$minimum) # function parameter
-print(result$objective) # function response
+print(result$minimum) #function parameter
+print(result$objective) # function response
# plot the function
x <- seq(-5, 5, length.out=100)
View
26 src/algorithms/optimization/stats_nelder_mead.R
@@ -11,21 +11,21 @@ rosenbrock <- function(v) {
# locate the minimum of the function using the Nelder-Mead method
result <- optim(
- c(runif(1,-3,3), runif(1,-3,3)), # start at a random position
- rosenbrock, # the function to minimize
- NULL, # no function gradient
- method="Nelder-Mead", # use the Nelder-Mead method
- control=c( # configure Nelder-Mead
- maxit=100, # maximum iterations of 100
- reltol=1e-8, # response tolerance over-one step
- alpha=1.0, # reflection factor
- beta=0.5, # contraction factor
- gamma=2.0)) # expansion factor
+ c(runif(1,-3,3), runif(1,-3,3)), # start at a random position
+ rosenbrock, # the function to minimize
+ NULL, # no function gradient
+ method="Nelder-Mead", # use the Nelder-Mead method
+ control=c( # configure Nelder-Mead
+ maxit=100, # maximum iterations of 100
+ reltol=1e-8, # response tolerance over-one step
+ alpha=1.0, # reflection factor
+ beta=0.5, # contraction factor
+ gamma=2.0)) # expansion factor
# summarise results
-print(result$par) # the coordinate of the minimim
-print(result$value) # the function response of the minimum
-print(result$counts) # the number of function calls performed
+print(result$par) # the coordinate of the minimim
+print(result$value) # the function response of the minimum
+print(result$counts) # the number of function calls performed
# dispaly the function as a contour plot
x <- seq(-3, 3, length.out=100)
View
6 src/algorithms/regression/stats_logistic_regression.R
@@ -21,9 +21,9 @@ test <- data[(1:100)[-training_set],]
# create the discriminator using Logistic Regression
model <- glm(
- z~x+y, # model formula, z give x and y
- binomial(link="logit"), # binomial using a logit link function
- train) # the training dataset
+ z~x+y, # model formula, z give x and y
+ binomial(link="logit"), # binomial using a logit link function
+ train) # the training dataset
# summarize the fitted model
summary(model)
View
10 src/algorithms/regression/stats_ordinary_least_squares.R
@@ -20,11 +20,11 @@ test <- data[(1:100)[-training_set],]
# create a linear regression model using ordinary least squares
model <- lm(
- y~x, # predict Y given X
- train, # training dataset
- NULL, # no weighting on the variables
- NULL, # no action on missing values
- method="qr") # QR decomposition (efficient matrix calculation method)
+ y~x, # predict Y given X
+ train, # training dataset
+ NULL, # no weighting on the variables
+ NULL, # no action on missing values
+ method="qr") # QR decomposition (efficient matrix calculation method)
# summarize the create linear regression model
summary(model)
View
24 src/algorithms/regression/stats_stepwise_linear_regression.R
@@ -22,22 +22,22 @@ test <- data[(1:100)[-training_set],]
# create a linear regression model using ordinary least squares
base_model <- lm(
- y~x1+x2+x3, # predict y given x1, x2 and x3
- train, # training dataset
- NULL, # no weighting on the variables
- NULL, # no action on missing values
+ y~x1+x2+x3, # predict y given x1, x2 and x3
+ train, # training dataset
+ NULL, # no weighting on the variables
+ NULL, # no action on missing values
method="qr") # QR decomposition (efficient matrix calculation method)
# apply the Stepwise Regression procedure
selected_model <- step(
- base_model, # the model on which to operate
- y~x1+x2+x3, # parameter relationships
- 0, # estimate the scale for the AIC statistic
- "both", # use forward and backward selection
- 1, # provide debug information during the execution
- NULL, # no filter function for models
- 1000, # maximum steps to execute
- 2) # Use AIC as the test criterion (use log(n) for BIC)
+ base_model, # the model on which to operate
+ y~x1+x2+x3, # parameter relationships
+ 0, # estimate the scale for the AIC statistic
+ "both", # use forward and backward selection
+ 1, # provide debug information during the execution
+ NULL, # no filter function for models
+ 1000, # maximum steps to execute
+ 2) # Use AIC as the test criterion (use log(n) for BIC)
# summarize the selected linear regression model
summary(selected_model)
View
44 web/generate.rb
@@ -395,10 +395,7 @@ def final_pretty_code_listing(lines, caption=nil, ruby_filename=nil)
# pretty print does not like <> brackets
raw = process_angle_brackets_and_ampersands(raw)
s = ""
- # table is a hack to ensure lines wrap
- add_line(s, "<pre class='prettyprint'>")
- add_line(s, raw)
- add_line(s, "</pre>")
+ add_line(s, "<pre class='prettyprint'>#{raw}</pre>")
if !caption.nil?
caption = post_process_text(caption) # process text
add_line(s, "<div class='caption'>#{caption}</div>")
@@ -416,7 +413,7 @@ def pretty_print_code_listing(code_listing_line)
# get the caption
parts = code_listing_line.split(",")
raise "Caption not where expected" if !starts_with?(parts[2], "caption")
- caption = parts[2][(parts[2].index("=")+1)..-1]
+ caption = parts[2][(parts[2].index("=")+2)...-1]
raw = IO.readlines(filename)
ruby_filename = filename[(filename.rindex("/")+1)..-1]
# trim top 7 lines
@@ -737,7 +734,7 @@ def process_figure(lines)
caption = post_process_text(caption) # processing of text
just_file = filename[(filename.index('/')+1)..-1]
s = ""
- add_line(s, "<img src='/images/#{just_file}.png' align='middle' alt='#{caption}' class='book_image'>")
+ add_line(s, "<img src='/images/machinelearning/#{just_file}' align='middle' alt='#{caption}' class='book_image'>")
add_line(s, "<br />")
add_line(s, "<div class='caption'>#{caption}</div>")
@@ -1512,45 +1509,20 @@ def get_ruby_into_position(chapters)
# locate link to file
filename = nil
lines.each do |line|
- if starts_with?(line.strip, "\\lstinputlisting[firstline=")
+ if starts_with?(line.strip, "\\lstinputlisting[firstline=")
+ line = line[line.rindex("{")..-1]
filename = get_data_in_brackets(line)
break
end
end
- raise "could not locate ruby file in #{source + "/" + file}" if filename.nil?
+ raise "could not locate R file in #{source + "/" + file}" if filename.nil?
# load
raw = IO.readlines(filename)
ruby_filename = OUTPUT_DIR + "/" + chapter + "/" + filename[(filename.rindex("/")+1)..-1]
# write
File.open(ruby_filename, 'w') {|f| f.write(raw.join("")) }
end
end
- # process advanced chapter
- begin
- chapter = "advanced"
- source = "../book/c_"+chapter
- Dir.entries(source).each do |file|
- next if file == "." or file == ".."
- next if File.extname(file) != ".tex"
- # load and process the algorithm
- lines = get_all_data_lines(source + "/" + file)
- # locate link to file
- filenames = []
- lines.each do |line|
- if starts_with?(line.strip, "\\lstinputlisting[")
- filenames << get_data_in_brackets(line)
- end
- end
- next if filenames.empty? # some have no files
- # load
- filenames.each do |filename|
- raw = IO.readlines(filename)
- ruby_filename = OUTPUT_DIR + "/" + chapter + "/" + filename[(filename.rindex("/")+1)..-1]
- # write
- File.open(ruby_filename, 'w') {|f| f.write(raw.join("")) }
- end
- end
- end
end
def add_image(s, host, filename)
@@ -1648,8 +1620,8 @@ def create_sitemap
# build_appendix(bib)
# eratta
# build_errata(bib)
- # ruby files
-# get_ruby_into_position(ALGORITHM_CHAPTERS)
+ # R files
+ get_ruby_into_position(ALGORITHM_CHAPTERS_COMPLETED)
# site map
# create_sitemap
end

0 comments on commit 14850c0

Please sign in to comment.