diff --git a/doc/pub/LogReg/html/._LogReg-bs000.html b/doc/pub/LogReg/html/._LogReg-bs000.html index 8fab13972..9d3836b5b 100644 --- a/doc/pub/LogReg/html/._LogReg-bs000.html +++ b/doc/pub/LogReg/html/._LogReg-bs000.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Logistic Regression @@ -54,18 +55,7 @@ Automatically generated HTML file from DocOnce source ('Extending to more predictors', 2, None, '___sec11'), ('Including more classes', 2, None, '___sec12'), ('The Softmax function', 2, None, '___sec13'), - ('A _scikit-learn_ example', 2, None, '___sec14'), - ('A simple classification problem', 2, None, '___sec15'), - ('The two-dimensional Ising model, Predicting phase transition ' - 'of the two-dimensional Ising model', - 2, - None, - '___sec16'), - ('Reading in the data', 2, None, '___sec17'), - ('Logistic regression', 2, None, '___sec18'), - ('Exploring the logistic regression', 2, None, '___sec19'), - ('Accuracy of a classification model', 2, None, '___sec20'), - ('Analyzing the results', 2, None, '___sec21')]} + ('A simple classification problem', 2, None, '___sec14')]} end of tocinfo --> @@ -117,14 +107,7 @@ MathJax.Hub.Config({
  • Extending to more predictors
  • Including more classes
  • The Softmax function
  • -
  • A scikit-learn example
  • -
  • A simple classification problem
  • -
  • The two-dimensional Ising model, Predicting phase transition of the two-dimensional Ising model
  • -
  • Reading in the data
  • -
  • Logistic regression
  • -
  • Exploring the logistic regression
  • -
  • Accuracy of a classification model
  • -
  • Analyzing the results
  • +
  • A simple classification problem
  • @@ -159,7 +142,7 @@ MathJax.Hub.Config({
    [2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University

    -

    Oct 18, 2018

    +

    Sep 15, 2019


    @@ -176,7 +159,7 @@ MathJax.Hub.Config({

  • 9
  • 10
  • ...
  • -
  • 23
  • +
  • 16
  • »
  • @@ -194,7 +177,7 @@ MathJax.Hub.Config({
    - © 1999-2018, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license + © 1999-2019, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license
    diff --git a/doc/pub/LogReg/html/._LogReg-bs001.html b/doc/pub/LogReg/html/._LogReg-bs001.html index 5db3db0a4..2095cfecf 100644 --- a/doc/pub/LogReg/html/._LogReg-bs001.html +++ b/doc/pub/LogReg/html/._LogReg-bs001.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Logistic Regression @@ -54,18 +55,7 @@ Automatically generated HTML file from DocOnce source ('Extending to more predictors', 2, None, '___sec11'), ('Including more classes', 2, None, '___sec12'), ('The Softmax function', 2, None, '___sec13'), - ('A _scikit-learn_ example', 2, None, '___sec14'), - ('A simple classification problem', 2, None, '___sec15'), - ('The two-dimensional Ising model, Predicting phase transition ' - 'of the two-dimensional Ising model', - 2, - None, - '___sec16'), - ('Reading in the data', 2, None, '___sec17'), - ('Logistic regression', 2, None, '___sec18'), - ('Exploring the logistic regression', 2, None, '___sec19'), - ('Accuracy of a classification model', 2, None, '___sec20'), - ('Analyzing the results', 2, None, '___sec21')]} + ('A simple classification problem', 2, None, '___sec14')]} end of tocinfo --> @@ -117,14 +107,7 @@ MathJax.Hub.Config({
  • Extending to more predictors
  • Including more classes
  • The Softmax function
  • -
  • A scikit-learn example
  • -
  • A simple classification problem
  • -
  • The two-dimensional Ising model, Predicting phase transition of the two-dimensional Ising model
  • -
  • Reading in the data
  • -
  • Logistic regression
  • -
  • Exploring the logistic regression
  • -
  • Accuracy of a classification model
  • -
  • Analyzing the results
  • +
  • A simple classification problem
  • @@ -151,7 +134,7 @@ coefficients of a functional fit (say a polynomial) in order to be able to predict the response of a continuous variable on some unseen data. The fit to the continuous variable \( y_i \) is based on some independent variables \( \hat{x}_i \). Linear regression resulted in -analytical expressions (in terms of matrices to invert) for several +analytical expressions for standard ordinary Least Squares or Ridge regression (in terms of matrices to invert) for several quantities, ranging from the variance and thereby the confidence intervals of the parameters \( \hat{\beta} \) to the mean squared error. If we can invert the product of the design matrices, linear @@ -192,7 +175,7 @@ failure etc.
  • 10
  • 11
  • ...
  • -
  • 23
  • +
  • 16
  • »
  • diff --git a/doc/pub/LogReg/html/._LogReg-bs002.html b/doc/pub/LogReg/html/._LogReg-bs002.html index a8a440ed7..e468c1a6d 100644 --- a/doc/pub/LogReg/html/._LogReg-bs002.html +++ b/doc/pub/LogReg/html/._LogReg-bs002.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Logistic Regression @@ -54,18 +55,7 @@ Automatically generated HTML file from DocOnce source ('Extending to more predictors', 2, None, '___sec11'), ('Including more classes', 2, None, '___sec12'), ('The Softmax function', 2, None, '___sec13'), - ('A _scikit-learn_ example', 2, None, '___sec14'), - ('A simple classification problem', 2, None, '___sec15'), - ('The two-dimensional Ising model, Predicting phase transition ' - 'of the two-dimensional Ising model', - 2, - None, - '___sec16'), - ('Reading in the data', 2, None, '___sec17'), - ('Logistic regression', 2, None, '___sec18'), - ('Exploring the logistic regression', 2, None, '___sec19'), - ('Accuracy of a classification model', 2, None, '___sec20'), - ('Analyzing the results', 2, None, '___sec21')]} + ('A simple classification problem', 2, None, '___sec14')]} end of tocinfo --> @@ -117,14 +107,7 @@ MathJax.Hub.Config({
  • Extending to more predictors
  • Including more classes
  • The Softmax function
  • -
  • A scikit-learn example
  • -
  • A simple classification problem
  • -
  • The two-dimensional Ising model, Predicting phase transition of the two-dimensional Ising model
  • -
  • Reading in the data
  • -
  • Logistic regression
  • -
  • Exploring the logistic regression
  • -
  • Accuracy of a classification model
  • -
  • Analyzing the results
  • +
  • A simple classification problem
  • @@ -146,7 +129,7 @@ MathJax.Hub.Config({ Logistic regression will also serve as our stepping stone towards neural network algorithms and supervised deep learning. For logistic learning, the minimization of the cost function leads to a non-linear -equation in the parameters \( \hat{\beta} \). The optmization of the problem calls therefore for minimization algorithms. This forms the bottle neck of all machine learning algorithms, namely how to find reliable minima of a multi-variable function. This leads us to the family of gradient descent methods. The latter are the working horses of basically all modern machine learning algorithms. +equation in the parameters \( \hat{\beta} \). The optimization of the problem calls therefore for minimization algorithms. This forms the bottle neck of all machine learning algorithms, namely how to find reliable minima of a multi-variable function. This leads us to the family of gradient descent methods. The latter are the working horses of basically all modern machine learning algorithms.

    We note also that many of the topics discussed here @@ -171,7 +154,7 @@ models, as we will see later.

  • 11
  • 12
  • ...
  • -
  • 23
  • +
  • 16
  • »
  • diff --git a/doc/pub/LogReg/html/._LogReg-bs003.html b/doc/pub/LogReg/html/._LogReg-bs003.html index dec304cb8..e2d495a52 100644 --- a/doc/pub/LogReg/html/._LogReg-bs003.html +++ b/doc/pub/LogReg/html/._LogReg-bs003.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Logistic Regression @@ -54,18 +55,7 @@ Automatically generated HTML file from DocOnce source ('Extending to more predictors', 2, None, '___sec11'), ('Including more classes', 2, None, '___sec12'), ('The Softmax function', 2, None, '___sec13'), - ('A _scikit-learn_ example', 2, None, '___sec14'), - ('A simple classification problem', 2, None, '___sec15'), - ('The two-dimensional Ising model, Predicting phase transition ' - 'of the two-dimensional Ising model', - 2, - None, - '___sec16'), - ('Reading in the data', 2, None, '___sec17'), - ('Logistic regression', 2, None, '___sec18'), - ('Exploring the logistic regression', 2, None, '___sec19'), - ('Accuracy of a classification model', 2, None, '___sec20'), - ('Analyzing the results', 2, None, '___sec21')]} + ('A simple classification problem', 2, None, '___sec14')]} end of tocinfo --> @@ -117,14 +107,7 @@ MathJax.Hub.Config({
  • Extending to more predictors
  • Including more classes
  • The Softmax function
  • -
  • A scikit-learn example
  • -
  • A simple classification problem
  • -
  • The two-dimensional Ising model, Predicting phase transition of the two-dimensional Ising model
  • -
  • Reading in the data
  • -
  • Logistic regression
  • -
  • Exploring the logistic regression
  • -
  • Accuracy of a classification model
  • -
  • Analyzing the results
  • +
  • A simple classification problem
  • @@ -179,7 +162,7 @@ $$
  • 12
  • 13
  • ...
  • -
  • 23
  • +
  • 16
  • »
  • diff --git a/doc/pub/LogReg/html/._LogReg-bs004.html b/doc/pub/LogReg/html/._LogReg-bs004.html index 96da937a7..4b0292fa7 100644 --- a/doc/pub/LogReg/html/._LogReg-bs004.html +++ b/doc/pub/LogReg/html/._LogReg-bs004.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Logistic Regression @@ -54,18 +55,7 @@ Automatically generated HTML file from DocOnce source ('Extending to more predictors', 2, None, '___sec11'), ('Including more classes', 2, None, '___sec12'), ('The Softmax function', 2, None, '___sec13'), - ('A _scikit-learn_ example', 2, None, '___sec14'), - ('A simple classification problem', 2, None, '___sec15'), - ('The two-dimensional Ising model, Predicting phase transition ' - 'of the two-dimensional Ising model', - 2, - None, - '___sec16'), - ('Reading in the data', 2, None, '___sec17'), - ('Logistic regression', 2, None, '___sec18'), - ('Exploring the logistic regression', 2, None, '___sec19'), - ('Accuracy of a classification model', 2, None, '___sec20'), - ('Analyzing the results', 2, None, '___sec21')]} + ('A simple classification problem', 2, None, '___sec14')]} end of tocinfo --> @@ -117,14 +107,7 @@ MathJax.Hub.Config({
  • Extending to more predictors
  • Including more classes
  • The Softmax function
  • -
  • A scikit-learn example
  • -
  • A simple classification problem
  • -
  • The two-dimensional Ising model, Predicting phase transition of the two-dimensional Ising model
  • -
  • Reading in the data
  • -
  • Logistic regression
  • -
  • Exploring the logistic regression
  • -
  • Accuracy of a classification model
  • -
  • Analyzing the results
  • +
  • A simple classification problem
  • @@ -178,7 +161,7 @@ where \( \hat{y} \) is a vector representing the possible outcomes, \( \hat{X} \
  • 13
  • 14
  • ...
  • -
  • 23
  • +
  • 16
  • »
  • diff --git a/doc/pub/LogReg/html/._LogReg-bs005.html b/doc/pub/LogReg/html/._LogReg-bs005.html index 8c4df61ba..3643eddc5 100644 --- a/doc/pub/LogReg/html/._LogReg-bs005.html +++ b/doc/pub/LogReg/html/._LogReg-bs005.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Logistic Regression @@ -54,18 +55,7 @@ Automatically generated HTML file from DocOnce source ('Extending to more predictors', 2, None, '___sec11'), ('Including more classes', 2, None, '___sec12'), ('The Softmax function', 2, None, '___sec13'), - ('A _scikit-learn_ example', 2, None, '___sec14'), - ('A simple classification problem', 2, None, '___sec15'), - ('The two-dimensional Ising model, Predicting phase transition ' - 'of the two-dimensional Ising model', - 2, - None, - '___sec16'), - ('Reading in the data', 2, None, '___sec17'), - ('Logistic regression', 2, None, '___sec18'), - ('Exploring the logistic regression', 2, None, '___sec19'), - ('Accuracy of a classification model', 2, None, '___sec20'), - ('Analyzing the results', 2, None, '___sec21')]} + ('A simple classification problem', 2, None, '___sec14')]} end of tocinfo --> @@ -117,14 +107,7 @@ MathJax.Hub.Config({
  • Extending to more predictors
  • Including more classes
  • The Softmax function
  • -
  • A scikit-learn example
  • -
  • A simple classification problem
  • -
  • The two-dimensional Ising model, Predicting phase transition of the two-dimensional Ising model
  • -
  • Reading in the data
  • -
  • Logistic regression
  • -
  • Exploring the logistic regression
  • -
  • Accuracy of a classification model
  • -
  • Analyzing the results
  • +
  • A simple classification problem
  • @@ -185,7 +168,7 @@ The code for plotting the perceptron can be seen here. This si nothing but the s
  • 14
  • 15
  • ...
  • -
  • 23
  • +
  • 16
  • »
  • diff --git a/doc/pub/LogReg/html/._LogReg-bs006.html b/doc/pub/LogReg/html/._LogReg-bs006.html index c222d091c..7ec6b80f2 100644 --- a/doc/pub/LogReg/html/._LogReg-bs006.html +++ b/doc/pub/LogReg/html/._LogReg-bs006.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Logistic Regression @@ -54,18 +55,7 @@ Automatically generated HTML file from DocOnce source ('Extending to more predictors', 2, None, '___sec11'), ('Including more classes', 2, None, '___sec12'), ('The Softmax function', 2, None, '___sec13'), - ('A _scikit-learn_ example', 2, None, '___sec14'), - ('A simple classification problem', 2, None, '___sec15'), - ('The two-dimensional Ising model, Predicting phase transition ' - 'of the two-dimensional Ising model', - 2, - None, - '___sec16'), - ('Reading in the data', 2, None, '___sec17'), - ('Logistic regression', 2, None, '___sec18'), - ('Exploring the logistic regression', 2, None, '___sec19'), - ('Accuracy of a classification model', 2, None, '___sec20'), - ('Analyzing the results', 2, None, '___sec21')]} + ('A simple classification problem', 2, None, '___sec14')]} end of tocinfo --> @@ -117,14 +107,7 @@ MathJax.Hub.Config({
  • Extending to more predictors
  • Including more classes
  • The Softmax function
  • -
  • A scikit-learn example
  • -
  • A simple classification problem
  • -
  • The two-dimensional Ising model, Predicting phase transition of the two-dimensional Ising model
  • -
  • Reading in the data
  • -
  • Logistic regression
  • -
  • Exploring the logistic regression
  • -
  • Accuracy of a classification model
  • -
  • Analyzing the results
  • +
  • A simple classification problem
  • @@ -185,8 +168,6 @@ The following code plots the logistic function.
  • 14
  • 15
  • 16
  • -
  • ...
  • -
  • 23
  • »
  • diff --git a/doc/pub/LogReg/html/._LogReg-bs007.html b/doc/pub/LogReg/html/._LogReg-bs007.html index f45a73acc..35f605577 100644 --- a/doc/pub/LogReg/html/._LogReg-bs007.html +++ b/doc/pub/LogReg/html/._LogReg-bs007.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Logistic Regression @@ -54,18 +55,7 @@ Automatically generated HTML file from DocOnce source ('Extending to more predictors', 2, None, '___sec11'), ('Including more classes', 2, None, '___sec12'), ('The Softmax function', 2, None, '___sec13'), - ('A _scikit-learn_ example', 2, None, '___sec14'), - ('A simple classification problem', 2, None, '___sec15'), - ('The two-dimensional Ising model, Predicting phase transition ' - 'of the two-dimensional Ising model', - 2, - None, - '___sec16'), - ('Reading in the data', 2, None, '___sec17'), - ('Logistic regression', 2, None, '___sec18'), - ('Exploring the logistic regression', 2, None, '___sec19'), - ('Accuracy of a classification model', 2, None, '___sec20'), - ('Analyzing the results', 2, None, '___sec21')]} + ('A simple classification problem', 2, None, '___sec14')]} end of tocinfo --> @@ -117,14 +107,7 @@ MathJax.Hub.Config({
  • Extending to more predictors
  • Including more classes
  • The Softmax function
  • -
  • A scikit-learn example
  • -
  • A simple classification problem
  • -
  • The two-dimensional Ising model, Predicting phase transition of the two-dimensional Ising model
  • -
  • Reading in the data
  • -
  • Logistic regression
  • -
  • Exploring the logistic regression
  • -
  • Accuracy of a classification model
  • -
  • Analyzing the results
  • +
  • A simple classification problem
  • @@ -180,9 +163,6 @@ $$
  • 14
  • 15
  • 16
  • -
  • 17
  • -
  • ...
  • -
  • 23
  • »
  • diff --git a/doc/pub/LogReg/html/._LogReg-bs008.html b/doc/pub/LogReg/html/._LogReg-bs008.html index fba0a6992..62f4afddc 100644 --- a/doc/pub/LogReg/html/._LogReg-bs008.html +++ b/doc/pub/LogReg/html/._LogReg-bs008.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Logistic Regression @@ -54,18 +55,7 @@ Automatically generated HTML file from DocOnce source ('Extending to more predictors', 2, None, '___sec11'), ('Including more classes', 2, None, '___sec12'), ('The Softmax function', 2, None, '___sec13'), - ('A _scikit-learn_ example', 2, None, '___sec14'), - ('A simple classification problem', 2, None, '___sec15'), - ('The two-dimensional Ising model, Predicting phase transition ' - 'of the two-dimensional Ising model', - 2, - None, - '___sec16'), - ('Reading in the data', 2, None, '___sec17'), - ('Logistic regression', 2, None, '___sec18'), - ('Exploring the logistic regression', 2, None, '___sec19'), - ('Accuracy of a classification model', 2, None, '___sec20'), - ('Analyzing the results', 2, None, '___sec21')]} + ('A simple classification problem', 2, None, '___sec14')]} end of tocinfo --> @@ -117,14 +107,7 @@ MathJax.Hub.Config({
  • Extending to more predictors
  • Including more classes
  • The Softmax function
  • -
  • A scikit-learn example
  • -
  • A simple classification problem
  • -
  • The two-dimensional Ising model, Predicting phase transition of the two-dimensional Ising model
  • -
  • Reading in the data
  • -
  • Logistic regression
  • -
  • Exploring the logistic regression
  • -
  • Accuracy of a classification model
  • -
  • Analyzing the results
  • +
  • A simple classification problem
  • @@ -181,10 +164,6 @@ $$
  • 14
  • 15
  • 16
  • -
  • 17
  • -
  • 18
  • -
  • ...
  • -
  • 23
  • »
  • diff --git a/doc/pub/LogReg/html/._LogReg-bs009.html b/doc/pub/LogReg/html/._LogReg-bs009.html index 1b49c8783..af1c8886f 100644 --- a/doc/pub/LogReg/html/._LogReg-bs009.html +++ b/doc/pub/LogReg/html/._LogReg-bs009.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Logistic Regression @@ -54,18 +55,7 @@ Automatically generated HTML file from DocOnce source ('Extending to more predictors', 2, None, '___sec11'), ('Including more classes', 2, None, '___sec12'), ('The Softmax function', 2, None, '___sec13'), - ('A _scikit-learn_ example', 2, None, '___sec14'), - ('A simple classification problem', 2, None, '___sec15'), - ('The two-dimensional Ising model, Predicting phase transition ' - 'of the two-dimensional Ising model', - 2, - None, - '___sec16'), - ('Reading in the data', 2, None, '___sec17'), - ('Logistic regression', 2, None, '___sec18'), - ('Exploring the logistic regression', 2, None, '___sec19'), - ('Accuracy of a classification model', 2, None, '___sec20'), - ('Analyzing the results', 2, None, '___sec21')]} + ('A simple classification problem', 2, None, '___sec14')]} end of tocinfo --> @@ -117,14 +107,7 @@ MathJax.Hub.Config({
  • Extending to more predictors
  • Including more classes
  • The Softmax function
  • -
  • A scikit-learn example
  • -
  • A simple classification problem
  • -
  • The two-dimensional Ising model, Predicting phase transition of the two-dimensional Ising model
  • -
  • Reading in the data
  • -
  • Logistic regression
  • -
  • Exploring the logistic regression
  • -
  • Accuracy of a classification model
  • -
  • Analyzing the results
  • +
  • A simple classification problem
  • @@ -179,11 +162,6 @@ in practice we often supplement the cross-entropy with additional regularization
  • 14
  • 15
  • 16
  • -
  • 17
  • -
  • 18
  • -
  • 19
  • -
  • ...
  • -
  • 23
  • »
  • diff --git a/doc/pub/LogReg/html/._LogReg-bs010.html b/doc/pub/LogReg/html/._LogReg-bs010.html index 3b006a5aa..f22f85bb5 100644 --- a/doc/pub/LogReg/html/._LogReg-bs010.html +++ b/doc/pub/LogReg/html/._LogReg-bs010.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Logistic Regression @@ -54,18 +55,7 @@ Automatically generated HTML file from DocOnce source ('Extending to more predictors', 2, None, '___sec11'), ('Including more classes', 2, None, '___sec12'), ('The Softmax function', 2, None, '___sec13'), - ('A _scikit-learn_ example', 2, None, '___sec14'), - ('A simple classification problem', 2, None, '___sec15'), - ('The two-dimensional Ising model, Predicting phase transition ' - 'of the two-dimensional Ising model', - 2, - None, - '___sec16'), - ('Reading in the data', 2, None, '___sec17'), - ('Logistic regression', 2, None, '___sec18'), - ('Exploring the logistic regression', 2, None, '___sec19'), - ('Accuracy of a classification model', 2, None, '___sec20'), - ('Analyzing the results', 2, None, '___sec21')]} + ('A simple classification problem', 2, None, '___sec14')]} end of tocinfo --> @@ -117,14 +107,7 @@ MathJax.Hub.Config({
  • Extending to more predictors
  • Including more classes
  • The Softmax function
  • -
  • A scikit-learn example
  • -
  • A simple classification problem
  • -
  • The two-dimensional Ising model, Predicting phase transition of the two-dimensional Ising model
  • -
  • Reading in the data
  • -
  • Logistic regression
  • -
  • Exploring the logistic regression
  • -
  • Accuracy of a classification model
  • -
  • Analyzing the results
  • +
  • A simple classification problem
  • @@ -180,12 +163,6 @@ $$
  • 14
  • 15
  • 16
  • -
  • 17
  • -
  • 18
  • -
  • 19
  • -
  • 20
  • -
  • ...
  • -
  • 23
  • »
  • diff --git a/doc/pub/LogReg/html/._LogReg-bs011.html b/doc/pub/LogReg/html/._LogReg-bs011.html index ac18ad1e7..c597e5e18 100644 --- a/doc/pub/LogReg/html/._LogReg-bs011.html +++ b/doc/pub/LogReg/html/._LogReg-bs011.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Logistic Regression @@ -54,18 +55,7 @@ Automatically generated HTML file from DocOnce source ('Extending to more predictors', 2, None, '___sec11'), ('Including more classes', 2, None, '___sec12'), ('The Softmax function', 2, None, '___sec13'), - ('A _scikit-learn_ example', 2, None, '___sec14'), - ('A simple classification problem', 2, None, '___sec15'), - ('The two-dimensional Ising model, Predicting phase transition ' - 'of the two-dimensional Ising model', - 2, - None, - '___sec16'), - ('Reading in the data', 2, None, '___sec17'), - ('Logistic regression', 2, None, '___sec18'), - ('Exploring the logistic regression', 2, None, '___sec19'), - ('Accuracy of a classification model', 2, None, '___sec20'), - ('Analyzing the results', 2, None, '___sec21')]} + ('A simple classification problem', 2, None, '___sec14')]} end of tocinfo --> @@ -117,14 +107,7 @@ MathJax.Hub.Config({
  • Extending to more predictors
  • Including more classes
  • The Softmax function
  • -
  • A scikit-learn example
  • -
  • A simple classification problem
  • -
  • The two-dimensional Ising model, Predicting phase transition of the two-dimensional Ising model
  • -
  • Reading in the data
  • -
  • Logistic regression
  • -
  • Exploring the logistic regression
  • -
  • Accuracy of a classification model
  • -
  • Analyzing the results
  • +
  • A simple classification problem
  • @@ -180,13 +163,6 @@ $$
  • 14
  • 15
  • 16
  • -
  • 17
  • -
  • 18
  • -
  • 19
  • -
  • 20
  • -
  • 21
  • -
  • ...
  • -
  • 23
  • »
  • diff --git a/doc/pub/LogReg/html/._LogReg-bs012.html b/doc/pub/LogReg/html/._LogReg-bs012.html index 9b7cef547..fa36cbbe8 100644 --- a/doc/pub/LogReg/html/._LogReg-bs012.html +++ b/doc/pub/LogReg/html/._LogReg-bs012.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Logistic Regression @@ -54,18 +55,7 @@ Automatically generated HTML file from DocOnce source ('Extending to more predictors', 2, None, '___sec11'), ('Including more classes', 2, None, '___sec12'), ('The Softmax function', 2, None, '___sec13'), - ('A _scikit-learn_ example', 2, None, '___sec14'), - ('A simple classification problem', 2, None, '___sec15'), - ('The two-dimensional Ising model, Predicting phase transition ' - 'of the two-dimensional Ising model', - 2, - None, - '___sec16'), - ('Reading in the data', 2, None, '___sec17'), - ('Logistic regression', 2, None, '___sec18'), - ('Exploring the logistic regression', 2, None, '___sec19'), - ('Accuracy of a classification model', 2, None, '___sec20'), - ('Analyzing the results', 2, None, '___sec21')]} + ('A simple classification problem', 2, None, '___sec14')]} end of tocinfo --> @@ -117,14 +107,7 @@ MathJax.Hub.Config({
  • Extending to more predictors
  • Including more classes
  • The Softmax function
  • -
  • A scikit-learn example
  • -
  • A simple classification problem
  • -
  • The two-dimensional Ising model, Predicting phase transition of the two-dimensional Ising model
  • -
  • Reading in the data
  • -
  • Logistic regression
  • -
  • Exploring the logistic regression
  • -
  • Accuracy of a classification model
  • -
  • Analyzing the results
  • +
  • A simple classification problem
  • @@ -172,14 +155,6 @@ $$
  • 14
  • 15
  • 16
  • -
  • 17
  • -
  • 18
  • -
  • 19
  • -
  • 20
  • -
  • 21
  • -
  • 22
  • -
  • ...
  • -
  • 23
  • »
  • diff --git a/doc/pub/LogReg/html/._LogReg-bs013.html b/doc/pub/LogReg/html/._LogReg-bs013.html index 8ddff5150..c5d1f4666 100644 --- a/doc/pub/LogReg/html/._LogReg-bs013.html +++ b/doc/pub/LogReg/html/._LogReg-bs013.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Logistic Regression @@ -54,18 +55,7 @@ Automatically generated HTML file from DocOnce source ('Extending to more predictors', 2, None, '___sec11'), ('Including more classes', 2, None, '___sec12'), ('The Softmax function', 2, None, '___sec13'), - ('A _scikit-learn_ example', 2, None, '___sec14'), - ('A simple classification problem', 2, None, '___sec15'), - ('The two-dimensional Ising model, Predicting phase transition ' - 'of the two-dimensional Ising model', - 2, - None, - '___sec16'), - ('Reading in the data', 2, None, '___sec17'), - ('Logistic regression', 2, None, '___sec18'), - ('Exploring the logistic regression', 2, None, '___sec19'), - ('Accuracy of a classification model', 2, None, '___sec20'), - ('Analyzing the results', 2, None, '___sec21')]} + ('A simple classification problem', 2, None, '___sec14')]} end of tocinfo --> @@ -117,14 +107,7 @@ MathJax.Hub.Config({
  • Extending to more predictors
  • Including more classes
  • The Softmax function
  • -
  • A scikit-learn example
  • -
  • A simple classification problem
  • -
  • The two-dimensional Ising model, Predicting phase transition of the two-dimensional Ising model
  • -
  • Reading in the data
  • -
  • Logistic regression
  • -
  • Exploring the logistic regression
  • -
  • Accuracy of a classification model
  • -
  • Analyzing the results
  • +
  • A simple classification problem
  • @@ -178,13 +161,6 @@ and the model is specified in term of \( K-1 \) so-called log-odds or logit14
  • 15
  • 16
  • -
  • 17
  • -
  • 18
  • -
  • 19
  • -
  • 20
  • -
  • 21
  • -
  • 22
  • -
  • 23
  • »
  • diff --git a/doc/pub/LogReg/html/._LogReg-bs014.html b/doc/pub/LogReg/html/._LogReg-bs014.html index 39329d58d..efe955f12 100644 --- a/doc/pub/LogReg/html/._LogReg-bs014.html +++ b/doc/pub/LogReg/html/._LogReg-bs014.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Logistic Regression @@ -54,18 +55,7 @@ Automatically generated HTML file from DocOnce source ('Extending to more predictors', 2, None, '___sec11'), ('Including more classes', 2, None, '___sec12'), ('The Softmax function', 2, None, '___sec13'), - ('A _scikit-learn_ example', 2, None, '___sec14'), - ('A simple classification problem', 2, None, '___sec15'), - ('The two-dimensional Ising model, Predicting phase transition ' - 'of the two-dimensional Ising model', - 2, - None, - '___sec16'), - ('Reading in the data', 2, None, '___sec17'), - ('Logistic regression', 2, None, '___sec18'), - ('Exploring the logistic regression', 2, None, '___sec19'), - ('Accuracy of a classification model', 2, None, '___sec20'), - ('Analyzing the results', 2, None, '___sec21')]} + ('A simple classification problem', 2, None, '___sec14')]} end of tocinfo --> @@ -117,14 +107,7 @@ MathJax.Hub.Config({
  • Extending to more predictors
  • Including more classes
  • The Softmax function
  • -
  • A scikit-learn example
  • -
  • A simple classification problem
  • -
  • The two-dimensional Ising model, Predicting phase transition of the two-dimensional Ising model
  • -
  • Reading in the data
  • -
  • Logistic regression
  • -
  • Exploring the logistic regression
  • -
  • Accuracy of a classification model
  • -
  • Analyzing the results
  • +
  • A simple classification problem
  • @@ -187,13 +170,6 @@ Newton's method and gradient descent methods are discussed in the material on 14
  • 15
  • 16
  • -
  • 17
  • -
  • 18
  • -
  • 19
  • -
  • 20
  • -
  • 21
  • -
  • 22
  • -
  • 23
  • »
  • diff --git a/doc/pub/LogReg/html/._LogReg-bs015.html b/doc/pub/LogReg/html/._LogReg-bs015.html index 24de58783..c4732d14a 100644 --- a/doc/pub/LogReg/html/._LogReg-bs015.html +++ b/doc/pub/LogReg/html/._LogReg-bs015.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Logistic Regression @@ -54,18 +55,7 @@ Automatically generated HTML file from DocOnce source ('Extending to more predictors', 2, None, '___sec11'), ('Including more classes', 2, None, '___sec12'), ('The Softmax function', 2, None, '___sec13'), - ('A _scikit-learn_ example', 2, None, '___sec14'), - ('A simple classification problem', 2, None, '___sec15'), - ('The two-dimensional Ising model, Predicting phase transition ' - 'of the two-dimensional Ising model', - 2, - None, - '___sec16'), - ('Reading in the data', 2, None, '___sec17'), - ('Logistic regression', 2, None, '___sec18'), - ('Exploring the logistic regression', 2, None, '___sec19'), - ('Accuracy of a classification model', 2, None, '___sec20'), - ('Analyzing the results', 2, None, '___sec21')]} + ('A simple classification problem', 2, None, '___sec14')]} end of tocinfo --> @@ -117,14 +107,7 @@ MathJax.Hub.Config({
  • Extending to more predictors
  • Including more classes
  • The Softmax function
  • -
  • A scikit-learn example
  • -
  • A simple classification problem
  • -
  • The two-dimensional Ising model, Predicting phase transition of the two-dimensional Ising model
  • -
  • Reading in the data
  • -
  • Logistic regression
  • -
  • Exploring the logistic regression
  • -
  • Accuracy of a classification model
  • -
  • Analyzing the results
  • +
  • A simple classification problem
  • @@ -140,31 +123,62 @@ MathJax.Hub.Config({ -

    A scikit-learn example

    - +

    A simple classification problem

    import numpy as np
    +from sklearn import datasets, linear_model
     import matplotlib.pyplot as plt
    -from sklearn import datasets
    -iris = datasets.load_iris()
    -list(iris.keys())
    -['data', 'target_names', 'feature_names', 'target', 'DESCR']
    -X = iris["data"][:, 3:] # petal width
    -y = (iris["target"] == 2).astype(np.int) # 1 if Iris-Virginica, else 0
     
    -from sklearn.linear_model import LogisticRegression
    -log_reg = LogisticRegression()
    -log_reg.fit(X, y)
     
    -X_new = np.linspace(0, 3, 1000).reshape(-1, 1)
    -y_proba = log_reg.predict_proba(X_new)
    -plt.plot(X_new, y_proba[:, 1], "g-", label="Iris-Virginica")
    -plt.plot(X_new, y_proba[:, 0], "b--", label="Not Iris-Virginica")
    -plt.show()
    +def generate_data():
    +    np.random.seed(0)
    +    X, y = datasets.make_moons(200, noise=0.20)
    +    return X, y
    +
    +
    +def visualize(X, y, clf):
    +    # plt.scatter(X[:, 0], X[:, 1], s=40, c=y, cmap=plt.cm.Spectral)
    +    # plt.show()
    +    plot_decision_boundary(lambda x: clf.predict(x), X, y)
    +    plt.title("Logistic Regression")
    +
    +
    +def plot_decision_boundary(pred_func, X, y):
    +    # Set min and max values and give it some padding
    +    x_min, x_max = X[:, 0].min() - .5, X[:, 0].max() + .5
    +    y_min, y_max = X[:, 1].min() - .5, X[:, 1].max() + .5
    +    h = 0.01
    +    # Generate a grid of points with distance h between them
    +    xx, yy = np.meshgrid(np.arange(x_min, x_max, h), np.arange(y_min, y_max, h))
    +    # Predict the function value for the whole gid
    +    Z = pred_func(np.c_[xx.ravel(), yy.ravel()])
    +    Z = Z.reshape(xx.shape)
    +    # Plot the contour and training examples
    +    plt.contourf(xx, yy, Z, cmap=plt.cm.Spectral)
    +    plt.scatter(X[:, 0], X[:, 1], c=y, cmap=plt.cm.Spectral)
    +    plt.show()
    +
    +
    +def classify(X, y):
    +    clf = linear_model.LogisticRegressionCV()
    +    clf.fit(X, y)
    +    return clf
    +
    +
    +def main():
    +    X, y = generate_data()
    +    # visualize(X, y)
    +    clf = classify(X, y)
    +    visualize(X, y, clf)
    +
    +
    +if __name__ == "__main__":
    +    main()
     

    +

    diff --git a/doc/pub/LogReg/html/LogReg-bs.html b/doc/pub/LogReg/html/LogReg-bs.html index 8fab13972..9d3836b5b 100644 --- a/doc/pub/LogReg/html/LogReg-bs.html +++ b/doc/pub/LogReg/html/LogReg-bs.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Logistic Regression @@ -54,18 +55,7 @@ Automatically generated HTML file from DocOnce source ('Extending to more predictors', 2, None, '___sec11'), ('Including more classes', 2, None, '___sec12'), ('The Softmax function', 2, None, '___sec13'), - ('A _scikit-learn_ example', 2, None, '___sec14'), - ('A simple classification problem', 2, None, '___sec15'), - ('The two-dimensional Ising model, Predicting phase transition ' - 'of the two-dimensional Ising model', - 2, - None, - '___sec16'), - ('Reading in the data', 2, None, '___sec17'), - ('Logistic regression', 2, None, '___sec18'), - ('Exploring the logistic regression', 2, None, '___sec19'), - ('Accuracy of a classification model', 2, None, '___sec20'), - ('Analyzing the results', 2, None, '___sec21')]} + ('A simple classification problem', 2, None, '___sec14')]} end of tocinfo --> @@ -117,14 +107,7 @@ MathJax.Hub.Config({
  • Extending to more predictors
  • Including more classes
  • The Softmax function
  • -
  • A scikit-learn example
  • -
  • A simple classification problem
  • -
  • The two-dimensional Ising model, Predicting phase transition of the two-dimensional Ising model
  • -
  • Reading in the data
  • -
  • Logistic regression
  • -
  • Exploring the logistic regression
  • -
  • Accuracy of a classification model
  • -
  • Analyzing the results
  • +
  • A simple classification problem
  • @@ -159,7 +142,7 @@ MathJax.Hub.Config({
    [2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University

    -

    Oct 18, 2018

    +

    Sep 15, 2019


    @@ -176,7 +159,7 @@ MathJax.Hub.Config({

  • 9
  • 10
  • ...
  • -
  • 23
  • +
  • 16
  • »
  • @@ -194,7 +177,7 @@ MathJax.Hub.Config({
    - © 1999-2018, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license + © 1999-2019, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license
    diff --git a/doc/pub/LogReg/html/LogReg-reveal.html b/doc/pub/LogReg/html/LogReg-reveal.html index 01452dbe0..e73834476 100644 --- a/doc/pub/LogReg/html/LogReg-reveal.html +++ b/doc/pub/LogReg/html/LogReg-reveal.html @@ -1,8 +1,8 @@ -\ + Data Analysis and Machine Learning: Logistic Regression @@ -148,12 +148,12 @@ MathJax.Hub.Config({
    [2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University

     
    -

    Oct 18, 2018

    +

    Sep 15, 2019


    - © 1999-2018, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license + © 1999-2019, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license
    @@ -167,7 +167,7 @@ coefficients of a functional fit (say a polynomial) in order to be able to predict the response of a continuous variable on some unseen data. The fit to the continuous variable \( y_i \) is based on some independent variables \( \hat{x}_i \). Linear regression resulted in -analytical expressions (in terms of matrices to invert) for several +analytical expressions for standard ordinary Least Squares or Ridge regression (in terms of matrices to invert) for several quantities, ranging from the variance and thereby the confidence intervals of the parameters \( \hat{\beta} \) to the mean squared error. If we can invert the product of the design matrices, linear @@ -200,7 +200,7 @@ failure etc. Logistic regression will also serve as our stepping stone towards neural network algorithms and supervised deep learning. For logistic learning, the minimization of the cost function leads to a non-linear -equation in the parameters \( \hat{\beta} \). The optmization of the problem calls therefore for minimization algorithms. This forms the bottle neck of all machine learning algorithms, namely how to find reliable minima of a multi-variable function. This leads us to the family of gradient descent methods. The latter are the working horses of basically all modern machine learning algorithms. +equation in the parameters \( \hat{\beta} \). The optimization of the problem calls therefore for minimization algorithms. This forms the bottle neck of all machine learning algorithms, namely how to find reliable minima of a multi-variable function. This leads us to the family of gradient descent methods. The latter are the working horses of basically all modern machine learning algorithms.

    We note also that many of the topics discussed here @@ -533,35 +533,7 @@ Newton's method and gradient descent methods are discussed in the material on -

    A scikit-learn example

    - -

    - - -

    import numpy as np
    -import matplotlib.pyplot as plt
    -from sklearn import datasets
    -iris = datasets.load_iris()
    -list(iris.keys())
    -['data', 'target_names', 'feature_names', 'target', 'DESCR']
    -X = iris["data"][:, 3:] # petal width
    -y = (iris["target"] == 2).astype(np.int) # 1 if Iris-Virginica, else 0
    -
    -from sklearn.linear_model import LogisticRegression
    -log_reg = LogisticRegression()
    -log_reg.fit(X, y)
    -
    -X_new = np.linspace(0, 3, 1000).reshape(-1, 1)
    -y_proba = log_reg.predict_proba(X_new)
    -plt.plot(X_new, y_proba[:, 1], "g-", label="Iris-Virginica")
    -plt.plot(X_new, y_proba[:, 0], "b--", label="Not Iris-Virginica")
    -plt.show()
    -
    - - - -
    -

    A simple classification problem

    +

    A simple classification problem

    @@ -618,341 +590,6 @@ plt.show()

    -
    -

    The two-dimensional Ising model, Predicting phase transition of the two-dimensional Ising model

    - -

    -The Hamiltonian of the two-dimensional Ising model without an external field for a constant coupling constant \( J \) is given by -

     
    -$$ -\begin{align} - H = -J \sum_{\langle ij\rangle} S_i S_j, -\tag{2} -\end{align} -$$ -

     
    - -where \( S_i \in \{-1, 1\} \) and \( \langle ij \rangle \) signifies that we only iterate over the nearest neighbors in the lattice. We will be looking at a system of \( L = 40 \) spins in each dimension, i.e., \( L^2 = 1600 \) spins in total. Opposed to the one-dimensional Ising model we will get a phase transition from an ordered phase to a disordered phase at the critical temperature - -

     
    -$$ -\begin{align} - \frac{T_c}{J} = \frac{2}{\log\left(1 + \sqrt{2}\right)} \approx 2.26, -\tag{3} -\end{align} -$$ -

     
    - -as shown by Lars Onsager. - -

    -Here we use logistic regression to predict when a phase transition -occurs. The data we will look at is a set of spin configurations, -i.e., individual lattices with spins, labeled ordered 1 or -disordered 0. Our job is to build a model which will take in a -spin configuration and predict whether or not the spin configuration -constitutes an ordered or a disordered phase. To achieve this we will -represent the lattices as flattened arrays with \( 1600 \) elements -instead of a matrix of \( 40 \times 40 \) elements. As an extra test of -the performance of the algorithms we will divide the dataset into -three pieces. We will do a conventional train-test-split on a -combination of totally ordered and totally disordered phases. The -remaining "critical-like" states will be used as test data which we -hope the model will be able to make good extrapolated predictions on. - -

    - - -

    import pickle
    -import os
    -import glob
    -import numpy as np
    -import pandas as pd
    -import matplotlib.pyplot as plt
    -import seaborn as sns
    -import sklearn.model_selection as skms
    -import sklearn.linear_model as skl
    -import sklearn.metrics as skm
    -import tqdm
    -import copy
    -import time
    -from IPython.display import display
    -
    -%matplotlib inline
    -
    -sns.set(color_codes=True)
    -
    -
    - - -
    -

    Reading in the data

    - -

    -Using the data from Mehta et al. (specifically the two datasets named Ising2DFM_reSample_L40_T=All.pkl and Ising2DFM_reSample_L40_T=All_labels.pkl) we have to unpack the data into numpy arrays. - -

    - - -

    filenames = glob.glob(os.path.join("..", "dat", "*"))
    -label_filename = list(filter(lambda x: "label" in x, filenames))[0]
    -dat_filename = list(filter(lambda x: "label" not in x, filenames))[0]
    -
    -# Read in the labels
    -with open(label_filename, "rb") as f:
    -    labels = pickle.load(f)
    -
    -# Read in the corresponding configurations
    -with open(dat_filename, "rb") as f:
    -    data = np.unpackbits(pickle.load(f)).reshape(-1, 1600).astype("int")
    -
    -# Set spin-down to -1
    -data[data == 0] = -1
    -
    -

    -This dataset consists of \( 10000 \) samples, i.e., \( 10000 \) spin -configurations with \( 40 \times 40 \) spins each, for \( 16 \) temperatures -between \( 0.25 \) to \( 4.0 \). Next we create a train/test-split and keep -the data in the critical phase as a separate dataset for -extrapolation-testing. - -

    - - -

    # Set up slices of the dataset
    -ordered = slice(0, 70000)
    -critical = slice(70000, 100000)
    -disordered = slice(100000, 160000)
    -
    -X_train, X_test, y_train, y_test = skms.train_test_split(
    -    np.concatenate((data[ordered], data[disordered])),
    -    np.concatenate((labels[ordered], labels[disordered])),
    -    test_size=0.95
    -)
    -
    -
    - - -
    -

    Logistic regression

    - -

    -Logistic regression is a linear model for classification. Recalling -the cost function for ordinary least squares with both L2 (ridge) and -L1 (LASSO) penalties we will see that the logistic cost function is -very similar. In OLS we wish to predict a continuous variable -\( \hat{y} \) using -

     
    -$$ -\begin{align} - \hat{y} = X\omega, -\tag{4} -\end{align} -$$ -

     
    - -

    -where \( X \in \mathbb{R}^{n \times p} \) is the input data and \( \omega^{p -\times d} \) are the weights of the regression. In a classification -setting (binary classification in our situation) we are interested in -a positive or negative answer. We can thus define either answer to be -above or below some threshold. But, in order to limit the size of the -answer and also to get a probability interpretation on how sure we are -for either answer we can compute the sigmoid function of OLS. That is, - -

     
    -$$ -\begin{align} - f(X\omega) = \frac{1}{1 + \exp(-X\omega)}. -\tag{5} -\end{align} -$$ -

     
    - -We are thus interested in minizming the following cost function -

     
    -$$ -\begin{align} - C(X, \omega) = \sum_{i = 1}^n \left\{ - - y_i\log\left( f(x_i^T\omega) \right) - - (1 - y_i)\log\left[1 - f(x_i^T\omega)\right] - \right\}, -\tag{6} -\end{align} -$$ -

     
    - -

    -where we will restrict ourselves to a value for \( f(z) \) as the sigmoid -described above. We can also tack on a L2 (Ridge) or L1 (LASSO) -penalization to this cost function in the same manner we did for -linear regression. -

    - - -
    -

    Exploring the logistic regression

    - -

    -The penalization factor \( \lambda \) is inverted in the case of the -logistic regression model we use. We will explore several values of -\( \lambda \) using both L1 and L2 penalization. We do this using a grid -search over different parameters and run a 3-fold cross validation for -each configuration. In other words, we fit a model 3 times for each -configuration of the hyper parameters. - -

    - - -

    lambdas = np.logspace(-7, -1, 7)
    -
    -param_grid = {
    -    "C": list(1.0/lambdas),
    -    "penalty": ["l1", "l2"]
    -}
    -clf = skms.GridSearchCV(
    -    skl.LogisticRegression(),
    -    param_grid=param_grid,
    -    n_jobs=-1,
    -    return_train_score=True
    -)
    -t0 = time.time()
    -clf.fit(X_train, y_train)
    -t1 = time.time()
    -
    -print (
    -    "Time spent fitting GridSearchCV(LogisticRegression): {0:.3f} sec".format(
    -        t1 - t0
    -    )
    -)
    -
    -

    -We can see that logistic regression is quite slow and using the grid -search and cross validation results in quite a heavy -computation. Below we show the results of the different -configurations. - -

    - - -

    logreg_df = pd.DataFrame(clf.cv_results_)
    -
    -display(logreg_df)
    -
    -
    - - -
    -

    Accuracy of a classification model

    - -

    -To determine how well a classification model is performing we count -the number of correctly labeled classes and divide by the number of -classes in total. The accuracy is thus given by - -

     
    -$$ -\begin{align} - a(y, \hat{y}) = \frac{1}{n}\sum_{i = 1}^{n} I(y_i = \hat{y}_i), -\tag{7} -\end{align} -$$ -

     
    - -

    -where \( I(y_i = \hat{y}_i) \) is the indicator function given by - -

     
    -$$ -\begin{align} - I(x = y) = \begin{array}{cc} - 1 & x = y, \\ - 0 & x \neq y. - \end{array} -\tag{8} -\end{align}$$ -

     
    - -

    -This is the accuracy provided by Scikit-learn when using sklearn.metrics.accuracyscore. - -

    -Below we compute the accuracy of the best fit model on the training data (which should give a good accuracy), the test data (which has not been shown to the model) and the critical data (completely new data that needs to be extrapolated). - -

    - - -

    train_accuracy = skm.accuracy_score(y_train, clf.predict(X_train))
    -test_accuracy = skm.accuracy_score(y_test, clf.predict(X_test))
    -critical_accuracy = skm.accuracy_score(labels[critical], clf.predict(data[critical]))
    -
    -print ("Accuracy on train data: {0}".format(train_accuracy))
    -print ("Accuracy on test data: {0}".format(test_accuracy))
    -print ("Accuracy on critical data: {0}".format(critical_accuracy))
    -
    -

    -We can see that we get quite good accuracy on the training data, but gradually worsening accuracy on the test and critical data. -

    - - -
    -

    Analyzing the results

    - -

    -Below we show a different metric for determining the quality of our -model, namely the reciever operating characteristic (ROC). The ROC -curve tells us how well the model correctly classifies the different -labels. We plot the true positive rate (the rate of predicted -positive classes that are positive) versus the false positive rate -(the rate of predicted positive classes that are negative). The ROC -curve is built by computing the true positive rate and the false -positive rate for varying thresholds, i.e, which probability we -should acredit a certain class. - -

    -By computing the area under the curve (AUC) of the ROC curve we get an estimate of how well our model is performing. Pure guessing will get an AUC of \( 0.5 \). A perfect score will get an AUC of \( 1.0 \). - -

    - - -

    fig = plt.figure(figsize=(20, 14))
    -
    -for (_X, _y), label in zip(
    -    [
    -        (X_train, y_train),
    -        (X_test, y_test),
    -        (data[critical], labels[critical])
    -    ],
    -    ["Train", "Test", "Critical"]
    -):
    -    proba = clf.predict_proba(_X)
    -    fpr, tpr, _ = skm.roc_curve(_y, proba[:, 1])
    -    roc_auc = skm.auc(fpr, tpr)
    -
    -    print ("LogisticRegression AUC ({0}): {1}".format(label, roc_auc))
    -
    -    plt.plot(fpr, tpr, label="{0} (AUC = {1})".format(label, roc_auc), linewidth=4.0)
    -
    -plt.plot([0, 1], [0, 1], "--", label="Guessing (AUC = 0.5)", linewidth=4.0)
    -
    -plt.title(r"The ROC curve for LogisticRegression", fontsize=18)
    -plt.xlabel(r"False positive rate", fontsize=18)
    -plt.ylabel(r"True positive rate", fontsize=18)
    -plt.axis([-0.01, 1.01, -0.01, 1.01])
    -plt.xticks(fontsize=18)
    -plt.yticks(fontsize=18)
    -plt.legend(loc="best", fontsize=18)
    -plt.show()
    -
    -

    -We can see that this plot of the ROC looks very strange. This tells us -that logistic regression is quite inept at predicting the Ising model -transition and is therefore highly non-linear. The ROC curve for the -training data looks quite good, but as the testing data is so far off -we see that we are dealing with an overfit model. -

    - - diff --git a/doc/pub/LogReg/html/LogReg-solarized.html b/doc/pub/LogReg/html/LogReg-solarized.html index 963a161fc..a3e0789bb 100644 --- a/doc/pub/LogReg/html/LogReg-solarized.html +++ b/doc/pub/LogReg/html/LogReg-solarized.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Logistic Regression @@ -48,18 +49,7 @@ div { text-align: justify; text-justify: inter-word; } ('Extending to more predictors', 2, None, '___sec11'), ('Including more classes', 2, None, '___sec12'), ('The Softmax function', 2, None, '___sec13'), - ('A _scikit-learn_ example', 2, None, '___sec14'), - ('A simple classification problem', 2, None, '___sec15'), - ('The two-dimensional Ising model, Predicting phase transition ' - 'of the two-dimensional Ising model', - 2, - None, - '___sec16'), - ('Reading in the data', 2, None, '___sec17'), - ('Logistic regression', 2, None, '___sec18'), - ('Exploring the logistic regression', 2, None, '___sec19'), - ('Accuracy of a classification model', 2, None, '___sec20'), - ('Analyzing the results', 2, None, '___sec21')]} + ('A simple classification problem', 2, None, '___sec14')]} end of tocinfo --> @@ -101,7 +91,7 @@ MathJax.Hub.Config({
    [2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University

    -

    Oct 18, 2018

    +

    Sep 15, 2019


    @@ -114,7 +104,7 @@ coefficients of a functional fit (say a polynomial) in order to be able to predict the response of a continuous variable on some unseen data. The fit to the continuous variable \( y_i \) is based on some independent variables \( \hat{x}_i \). Linear regression resulted in -analytical expressions (in terms of matrices to invert) for several +analytical expressions for standard ordinary Least Squares or Ridge regression (in terms of matrices to invert) for several quantities, ranging from the variance and thereby the confidence intervals of the parameters \( \hat{\beta} \) to the mean squared error. If we can invert the product of the design matrices, linear @@ -147,7 +137,7 @@ failure etc. Logistic regression will also serve as our stepping stone towards neural network algorithms and supervised deep learning. For logistic learning, the minimization of the cost function leads to a non-linear -equation in the parameters \( \hat{\beta} \). The optmization of the problem calls therefore for minimization algorithms. This forms the bottle neck of all machine learning algorithms, namely how to find reliable minima of a multi-variable function. This leads us to the family of gradient descent methods. The latter are the working horses of basically all modern machine learning algorithms. +equation in the parameters \( \hat{\beta} \). The optimization of the problem calls therefore for minimization algorithms. This forms the bottle neck of all machine learning algorithms, namely how to find reliable minima of a multi-variable function. This leads us to the family of gradient descent methods. The latter are the working horses of basically all modern machine learning algorithms.

    We note also that many of the topics discussed here @@ -438,34 +428,7 @@ Newton's method and gradient descent methods are discussed in the material on









    -

    A scikit-learn example

    - -

    - - -

    import numpy as np
    -import matplotlib.pyplot as plt
    -from sklearn import datasets
    -iris = datasets.load_iris()
    -list(iris.keys())
    -['data', 'target_names', 'feature_names', 'target', 'DESCR']
    -X = iris["data"][:, 3:] # petal width
    -y = (iris["target"] == 2).astype(np.int) # 1 if Iris-Virginica, else 0
    -
    -from sklearn.linear_model import LogisticRegression
    -log_reg = LogisticRegression()
    -log_reg.fit(X, y)
    -
    -X_new = np.linspace(0, 3, 1000).reshape(-1, 1)
    -y_proba = log_reg.predict_proba(X_new)
    -plt.plot(X_new, y_proba[:, 1], "g-", label="Iris-Virginica")
    -plt.plot(X_new, y_proba[:, 0], "b--", label="Not Iris-Virginica")
    -plt.show()
    -
    -

    -









    - -

    A simple classification problem

    +

    A simple classification problem

    @@ -519,331 +482,13 @@ plt.show() if __name__ == "__main__": main() -

    - - -

    The two-dimensional Ising model, Predicting phase transition of the two-dimensional Ising model

    - -

    -The Hamiltonian of the two-dimensional Ising model without an external field for a constant coupling constant \( J \) is given by -$$ -\begin{align} - H = -J \sum_{\langle ij\rangle} S_i S_j, -\label{_auto2} -\end{align} -$$ - -where \( S_i \in \{-1, 1\} \) and \( \langle ij \rangle \) signifies that we only iterate over the nearest neighbors in the lattice. We will be looking at a system of \( L = 40 \) spins in each dimension, i.e., \( L^2 = 1600 \) spins in total. Opposed to the one-dimensional Ising model we will get a phase transition from an ordered phase to a disordered phase at the critical temperature - -$$ -\begin{align} - \frac{T_c}{J} = \frac{2}{\log\left(1 + \sqrt{2}\right)} \approx 2.26, -\label{_auto3} -\end{align} -$$ - -as shown by Lars Onsager. - -

    -Here we use logistic regression to predict when a phase transition -occurs. The data we will look at is a set of spin configurations, -i.e., individual lattices with spins, labeled ordered 1 or -disordered 0. Our job is to build a model which will take in a -spin configuration and predict whether or not the spin configuration -constitutes an ordered or a disordered phase. To achieve this we will -represent the lattices as flattened arrays with \( 1600 \) elements -instead of a matrix of \( 40 \times 40 \) elements. As an extra test of -the performance of the algorithms we will divide the dataset into -three pieces. We will do a conventional train-test-split on a -combination of totally ordered and totally disordered phases. The -remaining "critical-like" states will be used as test data which we -hope the model will be able to make good extrapolated predictions on. - -

    - - -

    import pickle
    -import os
    -import glob
    -import numpy as np
    -import pandas as pd
    -import matplotlib.pyplot as plt
    -import seaborn as sns
    -import sklearn.model_selection as skms
    -import sklearn.linear_model as skl
    -import sklearn.metrics as skm
    -import tqdm
    -import copy
    -import time
    -from IPython.display import display
    -
    -%matplotlib inline
    -
    -sns.set(color_codes=True)
    -
    -

    -









    - -

    Reading in the data

    - -

    -Using the data from Mehta et al. (specifically the two datasets named Ising2DFM_reSample_L40_T=All.pkl and Ising2DFM_reSample_L40_T=All_labels.pkl) we have to unpack the data into numpy arrays. - -

    - - -

    filenames = glob.glob(os.path.join("..", "dat", "*"))
    -label_filename = list(filter(lambda x: "label" in x, filenames))[0]
    -dat_filename = list(filter(lambda x: "label" not in x, filenames))[0]
    -
    -# Read in the labels
    -with open(label_filename, "rb") as f:
    -    labels = pickle.load(f)
    -
    -# Read in the corresponding configurations
    -with open(dat_filename, "rb") as f:
    -    data = np.unpackbits(pickle.load(f)).reshape(-1, 1600).astype("int")
    -
    -# Set spin-down to -1
    -data[data == 0] = -1
    -
    -

    -This dataset consists of \( 10000 \) samples, i.e., \( 10000 \) spin -configurations with \( 40 \times 40 \) spins each, for \( 16 \) temperatures -between \( 0.25 \) to \( 4.0 \). Next we create a train/test-split and keep -the data in the critical phase as a separate dataset for -extrapolation-testing. - -

    - - -

    # Set up slices of the dataset
    -ordered = slice(0, 70000)
    -critical = slice(70000, 100000)
    -disordered = slice(100000, 160000)
    -
    -X_train, X_test, y_train, y_test = skms.train_test_split(
    -    np.concatenate((data[ordered], data[disordered])),
    -    np.concatenate((labels[ordered], labels[disordered])),
    -    test_size=0.95
    -)
    -
    -

    -









    - -

    Logistic regression

    - -

    -Logistic regression is a linear model for classification. Recalling -the cost function for ordinary least squares with both L2 (ridge) and -L1 (LASSO) penalties we will see that the logistic cost function is -very similar. In OLS we wish to predict a continuous variable -\( \hat{y} \) using -$$ -\begin{align} - \hat{y} = X\omega, -\label{_auto4} -\end{align} -$$ - -

    -where \( X \in \mathbb{R}^{n \times p} \) is the input data and \( \omega^{p -\times d} \) are the weights of the regression. In a classification -setting (binary classification in our situation) we are interested in -a positive or negative answer. We can thus define either answer to be -above or below some threshold. But, in order to limit the size of the -answer and also to get a probability interpretation on how sure we are -for either answer we can compute the sigmoid function of OLS. That is, - -$$ -\begin{align} - f(X\omega) = \frac{1}{1 + \exp(-X\omega)}. -\label{_auto5} -\end{align} -$$ - -We are thus interested in minizming the following cost function -$$ -\begin{align} - C(X, \omega) = \sum_{i = 1}^n \left\{ - - y_i\log\left( f(x_i^T\omega) \right) - - (1 - y_i)\log\left[1 - f(x_i^T\omega)\right] - \right\}, -\label{_auto6} -\end{align} -$$ - -

    -where we will restrict ourselves to a value for \( f(z) \) as the sigmoid -described above. We can also tack on a L2 (Ridge) or L1 (LASSO) -penalization to this cost function in the same manner we did for -linear regression. - -

    -









    - -

    Exploring the logistic regression

    - -

    -The penalization factor \( \lambda \) is inverted in the case of the -logistic regression model we use. We will explore several values of -\( \lambda \) using both L1 and L2 penalization. We do this using a grid -search over different parameters and run a 3-fold cross validation for -each configuration. In other words, we fit a model 3 times for each -configuration of the hyper parameters. - -

    - - -

    lambdas = np.logspace(-7, -1, 7)
    -
    -param_grid = {
    -    "C": list(1.0/lambdas),
    -    "penalty": ["l1", "l2"]
    -}
    -clf = skms.GridSearchCV(
    -    skl.LogisticRegression(),
    -    param_grid=param_grid,
    -    n_jobs=-1,
    -    return_train_score=True
    -)
    -t0 = time.time()
    -clf.fit(X_train, y_train)
    -t1 = time.time()
    -
    -print (
    -    "Time spent fitting GridSearchCV(LogisticRegression): {0:.3f} sec".format(
    -        t1 - t0
    -    )
    -)
    -
    -

    -We can see that logistic regression is quite slow and using the grid -search and cross validation results in quite a heavy -computation. Below we show the results of the different -configurations. - -

    - - -

    logreg_df = pd.DataFrame(clf.cv_results_)
    -
    -display(logreg_df)
    -
    -

    -









    - -

    Accuracy of a classification model

    - -

    -To determine how well a classification model is performing we count -the number of correctly labeled classes and divide by the number of -classes in total. The accuracy is thus given by - -$$ -\begin{align} - a(y, \hat{y}) = \frac{1}{n}\sum_{i = 1}^{n} I(y_i = \hat{y}_i), -\label{_auto7} -\end{align} -$$ - -

    -where \( I(y_i = \hat{y}_i) \) is the indicator function given by - -$$ -\begin{align} - I(x = y) = \begin{array}{cc} - 1 & x = y, \\ - 0 & x \neq y. - \end{array} -\label{_auto8} -\end{align}$$ - -

    -This is the accuracy provided by Scikit-learn when using sklearn.metrics.accuracyscore. - -

    -Below we compute the accuracy of the best fit model on the training data (which should give a good accuracy), the test data (which has not been shown to the model) and the critical data (completely new data that needs to be extrapolated). - -

    - - -

    train_accuracy = skm.accuracy_score(y_train, clf.predict(X_train))
    -test_accuracy = skm.accuracy_score(y_test, clf.predict(X_test))
    -critical_accuracy = skm.accuracy_score(labels[critical], clf.predict(data[critical]))
    -
    -print ("Accuracy on train data: {0}".format(train_accuracy))
    -print ("Accuracy on test data: {0}".format(test_accuracy))
    -print ("Accuracy on critical data: {0}".format(critical_accuracy))
    -
    -

    -We can see that we get quite good accuracy on the training data, but gradually worsening accuracy on the test and critical data. - -

    -









    - -

    Analyzing the results

    - -

    -Below we show a different metric for determining the quality of our -model, namely the reciever operating characteristic (ROC). The ROC -curve tells us how well the model correctly classifies the different -labels. We plot the true positive rate (the rate of predicted -positive classes that are positive) versus the false positive rate -(the rate of predicted positive classes that are negative). The ROC -curve is built by computing the true positive rate and the false -positive rate for varying thresholds, i.e, which probability we -should acredit a certain class. - -

    -By computing the area under the curve (AUC) of the ROC curve we get an estimate of how well our model is performing. Pure guessing will get an AUC of \( 0.5 \). A perfect score will get an AUC of \( 1.0 \). - -

    - - -

    fig = plt.figure(figsize=(20, 14))
    -
    -for (_X, _y), label in zip(
    -    [
    -        (X_train, y_train),
    -        (X_test, y_test),
    -        (data[critical], labels[critical])
    -    ],
    -    ["Train", "Test", "Critical"]
    -):
    -    proba = clf.predict_proba(_X)
    -    fpr, tpr, _ = skm.roc_curve(_y, proba[:, 1])
    -    roc_auc = skm.auc(fpr, tpr)
    -
    -    print ("LogisticRegression AUC ({0}): {1}".format(label, roc_auc))
    -
    -    plt.plot(fpr, tpr, label="{0} (AUC = {1})".format(label, roc_auc), linewidth=4.0)
    -
    -plt.plot([0, 1], [0, 1], "--", label="Guessing (AUC = 0.5)", linewidth=4.0)
    -
    -plt.title(r"The ROC curve for LogisticRegression", fontsize=18)
    -plt.xlabel(r"False positive rate", fontsize=18)
    -plt.ylabel(r"True positive rate", fontsize=18)
    -plt.axis([-0.01, 1.01, -0.01, 1.01])
    -plt.xticks(fontsize=18)
    -plt.yticks(fontsize=18)
    -plt.legend(loc="best", fontsize=18)
    -plt.show()
    -
    -

    -We can see that this plot of the ROC looks very strange. This tells us -that logistic regression is quite inept at predicting the Ising model -transition and is therefore highly non-linear. The ROC curve for the -training data looks quite good, but as the testing data is so far off -we see that we are dealing with an overfit model. -

    - © 1999-2018, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license + © 1999-2019, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license
    diff --git a/doc/pub/LogReg/html/LogReg.html b/doc/pub/LogReg/html/LogReg.html index 61b01692f..e1406ca8f 100644 --- a/doc/pub/LogReg/html/LogReg.html +++ b/doc/pub/LogReg/html/LogReg.html @@ -6,6 +6,7 @@ Automatically generated HTML file from DocOnce source + Data Analysis and Machine Learning: Logistic Regression @@ -53,18 +54,7 @@ div { text-align: justify; text-justify: inter-word; } ('Extending to more predictors', 2, None, '___sec11'), ('Including more classes', 2, None, '___sec12'), ('The Softmax function', 2, None, '___sec13'), - ('A _scikit-learn_ example', 2, None, '___sec14'), - ('A simple classification problem', 2, None, '___sec15'), - ('The two-dimensional Ising model, Predicting phase transition ' - 'of the two-dimensional Ising model', - 2, - None, - '___sec16'), - ('Reading in the data', 2, None, '___sec17'), - ('Logistic regression', 2, None, '___sec18'), - ('Exploring the logistic regression', 2, None, '___sec19'), - ('Accuracy of a classification model', 2, None, '___sec20'), - ('Analyzing the results', 2, None, '___sec21')]} + ('A simple classification problem', 2, None, '___sec14')]} end of tocinfo --> @@ -106,7 +96,7 @@ MathJax.Hub.Config({
    [2] Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University

    -

    Oct 18, 2018

    +

    Sep 15, 2019


    @@ -119,7 +109,7 @@ coefficients of a functional fit (say a polynomial) in order to be able to predict the response of a continuous variable on some unseen data. The fit to the continuous variable \( y_i \) is based on some independent variables \( \hat{x}_i \). Linear regression resulted in -analytical expressions (in terms of matrices to invert) for several +analytical expressions for standard ordinary Least Squares or Ridge regression (in terms of matrices to invert) for several quantities, ranging from the variance and thereby the confidence intervals of the parameters \( \hat{\beta} \) to the mean squared error. If we can invert the product of the design matrices, linear @@ -152,7 +142,7 @@ failure etc. Logistic regression will also serve as our stepping stone towards neural network algorithms and supervised deep learning. For logistic learning, the minimization of the cost function leads to a non-linear -equation in the parameters \( \hat{\beta} \). The optmization of the problem calls therefore for minimization algorithms. This forms the bottle neck of all machine learning algorithms, namely how to find reliable minima of a multi-variable function. This leads us to the family of gradient descent methods. The latter are the working horses of basically all modern machine learning algorithms. +equation in the parameters \( \hat{\beta} \). The optimization of the problem calls therefore for minimization algorithms. This forms the bottle neck of all machine learning algorithms, namely how to find reliable minima of a multi-variable function. This leads us to the family of gradient descent methods. The latter are the working horses of basically all modern machine learning algorithms.

    We note also that many of the topics discussed here @@ -443,34 +433,7 @@ Newton's method and gradient descent methods are discussed in the material on









    -

    A scikit-learn example

    - -

    - - -

    import numpy as np
    -import matplotlib.pyplot as plt
    -from sklearn import datasets
    -iris = datasets.load_iris()
    -list(iris.keys())
    -['data', 'target_names', 'feature_names', 'target', 'DESCR']
    -X = iris["data"][:, 3:] # petal width
    -y = (iris["target"] == 2).astype(np.int) # 1 if Iris-Virginica, else 0
    -
    -from sklearn.linear_model import LogisticRegression
    -log_reg = LogisticRegression()
    -log_reg.fit(X, y)
    -
    -X_new = np.linspace(0, 3, 1000).reshape(-1, 1)
    -y_proba = log_reg.predict_proba(X_new)
    -plt.plot(X_new, y_proba[:, 1], "g-", label="Iris-Virginica")
    -plt.plot(X_new, y_proba[:, 0], "b--", label="Not Iris-Virginica")
    -plt.show()
    -
    -

    -









    - -

    A simple classification problem

    +

    A simple classification problem

    @@ -524,331 +487,13 @@ plt.show() if __name__ == "__main__": main() -

    - - -

    The two-dimensional Ising model, Predicting phase transition of the two-dimensional Ising model

    - -

    -The Hamiltonian of the two-dimensional Ising model without an external field for a constant coupling constant \( J \) is given by -$$ -\begin{align} - H = -J \sum_{\langle ij\rangle} S_i S_j, -\label{_auto2} -\end{align} -$$ - -where \( S_i \in \{-1, 1\} \) and \( \langle ij \rangle \) signifies that we only iterate over the nearest neighbors in the lattice. We will be looking at a system of \( L = 40 \) spins in each dimension, i.e., \( L^2 = 1600 \) spins in total. Opposed to the one-dimensional Ising model we will get a phase transition from an ordered phase to a disordered phase at the critical temperature - -$$ -\begin{align} - \frac{T_c}{J} = \frac{2}{\log\left(1 + \sqrt{2}\right)} \approx 2.26, -\label{_auto3} -\end{align} -$$ - -as shown by Lars Onsager. - -

    -Here we use logistic regression to predict when a phase transition -occurs. The data we will look at is a set of spin configurations, -i.e., individual lattices with spins, labeled ordered 1 or -disordered 0. Our job is to build a model which will take in a -spin configuration and predict whether or not the spin configuration -constitutes an ordered or a disordered phase. To achieve this we will -represent the lattices as flattened arrays with \( 1600 \) elements -instead of a matrix of \( 40 \times 40 \) elements. As an extra test of -the performance of the algorithms we will divide the dataset into -three pieces. We will do a conventional train-test-split on a -combination of totally ordered and totally disordered phases. The -remaining "critical-like" states will be used as test data which we -hope the model will be able to make good extrapolated predictions on. - -

    - - -

    import pickle
    -import os
    -import glob
    -import numpy as np
    -import pandas as pd
    -import matplotlib.pyplot as plt
    -import seaborn as sns
    -import sklearn.model_selection as skms
    -import sklearn.linear_model as skl
    -import sklearn.metrics as skm
    -import tqdm
    -import copy
    -import time
    -from IPython.display import display
    -
    -%matplotlib inline
    -
    -sns.set(color_codes=True)
    -
    -

    -









    - -

    Reading in the data

    - -

    -Using the data from Mehta et al. (specifically the two datasets named Ising2DFM_reSample_L40_T=All.pkl and Ising2DFM_reSample_L40_T=All_labels.pkl) we have to unpack the data into numpy arrays. - -

    - - -

    filenames = glob.glob(os.path.join("..", "dat", "*"))
    -label_filename = list(filter(lambda x: "label" in x, filenames))[0]
    -dat_filename = list(filter(lambda x: "label" not in x, filenames))[0]
    -
    -# Read in the labels
    -with open(label_filename, "rb") as f:
    -    labels = pickle.load(f)
    -
    -# Read in the corresponding configurations
    -with open(dat_filename, "rb") as f:
    -    data = np.unpackbits(pickle.load(f)).reshape(-1, 1600).astype("int")
    -
    -# Set spin-down to -1
    -data[data == 0] = -1
    -
    -

    -This dataset consists of \( 10000 \) samples, i.e., \( 10000 \) spin -configurations with \( 40 \times 40 \) spins each, for \( 16 \) temperatures -between \( 0.25 \) to \( 4.0 \). Next we create a train/test-split and keep -the data in the critical phase as a separate dataset for -extrapolation-testing. - -

    - - -

    # Set up slices of the dataset
    -ordered = slice(0, 70000)
    -critical = slice(70000, 100000)
    -disordered = slice(100000, 160000)
    -
    -X_train, X_test, y_train, y_test = skms.train_test_split(
    -    np.concatenate((data[ordered], data[disordered])),
    -    np.concatenate((labels[ordered], labels[disordered])),
    -    test_size=0.95
    -)
    -
    -

    -









    - -

    Logistic regression

    - -

    -Logistic regression is a linear model for classification. Recalling -the cost function for ordinary least squares with both L2 (ridge) and -L1 (LASSO) penalties we will see that the logistic cost function is -very similar. In OLS we wish to predict a continuous variable -\( \hat{y} \) using -$$ -\begin{align} - \hat{y} = X\omega, -\label{_auto4} -\end{align} -$$ - -

    -where \( X \in \mathbb{R}^{n \times p} \) is the input data and \( \omega^{p -\times d} \) are the weights of the regression. In a classification -setting (binary classification in our situation) we are interested in -a positive or negative answer. We can thus define either answer to be -above or below some threshold. But, in order to limit the size of the -answer and also to get a probability interpretation on how sure we are -for either answer we can compute the sigmoid function of OLS. That is, - -$$ -\begin{align} - f(X\omega) = \frac{1}{1 + \exp(-X\omega)}. -\label{_auto5} -\end{align} -$$ - -We are thus interested in minizming the following cost function -$$ -\begin{align} - C(X, \omega) = \sum_{i = 1}^n \left\{ - - y_i\log\left( f(x_i^T\omega) \right) - - (1 - y_i)\log\left[1 - f(x_i^T\omega)\right] - \right\}, -\label{_auto6} -\end{align} -$$ - -

    -where we will restrict ourselves to a value for \( f(z) \) as the sigmoid -described above. We can also tack on a L2 (Ridge) or L1 (LASSO) -penalization to this cost function in the same manner we did for -linear regression. - -

    -









    - -

    Exploring the logistic regression

    - -

    -The penalization factor \( \lambda \) is inverted in the case of the -logistic regression model we use. We will explore several values of -\( \lambda \) using both L1 and L2 penalization. We do this using a grid -search over different parameters and run a 3-fold cross validation for -each configuration. In other words, we fit a model 3 times for each -configuration of the hyper parameters. - -

    - - -

    lambdas = np.logspace(-7, -1, 7)
    -
    -param_grid = {
    -    "C": list(1.0/lambdas),
    -    "penalty": ["l1", "l2"]
    -}
    -clf = skms.GridSearchCV(
    -    skl.LogisticRegression(),
    -    param_grid=param_grid,
    -    n_jobs=-1,
    -    return_train_score=True
    -)
    -t0 = time.time()
    -clf.fit(X_train, y_train)
    -t1 = time.time()
    -
    -print (
    -    "Time spent fitting GridSearchCV(LogisticRegression): {0:.3f} sec".format(
    -        t1 - t0
    -    )
    -)
    -
    -

    -We can see that logistic regression is quite slow and using the grid -search and cross validation results in quite a heavy -computation. Below we show the results of the different -configurations. - -

    - - -

    logreg_df = pd.DataFrame(clf.cv_results_)
    -
    -display(logreg_df)
    -
    -

    -









    - -

    Accuracy of a classification model

    - -

    -To determine how well a classification model is performing we count -the number of correctly labeled classes and divide by the number of -classes in total. The accuracy is thus given by - -$$ -\begin{align} - a(y, \hat{y}) = \frac{1}{n}\sum_{i = 1}^{n} I(y_i = \hat{y}_i), -\label{_auto7} -\end{align} -$$ - -

    -where \( I(y_i = \hat{y}_i) \) is the indicator function given by - -$$ -\begin{align} - I(x = y) = \begin{array}{cc} - 1 & x = y, \\ - 0 & x \neq y. - \end{array} -\label{_auto8} -\end{align}$$ - -

    -This is the accuracy provided by Scikit-learn when using sklearn.metrics.accuracyscore. - -

    -Below we compute the accuracy of the best fit model on the training data (which should give a good accuracy), the test data (which has not been shown to the model) and the critical data (completely new data that needs to be extrapolated). - -

    - - -

    train_accuracy = skm.accuracy_score(y_train, clf.predict(X_train))
    -test_accuracy = skm.accuracy_score(y_test, clf.predict(X_test))
    -critical_accuracy = skm.accuracy_score(labels[critical], clf.predict(data[critical]))
    -
    -print ("Accuracy on train data: {0}".format(train_accuracy))
    -print ("Accuracy on test data: {0}".format(test_accuracy))
    -print ("Accuracy on critical data: {0}".format(critical_accuracy))
    -
    -

    -We can see that we get quite good accuracy on the training data, but gradually worsening accuracy on the test and critical data. - -

    -









    - -

    Analyzing the results

    - -

    -Below we show a different metric for determining the quality of our -model, namely the reciever operating characteristic (ROC). The ROC -curve tells us how well the model correctly classifies the different -labels. We plot the true positive rate (the rate of predicted -positive classes that are positive) versus the false positive rate -(the rate of predicted positive classes that are negative). The ROC -curve is built by computing the true positive rate and the false -positive rate for varying thresholds, i.e, which probability we -should acredit a certain class. - -

    -By computing the area under the curve (AUC) of the ROC curve we get an estimate of how well our model is performing. Pure guessing will get an AUC of \( 0.5 \). A perfect score will get an AUC of \( 1.0 \). - -

    - - -

    fig = plt.figure(figsize=(20, 14))
    -
    -for (_X, _y), label in zip(
    -    [
    -        (X_train, y_train),
    -        (X_test, y_test),
    -        (data[critical], labels[critical])
    -    ],
    -    ["Train", "Test", "Critical"]
    -):
    -    proba = clf.predict_proba(_X)
    -    fpr, tpr, _ = skm.roc_curve(_y, proba[:, 1])
    -    roc_auc = skm.auc(fpr, tpr)
    -
    -    print ("LogisticRegression AUC ({0}): {1}".format(label, roc_auc))
    -
    -    plt.plot(fpr, tpr, label="{0} (AUC = {1})".format(label, roc_auc), linewidth=4.0)
    -
    -plt.plot([0, 1], [0, 1], "--", label="Guessing (AUC = 0.5)", linewidth=4.0)
    -
    -plt.title(r"The ROC curve for LogisticRegression", fontsize=18)
    -plt.xlabel(r"False positive rate", fontsize=18)
    -plt.ylabel(r"True positive rate", fontsize=18)
    -plt.axis([-0.01, 1.01, -0.01, 1.01])
    -plt.xticks(fontsize=18)
    -plt.yticks(fontsize=18)
    -plt.legend(loc="best", fontsize=18)
    -plt.show()
    -
    -

    -We can see that this plot of the ROC looks very strange. This tells us -that logistic regression is quite inept at predicting the Ising model -transition and is therefore highly non-linear. The ROC curve for the -training data looks quite good, but as the testing data is so far off -we see that we are dealing with an overfit model. -

    - © 1999-2018, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license + © 1999-2019, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license
    diff --git a/doc/pub/LogReg/html/reveal.js/.gitignore b/doc/pub/LogReg/html/reveal.js/.gitignore index e7b4f216a..a5df3133d 100644 --- a/doc/pub/LogReg/html/reveal.js/.gitignore +++ b/doc/pub/LogReg/html/reveal.js/.gitignore @@ -1,8 +1,3 @@ -.idea/ -*.iml -*.iws -*.eml -out/ .DS_Store .svn log/*.log @@ -10,4 +5,4 @@ tmp/** node_modules/ .sass-cache css/reveal.min.css -js/reveal.min.js \ No newline at end of file +js/reveal.min.js diff --git a/doc/pub/LogReg/html/reveal.js/.travis.yml b/doc/pub/LogReg/html/reveal.js/.travis.yml index ec3b27d5d..165d9ae9f 100644 --- a/doc/pub/LogReg/html/reveal.js/.travis.yml +++ b/doc/pub/LogReg/html/reveal.js/.travis.yml @@ -1,7 +1,5 @@ language: node_js node_js: - - 4 + - 0.10 before_script: - - npm install -g grunt-cli -after_script: - - grunt retire + - npm install -g grunt-cli \ No newline at end of file diff --git a/doc/pub/LogReg/html/reveal.js/LICENSE b/doc/pub/LogReg/html/reveal.js/LICENSE index c3e6e5fd6..09623076f 100644 --- a/doc/pub/LogReg/html/reveal.js/LICENSE +++ b/doc/pub/LogReg/html/reveal.js/LICENSE @@ -1,4 +1,4 @@ -Copyright (C) 2017 Hakim El Hattab, http://hakim.se, and reveal.js contributors +Copyright (C) 2015 Hakim El Hattab, http://hakim.se Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/doc/pub/LogReg/html/reveal.js/README.md b/doc/pub/LogReg/html/reveal.js/README.md index f2ab6ca88..573b19597 100644 --- a/doc/pub/LogReg/html/reveal.js/README.md +++ b/doc/pub/LogReg/html/reveal.js/README.md @@ -1,58 +1,12 @@ -# reveal.js [![Build Status](https://travis-ci.org/hakimel/reveal.js.svg?branch=master)](https://travis-ci.org/hakimel/reveal.js) Slides +# reveal.js [![Build Status](https://travis-ci.org/hakimel/reveal.js.svg?branch=master)](https://travis-ci.org/hakimel/reveal.js) -A framework for easily creating beautiful presentations using HTML. [Check out the live demo](http://revealjs.com/). +A framework for easily creating beautiful presentations using HTML. [Check out the live demo](http://lab.hakim.se/reveal-js/). -reveal.js comes with a broad range of features including [nested slides](https://github.com/hakimel/reveal.js#markup), [Markdown contents](https://github.com/hakimel/reveal.js#markdown), [PDF export](https://github.com/hakimel/reveal.js#pdf-export), [speaker notes](https://github.com/hakimel/reveal.js#speaker-notes) and a [JavaScript API](https://github.com/hakimel/reveal.js#api). There's also a fully featured visual editor and platform for sharing reveal.js presentations at [slides.com](https://slides.com?ref=github). +reveal.js comes with a broad range of features including [nested slides](https://github.com/hakimel/reveal.js#markup), [Markdown contents](https://github.com/hakimel/reveal.js#markdown), [PDF export](https://github.com/hakimel/reveal.js#pdf-export), [speaker notes](https://github.com/hakimel/reveal.js#speaker-notes) and a [JavaScript API](https://github.com/hakimel/reveal.js#api). It's best viewed in a modern browser but [fallbacks](https://github.com/hakimel/reveal.js/wiki/Browser-Support) are available to make sure your presentation can still be viewed elsewhere. -## Table of contents -- [Online Editor](#online-editor) -- [Instructions](#instructions) - - [Markup](#markup) - - [Markdown](#markdown) - - [Element Attributes](#element-attributes) - - [Slide Attributes](#slide-attributes) -- [Configuration](#configuration) -- [Presentation Size](#presentation-size) -- [Dependencies](#dependencies) -- [Ready Event](#ready-event) -- [Auto-sliding](#auto-sliding) -- [Keyboard Bindings](#keyboard-bindings) -- [Touch Navigation](#touch-navigation) -- [Lazy Loading](#lazy-loading) -- [API](#api) - - [Slide Changed Event](#slide-changed-event) - - [Presentation State](#presentation-state) - - [Slide States](#slide-states) - - [Slide Backgrounds](#slide-backgrounds) - - [Parallax Background](#parallax-background) - - [Slide Transitions](#slide-transitions) - - [Internal links](#internal-links) - - [Fragments](#fragments) - - [Fragment events](#fragment-events) - - [Code syntax highlighting](#code-syntax-highlighting) - - [Slide number](#slide-number) - - [Overview mode](#overview-mode) - - [Fullscreen mode](#fullscreen-mode) - - [Embedded media](#embedded-media) - - [Stretching elements](#stretching-elements) - - [postMessage API](#postmessage-api) -- [PDF Export](#pdf-export) -- [Theming](#theming) -- [Speaker Notes](#speaker-notes) - - [Share and Print Speaker Notes](#share-and-print-speaker-notes) - - [Server Side Speaker Notes](#server-side-speaker-notes) -- [Multiplexing](#multiplexing) - - [Master presentation](#master-presentation) - - [Client presentation](#client-presentation) - - [Socket.io server](#socketio-server) -- [MathJax](#mathjax) -- [Installation](#installation) - - [Basic setup](#basic-setup) - - [Full setup](#full-setup) - - [Folder Structure](#folder-structure) -- [License](#license) -#### More reading +#### More reading: +- [Installation](#installation): Step-by-step instructions for getting reveal.js running on your computer. - [Changelog](https://github.com/hakimel/reveal.js/releases): Up-to-date version history. - [Examples](https://github.com/hakimel/reveal.js/wiki/Example-Presentations): Presentations created with reveal.js, add your own! - [Browser Support](https://github.com/hakimel/reveal.js/wiki/Browser-Support): Explanation of browser support and fallbacks. @@ -60,36 +14,14 @@ reveal.js comes with a broad range of features including [nested slides](https:/ ## Online Editor -Presentations are written using HTML or Markdown but there's also an online editor for those of you who prefer a graphical interface. Give it a try at [https://slides.com](https://slides.com?ref=github). +Presentations are written using HTML or Markdown but there's also an online editor for those of you who prefer a graphical interface. Give it a try at [http://slides.com](http://slides.com). ## Instructions ### Markup -Here's a barebones example of a fully working reveal.js presentation: -```html - - - - - - -
    -
    -
    Slide 1
    -
    Slide 2
    -
    -
    - - - - -``` - -The presentation markup hierarchy needs to be `.reveal > .slides > section` where the `section` represents one slide and can be repeated indefinitely. If you place multiple `section` elements inside of another `section` they will be shown as vertical slides. The first of the vertical slides is the "root" of the others (at the top), and will be included in the horizontal sequence. For example: +Markup hierarchy needs to be ``
    `` where the ``
    `` represents one slide and can be repeated indefinitely. If you place multiple ``
    ``'s inside of another ``
    `` they will be shown as vertical slides. The first of the vertical slides is the "root" of the others (at the top), and it will be included in the horizontal sequence. For example: ```html
    @@ -105,36 +37,32 @@ The presentation markup hierarchy needs to be `.reveal > .slides > section` wher ### Markdown -It's possible to write your slides using Markdown. To enable Markdown, add the `data-markdown` attribute to your `
    ` elements and wrap the contents in a ` +
    ``` #### External Markdown -You can write your content as a separate file and have reveal.js load it at runtime. Note the separator arguments which determine how slides are delimited in the external file: the `data-separator` attribute defines a regular expression for horizontal slides (defaults to `^\r?\n---\r?\n$`, a newline-bounded horizontal rule) and `data-separator-vertical` defines vertical slides (disabled by default). The `data-separator-notes` attribute is a regular expression for specifying the beginning of the current slide's speaker notes (defaults to `note:`). The `data-charset` attribute is optional and specifies which charset to use when loading the external file. +You can write your content as a separate file and have reveal.js load it at runtime. Note the separator arguments which determine how slides are delimited in the external file. The ```data-charset``` attribute is optional and specifies which charset to use when loading the external file. -When used locally, this feature requires that reveal.js [runs from a local web server](#full-setup). The following example customises all available options: +When used locally, this feature requires that reveal.js [runs from a local web server](#full-setup). ```html -
    -
    ``` @@ -164,19 +92,6 @@ Special syntax (in html comment) is available for adding attributes to the slide
    ``` -#### Configuring *marked* - -We use [marked](https://github.com/chjj/marked) to parse Markdown. To customise marked's rendering, you can pass in options when [configuring Reveal](#configuration): - -```javascript -Reveal.initialize({ - // Options which are passed into marked - // See https://github.com/chjj/marked#options-1 - markdown: { - smartypants: true - } -}); -``` ### Configuration @@ -185,26 +100,12 @@ At the end of your page you need to initialize reveal by running the following c ```javascript Reveal.initialize({ - // Display presentation control arrows + // Display controls in the bottom right corner controls: true, - // Help the user learn the controls by providing hints, for example by - // bouncing the down arrow when they first encounter a vertical slide - controlsTutorial: true, - - // Determines where controls appear, "edges" or "bottom-right" - controlsLayout: 'bottom-right', - - // Visibility rule for backwards navigation arrows; "faded", "hidden" - // or "visible" - controlsBackArrows: 'faded', - // Display a presentation progress bar progress: true, - // Set default timing of 2 minutes per slide - defaultTiming: 120, - // Display the page number of the current slide slideNumber: false, @@ -229,9 +130,6 @@ Reveal.initialize({ // Change the presentation direction to be RTL rtl: false, - // Randomizes the order of slides each time the presentation loads - shuffle: false, - // Turns fragments on and off globally fragments: true, @@ -243,15 +141,6 @@ Reveal.initialize({ // key is pressed help: true, - // Flags if speaker notes should be visible to all viewers - showNotes: false, - - // Global override for autoplaying embedded media (video/audio/iframe) - // - null: Media will only autoplay if data-autoplay is present - // - true: All media will autoplay, regardless of individual setting - // - false: No media will autoplay, regardless of individual setting - autoPlayMedia: null, - // Number of milliseconds between automatically proceeding to the // next slide, disabled when set to 0, this value can be overwritten // by using a data-autoslide attribute on your slides @@ -260,9 +149,6 @@ Reveal.initialize({ // Stop auto-sliding after user input autoSlideStoppable: true, - // Use this method for navigation when auto-sliding - autoSlideMethod: Reveal.navigateNext, - // Enable slide navigation via mouse wheel mouseWheel: false, @@ -270,18 +156,16 @@ Reveal.initialize({ hideAddressBar: true, // Opens links in an iframe preview overlay - // Add `data-preview-link` and `data-preview-link="false"` to customise each link - // individually previewLinks: false, // Transition style - transition: 'slide', // none/fade/slide/convex/concave/zoom + transition: 'default', // none/fade/slide/convex/concave/zoom // Transition speed transitionSpeed: 'default', // default/fast/slow // Transition style for full page slide backgrounds - backgroundTransition: 'fade', // none/fade/slide/convex/concave/zoom + backgroundTransition: 'default', // none/fade/slide/convex/concave/zoom // Number of slides away from the current that are visible viewDistance: 3, @@ -292,14 +176,10 @@ Reveal.initialize({ // Parallax background size parallaxBackgroundSize: '', // CSS syntax, e.g. "2100px 900px" - // Number of pixels to move the parallax background per slide - // - Calculated automatically unless specified - // - Set to 0 to disable movement along an axis - parallaxBackgroundHorizontal: null, - parallaxBackgroundVertical: null, - - // The display mode that will be used to show slides - display: 'block' + // Amount to move parallax background (horizontal and vertical) on slide change + // Number, e.g. 100 + parallaxBackgroundHorizontal: '', + parallaxBackgroundVertical: '' }); ``` @@ -316,6 +196,56 @@ Reveal.configure({ autoSlide: 5000 }); ``` +### Dependencies + +Reveal.js doesn't _rely_ on any third party scripts to work but a few optional libraries are included by default. These libraries are loaded as dependencies in the order they appear, for example: + +```javascript +Reveal.initialize({ + dependencies: [ + // Cross-browser shim that fully implements classList - https://github.com/eligrey/classList.js/ + { src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } }, + + // Interpret Markdown in
    elements + { src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, + { src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, + + // Syntax highlight for elements + { src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, + + // Zoom in and out with Alt+click + { src: 'plugin/zoom-js/zoom.js', async: true }, + + // Speaker notes + { src: 'plugin/notes/notes.js', async: true }, + + // Remote control your reveal.js presentation using a touch device + { src: 'plugin/remotes/remotes.js', async: true }, + + // MathJax + { src: 'plugin/math/math.js', async: true } + ] +}); +``` + +You can add your own extensions using the same syntax. The following properties are available for each dependency object: +- **src**: Path to the script to load +- **async**: [optional] Flags if the script should load after reveal.js has started, defaults to false +- **callback**: [optional] Function to execute when the script has loaded +- **condition**: [optional] Function which must return true for the script to be loaded + + +### Ready Event + +A 'ready' event is fired when reveal.js has loaded all non-async dependencies and is ready to start navigating. To check if reveal.js is already 'ready' you can call `Reveal.isReady()`. + +```javascript +Reveal.addEventListener( 'ready', function( event ) { + // event.currentSlide, event.indexh, event.indexv +} ); +``` + + ### Presentation Size All presentations have a normal size, that is the resolution at which they are authored. The framework will automatically scale presentations uniformly based on this size to ensure that everything fits on any given display or viewport. @@ -343,69 +273,6 @@ Reveal.initialize({ }); ``` -If you wish to disable this behavior and do your own scaling (e.g. using media queries), try these settings: - -```javascript -Reveal.initialize({ - - ... - - width: "100%", - height: "100%", - margin: 0, - minScale: 1, - maxScale: 1 -}); -``` - -### Dependencies - -Reveal.js doesn't _rely_ on any third party scripts to work but a few optional libraries are included by default. These libraries are loaded as dependencies in the order they appear, for example: - -```javascript -Reveal.initialize({ - dependencies: [ - // Cross-browser shim that fully implements classList - https://github.com/eligrey/classList.js/ - { src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } }, - - // Interpret Markdown in
    elements - { src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, - { src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, - - // Syntax highlight for elements - { src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, - - // Zoom in and out with Alt+click - { src: 'plugin/zoom-js/zoom.js', async: true }, - - // Speaker notes - { src: 'plugin/notes/notes.js', async: true }, - - // MathJax - { src: 'plugin/math/math.js', async: true } - ] -}); -``` - -You can add your own extensions using the same syntax. The following properties are available for each dependency object: -- **src**: Path to the script to load -- **async**: [optional] Flags if the script should load after reveal.js has started, defaults to false -- **callback**: [optional] Function to execute when the script has loaded -- **condition**: [optional] Function which must return true for the script to be loaded - -To load these dependencies, reveal.js requires [head.js](http://headjs.com/) *(a script loading library)* to be loaded before reveal.js. - -### Ready Event - -A 'ready' event is fired when reveal.js has loaded all non-async dependencies and is ready to start navigating. To check if reveal.js is already 'ready' you can call `Reveal.isReady()`. - -```javascript -Reveal.addEventListener( 'ready', function( event ) { - // event.currentSlide, event.indexh, event.indexv -} ); -``` - -Note that we also add a `.ready` class to the `.reveal` element so that you can hook into this with CSS. ### Auto-sliding @@ -429,8 +296,6 @@ You can also override the slide duration for individual slides and fragments by
    ``` -To override the method used for navigation when auto-sliding, you can specify the ```autoSlideMethod``` setting. To only navigate along the top layer and ignore vertical slides, set this to ```Reveal.navigateRight```. - Whenever the auto-slide mode is resumed or paused the ```autoslideresumed``` and ```autoslidepaused``` events are fired. @@ -448,13 +313,6 @@ Reveal.configure({ }); ``` -### Touch Navigation - -You can swipe to navigate through a presentation on any touch-enabled device. Horizontal swipes change between horizontal slides, vertical swipes change between vertical slides. If you wish to disable this you can set the `touch` config option to false when initializing reveal.js. - -If there's some part of your content that needs to remain accessible to touch events you'll need to highlight this by adding a `data-prevent-swipe` attribute to the element. One common example where this is useful is elements that need to be scrolled. - - ### Lazy Loading When working on presentation with a lot of media or iframe content it's important to load lazily. Lazy loading means that reveal.js will only load content for the few slides nearest to the current slide. The number of slides that are preloaded is determined by the `viewDistance` configuration option. @@ -489,18 +347,11 @@ Reveal.next(); Reveal.prevFragment(); Reveal.nextFragment(); -// Randomize the order of slides -Reveal.shuffle(); - // Toggle presentation states, optionally pass true/false to force on/off Reveal.toggleOverview(); Reveal.togglePause(); Reveal.toggleAutoSlide(); -// Shows a help overlay with keyboard shortcuts, optionally pass true/false -// to force on/off -Reveal.toggleHelp(); - // Change a config value at runtime Reveal.configure({ controls: true }); @@ -514,14 +365,9 @@ Reveal.getScale(); Reveal.getPreviousSlide(); Reveal.getCurrentSlide(); -Reveal.getIndices(); // { h: 0, v: 0 } } -Reveal.getPastSlideCount(); -Reveal.getProgress(); // (0 == first slide, 1 == last slide) -Reveal.getSlides(); // Array of all slides -Reveal.getTotalSlides(); // total number of slides - -// Returns the speaker notes for the current slide -Reveal.getSlideNotes(); +Reveal.getIndices(); // { h: 0, v: 0 } } +Reveal.getProgress(); // 0-1 +Reveal.getTotalSlides(); // State checks Reveal.isFirstSlide(); @@ -574,59 +420,26 @@ Reveal.addEventListener( 'somestate', function() { ### Slide Backgrounds -Slides are contained within a limited portion of the screen by default to allow them to fit any display and scale uniformly. You can apply full page backgrounds outside of the slide area by adding a ```data-background``` attribute to your ```
    ``` elements. Four different types of backgrounds are supported: color, image, video and iframe. +Slides are contained within a limited portion of the screen by default to allow them to fit any display and scale uniformly. You can apply full page backgrounds outside of the slide area by adding a ```data-background``` attribute to your ```
    ``` elements. Four different types of backgrounds are supported: color, image, video and iframe. Below are a few examples. -#### Color Backgrounds -All CSS color formats are supported, like rgba() or hsl(). ```html -
    -

    Color

    +
    +

    All CSS color formats are supported, like rgba() or hsl().

    +
    +
    +

    This slide will have a full-size background image.

    +
    +
    +

    This background image will be sized to 100px and repeated.

    +
    +
    +

    Video. Multiple sources can be defined using a comma separated list. Video will loop when the data-background-video-loop attribute is provided.

    +
    +
    +

    Embeds a web page as a background. Note that the page won't be interactive.

    ``` -#### Image Backgrounds -By default, background images are resized to cover the full page. Available options: - -| Attribute | Default | Description | -| :--------------------------- | :--------- | :---------- | -| data-background-image | | URL of the image to show. GIFs restart when the slide opens. | -| data-background-size | cover | See [background-size](https://developer.mozilla.org/docs/Web/CSS/background-size) on MDN. | -| data-background-position | center | See [background-position](https://developer.mozilla.org/docs/Web/CSS/background-position) on MDN. | -| data-background-repeat | no-repeat | See [background-repeat](https://developer.mozilla.org/docs/Web/CSS/background-repeat) on MDN. | -```html -
    -

    Image

    -
    -
    -

    This background image will be sized to 100px and repeated

    -
    -``` - -#### Video Backgrounds -Automatically plays a full size video behind the slide. - -| Attribute | Default | Description | -| :--------------------------- | :------ | :---------- | -| data-background-video | | A single video source, or a comma separated list of video sources. | -| data-background-video-loop | false | Flags if the video should play repeatedly. | -| data-background-video-muted | false | Flags if the audio should be muted. | -| data-background-size | cover | Use `cover` for full screen and some cropping or `contain` for letterboxing. | - -```html -
    -

    Video

    -
    -``` - -#### Iframe Backgrounds -Embeds a web page as a slide background that covers 100% of the reveal.js width and height. The iframe is in the background layer, behind your slides, and as such it's not possible to interact with it by default. To make your background interactive, you can add the `data-background-interactive` attribute. -```html -
    -

    Iframe

    -
    -``` - -#### Background Transitions Backgrounds transition using a fade animation by default. This can be changed to a linear sliding transition by passing ```backgroundTransition: 'slide'``` to the ```Reveal.initialize()``` call. Alternatively you can set ```data-background-transition``` on any section with a background to override that specific transition. @@ -643,16 +456,16 @@ Reveal.initialize({ // Parallax background size parallaxBackgroundSize: '', // CSS syntax, e.g. "2100px 900px" - currently only pixels are supported (don't use % or auto) - // Number of pixels to move the parallax background per slide - // - Calculated automatically unless specified - // - Set to 0 to disable movement along an axis + // Amount of pixels to move the parallax background per slide step, + // a value of 0 disables movement along the given axis + // These are optional, if they aren't specified they'll be calculated automatically parallaxBackgroundHorizontal: 200, parallaxBackgroundVertical: 50 }); ``` -Make sure that the background size is much bigger than screen size to allow for some scrolling. [View example](http://revealjs.com/?parallaxBackgroundImage=https%3A%2F%2Fs3.amazonaws.com%2Fhakim-static%2Freveal-js%2Freveal-parallax-1.jpg¶llaxBackgroundSize=2100px%20900px). +Make sure that the background size is much bigger than screen size to allow for some scrolling. [View example](http://lab.hakim.se/reveal-js/?parallaxBackgroundImage=https%3A%2F%2Fs3.amazonaws.com%2Fhakim-static%2Freveal-js%2Freveal-parallax-1.jpg¶llaxBackgroundSize=2100px%20900px). @@ -673,15 +486,15 @@ You can also use different in and out transitions for the same slide: ```html
    - The train goes on … + The train goes on …
    -
    - and on … +
    + and on …
    -
    +
    and stops.
    -
    +
    (Passengers entering and leaving)
    @@ -690,6 +503,9 @@ You can also use different in and out transitions for the same slide: ``` +Note that this does not work with the page and cube transitions. + + ### Internal links It's easy to link between slides. The first example below targets the index of another slide whereas the second targets a slide with an ID attribute (```
    ```): @@ -712,7 +528,7 @@ You can also add relative navigation links, similar to the built in reveal.js co ### Fragments -Fragments are used to highlight individual elements on a slide. Every element with the class ```fragment``` will be stepped through before moving on to the next slide. Here's an example: http://revealjs.com/#/fragments +Fragments are used to highlight individual elements on a slide. Every element with the class ```fragment``` will be stepped through before moving on to the next slide. Here's an example: http://lab.hakim.se/reveal-js/#/fragments The default fragment style is to start out invisible and fade in. This style can be changed by appending a different class to the fragment: @@ -721,7 +537,6 @@ The default fragment style is to start out invisible and fade in. This style can

    grow

    shrink

    fade-out

    -

    fade-up (also down, left and right!)

    visible only once

    blue only once

    highlight-red

    @@ -767,41 +582,33 @@ Reveal.addEventListener( 'fragmenthidden', function( event ) { ### Code syntax highlighting -By default, Reveal is configured with [highlight.js](https://highlightjs.org/) for code syntax highlighting. To enable syntax highlighting, you'll have to load the highlight plugin ([plugin/highlight/highlight.js](plugin/highlight/highlight.js)) and a highlight.js CSS theme (Reveal comes packaged with the zenburn theme: [lib/css/zenburn.css](lib/css/zenburn.css)). - -Below is an example with clojure code that will be syntax highlighted. When the `data-trim` attribute is present, surrounding whitespace is automatically removed. HTML will be escaped by default. To avoid this, for example if you are using `` to call out a line of code, add the `data-noescape` attribute to the `` element. +By default, Reveal is configured with [highlight.js](http://softwaremaniacs.org/soft/highlight/en/) for code syntax highlighting. Below is an example with clojure code that will be syntax highlighted. When the `data-trim` attribute is present surrounding whitespace is automatically removed. ```html
    -
    
    +	
    
     (def lazy-fib
       (concat
        [0 1]
    -   ((fn rfib [a b]
    +   ((fn rfib [a b]
             (lazy-cons (+ a b) (rfib b (+ a b)))) 0 1)))
     	
    ``` ### Slide number -If you would like to display the page number of the current slide you can do so using the ```slideNumber``` and ```showSlideNumber``` configuration values. +If you would like to display the page number of the current slide you can do so using the ```slideNumber``` configuration value. ```javascript // Shows the slide number using default formatting Reveal.configure({ slideNumber: true }); // Slide number formatting can be configured using these variables: -// "h.v": horizontal . vertical slide number (default) -// "h/v": horizontal / vertical slide number -// "c": flattened slide number -// "c/t": flattened slide number / total slides -Reveal.configure({ slideNumber: 'c/t' }); - -// Control which views the slide number displays on using the "showSlideNumber" value: -// "all": show on all views (default) -// "speaker": only show slide numbers on speaker notes view -// "print": only show slide numbers when printing to PDF -Reveal.configure({ showSlideNumber: 'speaker' }); +// h: current slide's horizontal index +// v: current slide's vertical index +// c: current slide index (flattened) +// t: total number of slides (flattened) +Reveal.configure({ slideNumber: 'c / t' }); ``` @@ -819,26 +626,20 @@ Reveal.addEventListener( 'overviewhidden', function( event ) { /* ... */ } ); Reveal.toggleOverview(); ``` - ### Fullscreen mode Just press »F« on your keyboard to show your presentation in fullscreen mode. Press the »ESC« key to exit fullscreen mode. ### Embedded media +Embedded HTML5 `
    diff --git a/doc/pub/LogReg/html/reveal.js/plugin/markdown/example.md b/doc/pub/LogReg/html/reveal.js/plugin/markdown/example.md index 89c75345e..6f6f577a1 100644 --- a/doc/pub/LogReg/html/reveal.js/plugin/markdown/example.md +++ b/doc/pub/LogReg/html/reveal.js/plugin/markdown/example.md @@ -29,8 +29,3 @@ Content 3.1 ## External 3.2 Content 3.2 - - -## External 3.3 - -![External Image](https://s3.amazonaws.com/static.slid.es/logo/v2/slides-symbol-512x512.png) diff --git a/doc/pub/LogReg/html/reveal.js/plugin/markdown/markdown.js b/doc/pub/LogReg/html/reveal.js/plugin/markdown/markdown.js index aa08ee5ed..15e3b40b3 100644 --- a/doc/pub/LogReg/html/reveal.js/plugin/markdown/markdown.js +++ b/doc/pub/LogReg/html/reveal.js/plugin/markdown/markdown.js @@ -4,26 +4,33 @@ * of external markdown documents. */ (function( root, factory ) { - if (typeof define === 'function' && define.amd) { - root.marked = require( './marked' ); - root.RevealMarkdown = factory( root.marked ); - root.RevealMarkdown.initialize(); - } else if( typeof exports === 'object' ) { + if( typeof exports === 'object' ) { module.exports = factory( require( './marked' ) ); - } else { + } + else { // Browser globals (root is window) root.RevealMarkdown = factory( root.marked ); root.RevealMarkdown.initialize(); } }( this, function( marked ) { + if( typeof marked === 'undefined' ) { + throw 'The reveal.js Markdown plugin requires marked to be loaded'; + } + + if( typeof hljs !== 'undefined' ) { + marked.setOptions({ + highlight: function( lang, code ) { + return hljs.highlightAuto( lang, code ).value; + } + }); + } + var DEFAULT_SLIDE_SEPARATOR = '^\r?\n---\r?\n$', - DEFAULT_NOTES_SEPARATOR = 'notes?:', + DEFAULT_NOTES_SEPARATOR = 'note:', DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR = '\\\.element\\\s*?(.+?)$', DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR = '\\\.slide:\\\s*?(\\\S.+?)$'; - var SCRIPT_END_PLACEHOLDER = '__SCRIPT_END__'; - /** * Retrieves the markdown contents of a slide section @@ -31,15 +38,11 @@ */ function getMarkdownFromSlide( section ) { - // look for a ' ); - var leadingWs = text.match( /^\n?(\s*)/ )[1].length, leadingTabs = text.match( /^\n?(\t*)/ )[1].length; @@ -109,13 +112,9 @@ var notesMatch = content.split( new RegExp( options.notesSeparator, 'mgi' ) ); if( notesMatch.length === 2 ) { - content = notesMatch[0] + ''; + content = notesMatch[0] + ''; } - // prevent script end tags in the content from interfering - // with parsing - content = content.replace( /<\/script>/g, SCRIPT_END_PLACEHOLDER ); - return ''; } @@ -178,7 +177,7 @@ markdownSections += '
    '; sectionStack[i].forEach( function( child ) { - markdownSections += '
    ' + createMarkdownSlide( child, options ) + '
    '; + markdownSections += '
    ' + createMarkdownSlide( child, options ) + '
    '; } ); markdownSections += '
    '; @@ -380,24 +379,6 @@ return { initialize: function() { - if( typeof marked === 'undefined' ) { - throw 'The reveal.js Markdown plugin requires marked to be loaded'; - } - - if( typeof hljs !== 'undefined' ) { - marked.setOptions({ - highlight: function( code, lang ) { - return hljs.highlightAuto( code, [lang] ).value; - } - }); - } - - var options = Reveal.getConfig().markdown; - - if ( options ) { - marked.setOptions( options ); - } - processSlides(); convertSlides(); }, diff --git a/doc/pub/LogReg/html/reveal.js/plugin/markdown/marked.js b/doc/pub/LogReg/html/reveal.js/plugin/markdown/marked.js index 555c1dc1d..70af29bf9 100644 --- a/doc/pub/LogReg/html/reveal.js/plugin/markdown/marked.js +++ b/doc/pub/LogReg/html/reveal.js/plugin/markdown/marked.js @@ -3,4 +3,4 @@ * Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed) * https://github.com/chjj/marked */ -(function(){var block={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:noop,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:noop,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:noop,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};block.bullet=/(?:[*+-]|\d+\.)/;block.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;block.item=replace(block.item,"gm")(/bull/g,block.bullet)();block.list=replace(block.list)(/bull/g,block.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+block.def.source+")")();block.blockquote=replace(block.blockquote)("def",block.def)();block._tag="(?!(?:"+"a|em|strong|small|s|cite|q|dfn|abbr|data|time|code"+"|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo"+"|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b";block.html=replace(block.html)("comment",//)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/])*?>/)(/tag/g,block._tag)();block.paragraph=replace(block.paragraph)("hr",block.hr)("heading",block.heading)("lheading",block.lheading)("blockquote",block.blockquote)("tag","<"+block._tag)("def",block.def)();block.normal=merge({},block);block.gfm=merge({},block.normal,{fences:/^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,paragraph:/^/,heading:/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/});block.gfm.paragraph=replace(block.paragraph)("(?!","(?!"+block.gfm.fences.source.replace("\\1","\\2")+"|"+block.list.source.replace("\\1","\\3")+"|")();block.tables=merge({},block.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/});function Lexer(options){this.tokens=[];this.tokens.links={};this.options=options||marked.defaults;this.rules=block.normal;if(this.options.gfm){if(this.options.tables){this.rules=block.tables}else{this.rules=block.gfm}}}Lexer.rules=block;Lexer.lex=function(src,options){var lexer=new Lexer(options);return lexer.lex(src)};Lexer.prototype.lex=function(src){src=src.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n");return this.token(src,true)};Lexer.prototype.token=function(src,top,bq){var src=src.replace(/^ +$/gm,""),next,loose,cap,bull,b,item,space,i,l;while(src){if(cap=this.rules.newline.exec(src)){src=src.substring(cap[0].length);if(cap[0].length>1){this.tokens.push({type:"space"})}}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);cap=cap[0].replace(/^ {4}/gm,"");this.tokens.push({type:"code",text:!this.options.pedantic?cap.replace(/\n+$/,""):cap});continue}if(cap=this.rules.fences.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"code",lang:cap[2],text:cap[3]||""});continue}if(cap=this.rules.heading.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"heading",depth:cap[1].length,text:cap[2]});continue}if(top&&(cap=this.rules.nptable.exec(src))){src=src.substring(cap[0].length);item={type:"table",header:cap[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:cap[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:cap[3].replace(/\n$/,"").split("\n")};for(i=0;i ?/gm,"");this.token(cap,top,true);this.tokens.push({type:"blockquote_end"});continue}if(cap=this.rules.list.exec(src)){src=src.substring(cap[0].length);bull=cap[2];this.tokens.push({type:"list_start",ordered:bull.length>1});cap=cap[0].match(this.rules.item);next=false;l=cap.length;i=0;for(;i1&&b.length>1)){src=cap.slice(i+1).join("\n")+src;i=l-1}}loose=next||/\n\n(?!\s*$)/.test(item);if(i!==l-1){next=item.charAt(item.length-1)==="\n";if(!loose)loose=next}this.tokens.push({type:loose?"loose_item_start":"list_item_start"});this.token(item,false,bq);this.tokens.push({type:"list_item_end"})}this.tokens.push({type:"list_end"});continue}if(cap=this.rules.html.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:!this.options.sanitizer&&(cap[1]==="pre"||cap[1]==="script"||cap[1]==="style"),text:cap[0]});continue}if(!bq&&top&&(cap=this.rules.def.exec(src))){src=src.substring(cap[0].length);this.tokens.links[cap[1].toLowerCase()]={href:cap[2],title:cap[3]};continue}if(top&&(cap=this.rules.table.exec(src))){src=src.substring(cap[0].length);item={type:"table",header:cap[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:cap[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:cap[3].replace(/(?: *\| *)?\n$/,"").split("\n")};for(i=0;i])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:noop,tag:/^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:noop,text:/^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/;inline.link=replace(inline.link)("inside",inline._inside)("href",inline._href)();inline.reflink=replace(inline.reflink)("inside",inline._inside)();inline.normal=merge({},inline);inline.pedantic=merge({},inline.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/});inline.gfm=merge({},inline.normal,{escape:replace(inline.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:replace(inline.text)("]|","~]|")("|","|https?://|")()});inline.breaks=merge({},inline.gfm,{br:replace(inline.br)("{2,}","*")(),text:replace(inline.gfm.text)("{2,}","*")()});function InlineLexer(links,options){this.options=options||marked.defaults;this.links=links;this.rules=inline.normal;this.renderer=this.options.renderer||new Renderer;this.renderer.options=this.options;if(!this.links){throw new Error("Tokens array requires a `links` property.")}if(this.options.gfm){if(this.options.breaks){this.rules=inline.breaks}else{this.rules=inline.gfm}}else if(this.options.pedantic){this.rules=inline.pedantic}}InlineLexer.rules=inline;InlineLexer.output=function(src,links,options){var inline=new InlineLexer(links,options);return inline.output(src)};InlineLexer.prototype.output=function(src){var out="",link,text,href,cap;while(src){if(cap=this.rules.escape.exec(src)){src=src.substring(cap[0].length);out+=cap[1];continue}if(cap=this.rules.autolink.exec(src)){src=src.substring(cap[0].length);if(cap[2]==="@"){text=cap[1].charAt(6)===":"?this.mangle(cap[1].substring(7)):this.mangle(cap[1]);href=this.mangle("mailto:")+text}else{text=escape(cap[1]);href=text}out+=this.renderer.link(href,null,text);continue}if(!this.inLink&&(cap=this.rules.url.exec(src))){src=src.substring(cap[0].length);text=escape(cap[1]);href=text;out+=this.renderer.link(href,null,text);continue}if(cap=this.rules.tag.exec(src)){if(!this.inLink&&/^/i.test(cap[0])){this.inLink=false}src=src.substring(cap[0].length);out+=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(cap[0]):escape(cap[0]):cap[0];continue}if(cap=this.rules.link.exec(src)){src=src.substring(cap[0].length);this.inLink=true;out+=this.outputLink(cap,{href:cap[2],title:cap[3]});this.inLink=false;continue}if((cap=this.rules.reflink.exec(src))||(cap=this.rules.nolink.exec(src))){src=src.substring(cap[0].length);link=(cap[2]||cap[1]).replace(/\s+/g," ");link=this.links[link.toLowerCase()];if(!link||!link.href){out+=cap[0].charAt(0);src=cap[0].substring(1)+src;continue}this.inLink=true;out+=this.outputLink(cap,link);this.inLink=false;continue}if(cap=this.rules.strong.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.strong(this.output(cap[2]||cap[1]));continue}if(cap=this.rules.em.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.em(this.output(cap[2]||cap[1]));continue}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.codespan(escape(cap[2],true));continue}if(cap=this.rules.br.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.br();continue}if(cap=this.rules.del.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.del(this.output(cap[1]));continue}if(cap=this.rules.text.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.text(escape(this.smartypants(cap[0])));continue}if(src){throw new Error("Infinite loop on byte: "+src.charCodeAt(0))}}return out};InlineLexer.prototype.outputLink=function(cap,link){var href=escape(link.href),title=link.title?escape(link.title):null;return cap[0].charAt(0)!=="!"?this.renderer.link(href,title,this.output(cap[1])):this.renderer.image(href,title,escape(cap[1]))};InlineLexer.prototype.smartypants=function(text){if(!this.options.smartypants)return text;return text.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")};InlineLexer.prototype.mangle=function(text){if(!this.options.mangle)return text;var out="",l=text.length,i=0,ch;for(;i.5){ch="x"+ch.toString(16)}out+="&#"+ch+";"}return out};function Renderer(options){this.options=options||{}}Renderer.prototype.code=function(code,lang,escaped){if(this.options.highlight){var out=this.options.highlight(code,lang);if(out!=null&&out!==code){escaped=true;code=out}}if(!lang){return"
    "+(escaped?code:escape(code,true))+"\n
    "}return'
    '+(escaped?code:escape(code,true))+"\n
    \n"};Renderer.prototype.blockquote=function(quote){return"
    \n"+quote+"
    \n"};Renderer.prototype.html=function(html){return html};Renderer.prototype.heading=function(text,level,raw){return"'+text+"\n"};Renderer.prototype.hr=function(){return this.options.xhtml?"
    \n":"
    \n"};Renderer.prototype.list=function(body,ordered){var type=ordered?"ol":"ul";return"<"+type+">\n"+body+"\n"};Renderer.prototype.listitem=function(text){return"
  • "+text+"
  • \n"};Renderer.prototype.paragraph=function(text){return"

    "+text+"

    \n"};Renderer.prototype.table=function(header,body){return"\n"+"\n"+header+"\n"+"\n"+body+"\n"+"
    \n"};Renderer.prototype.tablerow=function(content){return"\n"+content+"\n"};Renderer.prototype.tablecell=function(content,flags){var type=flags.header?"th":"td";var tag=flags.align?"<"+type+' style="text-align:'+flags.align+'">':"<"+type+">";return tag+content+"\n"};Renderer.prototype.strong=function(text){return""+text+""};Renderer.prototype.em=function(text){return""+text+""};Renderer.prototype.codespan=function(text){return""+text+""};Renderer.prototype.br=function(){return this.options.xhtml?"
    ":"
    "};Renderer.prototype.del=function(text){return""+text+""};Renderer.prototype.link=function(href,title,text){if(this.options.sanitize){try{var prot=decodeURIComponent(unescape(href)).replace(/[^\w:]/g,"").toLowerCase()}catch(e){return""}if(prot.indexOf("javascript:")===0||prot.indexOf("vbscript:")===0){return""}}var out='
    ";return out};Renderer.prototype.image=function(href,title,text){var out=''+text+'":">";return out};Renderer.prototype.text=function(text){return text};function Parser(options){this.tokens=[];this.token=null;this.options=options||marked.defaults;this.options.renderer=this.options.renderer||new Renderer;this.renderer=this.options.renderer;this.renderer.options=this.options}Parser.parse=function(src,options,renderer){var parser=new Parser(options,renderer);return parser.parse(src)};Parser.prototype.parse=function(src){this.inline=new InlineLexer(src.links,this.options,this.renderer);this.tokens=src.reverse();var out="";while(this.next()){out+=this.tok()}return out};Parser.prototype.next=function(){return this.token=this.tokens.pop()};Parser.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0};Parser.prototype.parseText=function(){var body=this.token.text;while(this.peek().type==="text"){body+="\n"+this.next().text}return this.inline.output(body)};Parser.prototype.tok=function(){switch(this.token.type){case"space":{return""}case"hr":{return this.renderer.hr()}case"heading":{return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text)}case"code":{return this.renderer.code(this.token.text,this.token.lang,this.token.escaped)}case"table":{var header="",body="",i,row,cell,flags,j;cell="";for(i=0;i/g,">").replace(/"/g,""").replace(/'/g,"'")}function unescape(html){return html.replace(/&([#\w]+);/g,function(_,n){n=n.toLowerCase();if(n==="colon")return":";if(n.charAt(0)==="#"){return n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1))}return""})}function replace(regex,opt){regex=regex.source;opt=opt||"";return function self(name,val){if(!name)return new RegExp(regex,opt);val=val.source||val;val=val.replace(/(^|[^\[])\^/g,"$1");regex=regex.replace(name,val);return self}}function noop(){}noop.exec=noop;function merge(obj){var i=1,target,key;for(;iAn error occured:

    "+escape(e.message+"",true)+"
    "}throw e}}marked.options=marked.setOptions=function(opt){merge(marked.defaults,opt);return marked};marked.defaults={gfm:true,tables:true,breaks:false,pedantic:false,sanitize:false,sanitizer:null,mangle:true,smartLists:false,silent:false,highlight:null,langPrefix:"lang-",smartypants:false,headerPrefix:"",renderer:new Renderer,xhtml:false};marked.Parser=Parser;marked.parser=Parser.parse;marked.Renderer=Renderer;marked.Lexer=Lexer;marked.lexer=Lexer.lex;marked.InlineLexer=InlineLexer;marked.inlineLexer=InlineLexer.output;marked.parse=marked;if(typeof module!=="undefined"&&typeof exports==="object"){module.exports=marked}else if(typeof define==="function"&&define.amd){define(function(){return marked})}else{this.marked=marked}}).call(function(){return this||(typeof window!=="undefined"?window:global)}()); \ No newline at end of file +(function(){function e(e){this.tokens=[],this.tokens.links={},this.options=e||a.defaults,this.rules=p.normal,this.options.gfm&&(this.rules=this.options.tables?p.tables:p.gfm)}function t(e,t){if(this.options=t||a.defaults,this.links=e,this.rules=u.normal,this.renderer=this.options.renderer||new n,this.renderer.options=this.options,!this.links)throw new Error("Tokens array requires a `links` property.");this.options.gfm?this.rules=this.options.breaks?u.breaks:u.gfm:this.options.pedantic&&(this.rules=u.pedantic)}function n(e){this.options=e||{}}function r(e){this.tokens=[],this.token=null,this.options=e||a.defaults,this.options.renderer=this.options.renderer||new n,this.renderer=this.options.renderer,this.renderer.options=this.options}function s(e,t){return e.replace(t?/&/g:/&(?!#?\w+;)/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function i(e){return e.replace(/&([#\w]+);/g,function(e,t){return t=t.toLowerCase(),"colon"===t?":":"#"===t.charAt(0)?String.fromCharCode("x"===t.charAt(1)?parseInt(t.substring(2),16):+t.substring(1)):""})}function l(e,t){return e=e.source,t=t||"",function n(r,s){return r?(s=s.source||s,s=s.replace(/(^|[^\[])\^/g,"$1"),e=e.replace(r,s),n):new RegExp(e,t)}}function o(){}function h(e){for(var t,n,r=1;rAn error occured:

    "+s(c.message+"",!0)+"
    ";throw c}}var p={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:o,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:o,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:o,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};p.bullet=/(?:[*+-]|\d+\.)/,p.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,p.item=l(p.item,"gm")(/bull/g,p.bullet)(),p.list=l(p.list)(/bull/g,p.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+p.def.source+")")(),p.blockquote=l(p.blockquote)("def",p.def)(),p._tag="(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b",p.html=l(p.html)("comment",//)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/])*?>/)(/tag/g,p._tag)(),p.paragraph=l(p.paragraph)("hr",p.hr)("heading",p.heading)("lheading",p.lheading)("blockquote",p.blockquote)("tag","<"+p._tag)("def",p.def)(),p.normal=h({},p),p.gfm=h({},p.normal,{fences:/^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/,paragraph:/^/}),p.gfm.paragraph=l(p.paragraph)("(?!","(?!"+p.gfm.fences.source.replace("\\1","\\2")+"|"+p.list.source.replace("\\1","\\3")+"|")(),p.tables=h({},p.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/}),e.rules=p,e.lex=function(t,n){var r=new e(n);return r.lex(t)},e.prototype.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(e,!0)},e.prototype.token=function(e,t,n){for(var r,s,i,l,o,h,a,u,c,e=e.replace(/^ +$/gm,"");e;)if((i=this.rules.newline.exec(e))&&(e=e.substring(i[0].length),i[0].length>1&&this.tokens.push({type:"space"})),i=this.rules.code.exec(e))e=e.substring(i[0].length),i=i[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",text:this.options.pedantic?i:i.replace(/\n+$/,"")});else if(i=this.rules.fences.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"code",lang:i[2],text:i[3]});else if(i=this.rules.heading.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"heading",depth:i[1].length,text:i[2]});else if(t&&(i=this.rules.nptable.exec(e))){for(e=e.substring(i[0].length),h={type:"table",header:i[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:i[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:i[3].replace(/\n$/,"").split("\n")},u=0;u ?/gm,""),this.token(i,t,!0),this.tokens.push({type:"blockquote_end"});else if(i=this.rules.list.exec(e)){for(e=e.substring(i[0].length),l=i[2],this.tokens.push({type:"list_start",ordered:l.length>1}),i=i[0].match(this.rules.item),r=!1,c=i.length,u=0;c>u;u++)h=i[u],a=h.length,h=h.replace(/^ *([*+-]|\d+\.) +/,""),~h.indexOf("\n ")&&(a-=h.length,h=this.options.pedantic?h.replace(/^ {1,4}/gm,""):h.replace(new RegExp("^ {1,"+a+"}","gm"),"")),this.options.smartLists&&u!==c-1&&(o=p.bullet.exec(i[u+1])[0],l===o||l.length>1&&o.length>1||(e=i.slice(u+1).join("\n")+e,u=c-1)),s=r||/\n\n(?!\s*$)/.test(h),u!==c-1&&(r="\n"===h.charAt(h.length-1),s||(s=r)),this.tokens.push({type:s?"loose_item_start":"list_item_start"}),this.token(h,!1,n),this.tokens.push({type:"list_item_end"});this.tokens.push({type:"list_end"})}else if(i=this.rules.html.exec(e))e=e.substring(i[0].length),this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:"pre"===i[1]||"script"===i[1]||"style"===i[1],text:i[0]});else if(!n&&t&&(i=this.rules.def.exec(e)))e=e.substring(i[0].length),this.tokens.links[i[1].toLowerCase()]={href:i[2],title:i[3]};else if(t&&(i=this.rules.table.exec(e))){for(e=e.substring(i[0].length),h={type:"table",header:i[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:i[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:i[3].replace(/(?: *\| *)?\n$/,"").split("\n")},u=0;u])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:o,tag:/^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:o,text:/^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/,u.link=l(u.link)("inside",u._inside)("href",u._href)(),u.reflink=l(u.reflink)("inside",u._inside)(),u.normal=h({},u),u.pedantic=h({},u.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/}),u.gfm=h({},u.normal,{escape:l(u.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:l(u.text)("]|","~]|")("|","|https?://|")()}),u.breaks=h({},u.gfm,{br:l(u.br)("{2,}","*")(),text:l(u.gfm.text)("{2,}","*")()}),t.rules=u,t.output=function(e,n,r){var s=new t(n,r);return s.output(e)},t.prototype.output=function(e){for(var t,n,r,i,l="";e;)if(i=this.rules.escape.exec(e))e=e.substring(i[0].length),l+=i[1];else if(i=this.rules.autolink.exec(e))e=e.substring(i[0].length),"@"===i[2]?(n=this.mangle(":"===i[1].charAt(6)?i[1].substring(7):i[1]),r=this.mangle("mailto:")+n):(n=s(i[1]),r=n),l+=this.renderer.link(r,null,n);else if(this.inLink||!(i=this.rules.url.exec(e))){if(i=this.rules.tag.exec(e))!this.inLink&&/^
    /i.test(i[0])&&(this.inLink=!1),e=e.substring(i[0].length),l+=this.options.sanitize?s(i[0]):i[0];else if(i=this.rules.link.exec(e))e=e.substring(i[0].length),this.inLink=!0,l+=this.outputLink(i,{href:i[2],title:i[3]}),this.inLink=!1;else if((i=this.rules.reflink.exec(e))||(i=this.rules.nolink.exec(e))){if(e=e.substring(i[0].length),t=(i[2]||i[1]).replace(/\s+/g," "),t=this.links[t.toLowerCase()],!t||!t.href){l+=i[0].charAt(0),e=i[0].substring(1)+e;continue}this.inLink=!0,l+=this.outputLink(i,t),this.inLink=!1}else if(i=this.rules.strong.exec(e))e=e.substring(i[0].length),l+=this.renderer.strong(this.output(i[2]||i[1]));else if(i=this.rules.em.exec(e))e=e.substring(i[0].length),l+=this.renderer.em(this.output(i[2]||i[1]));else if(i=this.rules.code.exec(e))e=e.substring(i[0].length),l+=this.renderer.codespan(s(i[2],!0));else if(i=this.rules.br.exec(e))e=e.substring(i[0].length),l+=this.renderer.br();else if(i=this.rules.del.exec(e))e=e.substring(i[0].length),l+=this.renderer.del(this.output(i[1]));else if(i=this.rules.text.exec(e))e=e.substring(i[0].length),l+=s(this.smartypants(i[0]));else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0))}else e=e.substring(i[0].length),n=s(i[1]),r=n,l+=this.renderer.link(r,null,n);return l},t.prototype.outputLink=function(e,t){var n=s(t.href),r=t.title?s(t.title):null;return"!"!==e[0].charAt(0)?this.renderer.link(n,r,this.output(e[1])):this.renderer.image(n,r,s(e[1]))},t.prototype.smartypants=function(e){return this.options.smartypants?e.replace(/--/g,"—").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):e},t.prototype.mangle=function(e){for(var t,n="",r=e.length,s=0;r>s;s++)t=e.charCodeAt(s),Math.random()>.5&&(t="x"+t.toString(16)),n+="&#"+t+";";return n},n.prototype.code=function(e,t,n){if(this.options.highlight){var r=this.options.highlight(e,t);null!=r&&r!==e&&(n=!0,e=r)}return t?'
    '+(n?e:s(e,!0))+"\n
    \n":"
    "+(n?e:s(e,!0))+"\n
    "},n.prototype.blockquote=function(e){return"
    \n"+e+"
    \n"},n.prototype.html=function(e){return e},n.prototype.heading=function(e,t,n){return"'+e+"\n"},n.prototype.hr=function(){return this.options.xhtml?"
    \n":"
    \n"},n.prototype.list=function(e,t){var n=t?"ol":"ul";return"<"+n+">\n"+e+"\n"},n.prototype.listitem=function(e){return"
  • "+e+"
  • \n"},n.prototype.paragraph=function(e){return"

    "+e+"

    \n"},n.prototype.table=function(e,t){return"\n\n"+e+"\n\n"+t+"\n
    \n"},n.prototype.tablerow=function(e){return"\n"+e+"\n"},n.prototype.tablecell=function(e,t){var n=t.header?"th":"td",r=t.align?"<"+n+' style="text-align:'+t.align+'">':"<"+n+">";return r+e+"\n"},n.prototype.strong=function(e){return""+e+""},n.prototype.em=function(e){return""+e+""},n.prototype.codespan=function(e){return""+e+""},n.prototype.br=function(){return this.options.xhtml?"
    ":"
    "},n.prototype.del=function(e){return""+e+""},n.prototype.link=function(e,t,n){if(this.options.sanitize){try{var r=decodeURIComponent(i(e)).replace(/[^\w:]/g,"").toLowerCase()}catch(s){return""}if(0===r.indexOf("javascript:")||0===r.indexOf("vbscript:"))return""}var l='
    "},n.prototype.image=function(e,t,n){var r=''+n+'":">"},r.parse=function(e,t,n){var s=new r(t,n);return s.parse(e)},r.prototype.parse=function(e){this.inline=new t(e.links,this.options,this.renderer),this.tokens=e.reverse();for(var n="";this.next();)n+=this.tok();return n},r.prototype.next=function(){return this.token=this.tokens.pop()},r.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0},r.prototype.parseText=function(){for(var e=this.token.text;"text"===this.peek().type;)e+="\n"+this.next().text;return this.inline.output(e)},r.prototype.tok=function(){switch(this.token.type){case"space":return"";case"hr":return this.renderer.hr();case"heading":return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text);case"code":return this.renderer.code(this.token.text,this.token.lang,this.token.escaped);case"table":var e,t,n,r,s,i="",l="";for(n="",e=0;ebody{font-family: sans-serif;}

    reveal.js multiplex server.

    Generate token'); - res.end(); - }); - stream.on('readable', function() { - stream.pipe(res); - }); + fs.createReadStream(opts.baseDir + '/index.html').pipe(res); }); app.get("/token", function(req,res) { @@ -55,7 +47,7 @@ var createHash = function(secret) { }; // Actually listen -server.listen( opts.port || null ); +app.listen(opts.port || null); var brown = '\033[33m', green = '\033[32m', diff --git a/doc/pub/LogReg/html/reveal.js/plugin/multiplex/master.js b/doc/pub/LogReg/html/reveal.js/plugin/multiplex/master.js index 7f4bf4511..b6a7eb7dc 100644 --- a/doc/pub/LogReg/html/reveal.js/plugin/multiplex/master.js +++ b/doc/pub/LogReg/html/reveal.js/plugin/multiplex/master.js @@ -1,34 +1,51 @@ (function() { - // Don't emit events from inside of notes windows if ( window.location.search.match( /receiver/gi ) ) { return; } var multiplex = Reveal.getConfig().multiplex; - var socket = io.connect( multiplex.url ); + var socket = io.connect(multiplex.url); - function post() { + var notify = function( slideElement, indexh, indexv, origin ) { + if( typeof origin === 'undefined' && origin !== 'remote' ) { + var nextindexh; + var nextindexv; - var messageData = { - state: Reveal.getState(), - secret: multiplex.secret, - socketId: multiplex.id - }; + var fragmentindex = Reveal.getIndices().f; + if (typeof fragmentindex == 'undefined') { + fragmentindex = 0; + } - socket.emit( 'multiplex-statechanged', messageData ); + if (slideElement.nextElementSibling && slideElement.parentNode.nodeName == 'SECTION') { + nextindexh = indexh; + nextindexv = indexv + 1; + } else { + nextindexh = indexh + 1; + nextindexv = 0; + } + var slideData = { + indexh : indexh, + indexv : indexv, + indexf : fragmentindex, + nextindexh : nextindexh, + nextindexv : nextindexv, + secret: multiplex.secret, + socketId : multiplex.id + }; + + socket.emit('slidechanged', slideData); + } + } + + Reveal.addEventListener( 'slidechanged', function( event ) { + notify( event.currentSlide, event.indexh, event.indexv, event.origin ); + } ); + + var fragmentNotify = function( event ) { + notify( Reveal.getCurrentSlide(), Reveal.getIndices().h, Reveal.getIndices().v, event.origin ); }; - // post once the page is loaded, so the client follows also on "open URL". - window.addEventListener( 'load', post ); - - // Monitor events that trigger a change in state - Reveal.addEventListener( 'slidechanged', post ); - Reveal.addEventListener( 'fragmentshown', post ); - Reveal.addEventListener( 'fragmenthidden', post ); - Reveal.addEventListener( 'overviewhidden', post ); - Reveal.addEventListener( 'overviewshown', post ); - Reveal.addEventListener( 'paused', post ); - Reveal.addEventListener( 'resumed', post ); - -}()); + Reveal.addEventListener( 'fragmentshown', fragmentNotify ); + Reveal.addEventListener( 'fragmenthidden', fragmentNotify ); +}()); \ No newline at end of file diff --git a/doc/pub/LogReg/html/reveal.js/plugin/notes-server/client.js b/doc/pub/LogReg/html/reveal.js/plugin/notes-server/client.js index 00b277baf..628586ffb 100644 --- a/doc/pub/LogReg/html/reveal.js/plugin/notes-server/client.js +++ b/doc/pub/LogReg/html/reveal.js/plugin/notes-server/client.js @@ -41,15 +41,10 @@ } // When a new notes window connects, post our current state - socket.on( 'new-subscriber', function( data ) { + socket.on( 'connect', function( data ) { post(); } ); - // When the state changes from inside of the speaker view - socket.on( 'statechanged-speaker', function( data ) { - Reveal.setState( data.state ); - } ); - // Monitor events that trigger a change in state Reveal.addEventListener( 'slidechanged', post ); Reveal.addEventListener( 'fragmentshown', post ); diff --git a/doc/pub/LogReg/html/reveal.js/plugin/notes-server/index.js b/doc/pub/LogReg/html/reveal.js/plugin/notes-server/index.js index b95f07188..df917f112 100644 --- a/doc/pub/LogReg/html/reveal.js/plugin/notes-server/index.js +++ b/doc/pub/LogReg/html/reveal.js/plugin/notes-server/index.js @@ -1,40 +1,37 @@ -var http = require('http'); var express = require('express'); var fs = require('fs'); var io = require('socket.io'); +var _ = require('underscore'); var Mustache = require('mustache'); -var app = express(); +var app = express.createServer(); var staticDir = express.static; -var server = http.createServer(app); -io = io(server); +io = io.listen(app); var opts = { port : 1947, baseDir : __dirname + '/../../' }; -io.on( 'connection', function( socket ) { +io.sockets.on( 'connection', function( socket ) { - socket.on( 'new-subscriber', function( data ) { - socket.broadcast.emit( 'new-subscriber', data ); + socket.on( 'connect', function( data ) { + socket.broadcast.emit( 'connect', data ); }); socket.on( 'statechanged', function( data ) { - delete data.state.overview; socket.broadcast.emit( 'statechanged', data ); }); - socket.on( 'statechanged-speaker', function( data ) { - delete data.state.overview; - socket.broadcast.emit( 'statechanged-speaker', data ); - }); - }); -[ 'css', 'js', 'images', 'plugin', 'lib' ].forEach( function( dir ) { - app.use( '/' + dir, staticDir( opts.baseDir + dir ) ); +app.configure( function() { + + [ 'css', 'js', 'images', 'plugin', 'lib' ].forEach( function( dir ) { + app.use( '/' + dir, staticDir( opts.baseDir + dir ) ); + }); + }); app.get('/', function( req, res ) { @@ -55,7 +52,7 @@ app.get( '/notes/:socketId', function( req, res ) { }); // Actually listen -server.listen( opts.port || null ); +app.listen( opts.port || null ); var brown = '\033[33m', green = '\033[32m', @@ -65,5 +62,5 @@ var slidesLocation = 'http://localhost' + ( opts.port ? ( ':' + opts.port ) : '' console.log( brown + 'reveal.js - Speaker Notes' + reset ); console.log( '1. Open the slides at ' + green + slidesLocation + reset ); -console.log( '2. Click on the link in your JS console to go to the notes page' ); +console.log( '2. Click on the link your JS console to go to the notes page' ); console.log( '3. Advance through your slides and your notes will advance automatically' ); diff --git a/doc/pub/LogReg/html/reveal.js/plugin/notes-server/notes.html b/doc/pub/LogReg/html/reveal.js/plugin/notes-server/notes.html index ab8c5b17a..72d0317f1 100644 --- a/doc/pub/LogReg/html/reveal.js/plugin/notes-server/notes.html +++ b/doc/pub/LogReg/html/reveal.js/plugin/notes-server/notes.html @@ -8,7 +8,6 @@ @@ -247,7 +152,7 @@
    -
    Upcoming
    +
    UPCOMING:

    Time Click to Reset

    @@ -265,10 +170,6 @@
    -
    - - -
    @@ -281,20 +182,11 @@ currentState, currentSlide, upcomingSlide, - layoutLabel, - layoutDropdown, connected = false; var socket = io.connect( window.location.origin ), socketId = '{{socketId}}'; - var SPEAKER_LAYOUTS = { - 'default': 'Default', - 'wide': 'Wide', - 'tall': 'Tall', - 'notes-only': 'Notes only' - }; - socket.on( 'statechanged', function( data ) { // ignore data from sockets that aren't ours @@ -303,6 +195,7 @@ if( connected === false ) { connected = true; + setupIframes( data ); setupKeyboard(); setupNotes(); setupTimer(); @@ -313,28 +206,13 @@ } ); - setupLayout(); - - // Load our presentation iframes - setupIframes(); - - // Once the iframes have loaded, emit a signal saying there's - // a new subscriber which will trigger a 'statechanged' - // message to be sent back window.addEventListener( 'message', function( event ) { var data = JSON.parse( event.data ); if( data && data.namespace === 'reveal' ) { if( /ready/.test( data.eventName ) ) { - socket.emit( 'new-subscriber', { socketId: socketId } ); - } - } - - // Messages sent by reveal.js inside of the current slide preview - if( data && data.namespace === 'reveal' ) { - if( /slidechanged|fragmentshown|fragmenthidden|overviewshown|overviewhidden|paused|resumed/.test( data.eventName ) && currentState !== JSON.stringify( data.state ) ) { - socket.emit( 'statechanged-speaker', { state: data.state } ); + socket.emit( 'connect', { socketId: socketId } ); } } @@ -389,7 +267,7 @@ /** * Creates the preview iframes. */ - function setupIframes() { + function setupIframes( data ) { var params = [ 'receiver', @@ -399,8 +277,9 @@ 'backgroundTransition=none' ].join( '&' ); - var currentURL = '/?' + params + '&postMessageEvents=true'; - var upcomingURL = '/?' + params + '&controls=false'; + var hash = '#/' + data.state.indexh + '/' + data.state.indexv; + var currentURL = '/?' + params + '&postMessageEvents=true' + hash; + var upcomingURL = '/?' + params + '&controls=false' + hash; currentSlide = document.createElement( 'iframe' ); currentSlide.setAttribute( 'width', 1280 ); @@ -472,74 +351,6 @@ } - /** - * Sets up the speaker view layout and layout selector. - */ - function setupLayout() { - - layoutDropdown = document.querySelector( '.speaker-layout-dropdown' ); - layoutLabel = document.querySelector( '.speaker-layout-label' ); - - // Render the list of available layouts - for( var id in SPEAKER_LAYOUTS ) { - var option = document.createElement( 'option' ); - option.setAttribute( 'value', id ); - option.textContent = SPEAKER_LAYOUTS[ id ]; - layoutDropdown.appendChild( option ); - } - - // Monitor the dropdown for changes - layoutDropdown.addEventListener( 'change', function( event ) { - - setLayout( layoutDropdown.value ); - - }, false ); - - // Restore any currently persisted layout - setLayout( getLayout() ); - - } - - /** - * Sets a new speaker view layout. The layout is persisted - * in local storage. - */ - function setLayout( value ) { - - var title = SPEAKER_LAYOUTS[ value ]; - - layoutLabel.innerHTML = 'Layout' + ( title ? ( ': ' + title ) : '' ); - layoutDropdown.value = value; - - document.body.setAttribute( 'data-speaker-layout', value ); - - // Persist locally - if( window.localStorage ) { - window.localStorage.setItem( 'reveal-speaker-layout', value ); - } - - } - - /** - * Returns the ID of the most recently set speaker layout - * or our default layout if none has been set. - */ - function getLayout() { - - if( window.localStorage ) { - var layout = window.localStorage.getItem( 'reveal-speaker-layout' ); - if( layout ) { - return layout; - } - } - - // Default to the first record in the layouts hash - for( var id in SPEAKER_LAYOUTS ) { - return id; - } - - } - function zeroPadInteger( num ) { var str = '00' + parseInt( num ); diff --git a/doc/pub/LogReg/html/reveal.js/plugin/notes/notes.html b/doc/pub/LogReg/html/reveal.js/plugin/notes/notes.html index 4c5b799b5..0cc8cf612 100644 --- a/doc/pub/LogReg/html/reveal.js/plugin/notes/notes.html +++ b/doc/pub/LogReg/html/reveal.js/plugin/notes/notes.html @@ -8,7 +8,6 @@