Skip to content

Commit

Permalink
added rendered and corrected GP solutions in the correct format
Browse files Browse the repository at this point in the history
  • Loading branch information
lrjohnson0 committed Jul 24, 2024
1 parent 7e803b9 commit db20740
Show file tree
Hide file tree
Showing 19 changed files with 257 additions and 107 deletions.
37 changes: 26 additions & 11 deletions GP_Solutions.qmd
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
---
title: "GP_Solutions"
format: html
editor: visual
title: "VectorByte Methods Training: Introduction to Gaussian Processes for Time Dependent Data (Practical - solution)"
author:
- name: Parul Patil
affiliation: Virginia Tech and VectorByte
citation: true
date: 2024-07-24
date-format: long
format:
html:
toc: true
toc-location: left
html-math-method: katex
css: styles.css
bibliography: references.bib
link-citations: TRUE
---

##### Libraries

# Libraries

```{r, warning=FALSE, message=FALSE, warn.conflicts = FALSE}
library(mvtnorm)
Expand All @@ -13,7 +26,7 @@ library(hetGP)
library(ggplot2)
```

##### HetGP (sin wave eg)
# HetGP (sin wave eg)

```{r}
# Your turn
Expand Down Expand Up @@ -50,7 +63,7 @@ nugs <- het_pred$nugs
summary(nugs)
```

##### Challenges
# Challenges

We need to load the data and the functions

Expand Down Expand Up @@ -86,7 +99,9 @@ fx.sin <- function(datetime, f1 = fx.iso_week){
}
```

###### Fit a GP Model for the location "SERC" i.e. `site_number = 7`.
## Fit a GP Model for the location "SERC"

i.e. `site_number = 7`.

Just change site = 7

Expand Down Expand Up @@ -191,7 +206,7 @@ rmse <- sqrt(mean((yt_true - yt_pred)^2))
rmse
```

###### Use an environmental predictor in your model. Following is a function `fx.green` that creates the variable given the `datetime` and the `location`.
## Use an environmental predictor in your model. Following is a function `fx.green` that creates the variable given the `datetime` and the `location`.

Here is a snippet of the supporting file that you will use; You can look into the data.frame and try to plot `ker` for one site at a time and see what it yields.

Expand All @@ -215,7 +230,7 @@ fx.green <- function(datetime, site, site_info = df_green){
- set up X3 using `fx_green`
- Scale X3

Setting up the target dataframe
### Setting up the target dataframe

```{r}
Expand All @@ -234,7 +249,7 @@ df_train <- subset(df, df$datetime <= cutoff)
df_test <- subset(df, df$datetime > cutoff)
```

Adding Greenness
### Adding Greenness

```{r}
# Choose location
Expand Down Expand Up @@ -333,7 +348,7 @@ rmse <- sqrt(mean((yt_true - yt_pred)^2))
rmse
```

###### Fit a GP Model for all the locations (*More advanced*).
## Fit a GP Model for all the locations (*More advanced*).

```{r}
# GP function. This can be varied but easiest way is to just take in X, y, XX and return the predicted means and bounds.
Expand Down
Binary file modified docs/GP_Practical_files/figure-html/unnamed-chunk-6-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
298 changes: 206 additions & 92 deletions docs/GP_Solutions.html

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/Stats_review.html
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ <h1>Random Variables (RVs)</h1>
<li>discrete (numbers of items or successes)</li>
<li>continuous (heights, times, weights)</li>
</ul>
<p>We usually use capital letters – e.g.&nbsp;<span class="math inline">X</span>, <span class="math inline">Y</span>, sometimes with bold or with subscripts – to denote the RVs. In contrast we use lower case letters, e.g.&nbsp;<span class="math inline">x</span>, <span class="math inline">y</span>, <span class="math inline">k</span>, to denote the values that the RV takes. For instance, lets say that the heights of the woman at Virginia Tech are the RV, <span class="math inline">X</span>, and <span class="math inline">X</span> has a normal distribution with mean 62 inches and variance 6<span class="math inline">^2</span>, i.e., <span class="math inline">X \sim \mathrm{N}(62,6^2)</span> distribution. Say we then observe the heights of 3 individuals drawn from this distribution – we would write this as: <span class="math inline">x=(</span> 63.4, 56.8, 67.3 <span class="math inline">)</span>.</p>
<p>We usually use capital letters – e.g.&nbsp;<span class="math inline">X</span>, <span class="math inline">Y</span>, sometimes with bold or with subscripts – to denote the RVs. In contrast we use lower case letters, e.g.&nbsp;<span class="math inline">x</span>, <span class="math inline">y</span>, <span class="math inline">k</span>, to denote the values that the RV takes. For instance, lets say that the heights of the woman at Virginia Tech are the RV, <span class="math inline">X</span>, and <span class="math inline">X</span> has a normal distribution with mean 62 inches and variance 6<span class="math inline">^2</span>, i.e., <span class="math inline">X \sim \mathrm{N}(62,6^2)</span> distribution. Say we then observe the heights of 3 individuals drawn from this distribution – we would write this as: <span class="math inline">x=(</span> 60.6, 58.6, 71.6 <span class="math inline">)</span>.</p>
<p><br> <br> </p>
</section>
<section id="probability-distributions" class="level1">
Expand Down Expand Up @@ -577,7 +577,7 @@ <h1>Probability Distributions in <code>R</code></h1>
<div class="cell">
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="fu">rnorm</span>(<span class="dv">3</span>, <span class="at">mean=</span><span class="dv">0</span>, <span class="at">sd=</span><span class="dv">1</span>) <span class="do">## random draws</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 0.4409249 1.0655151 -1.5581929</code></pre>
<pre><code>[1] 0.3620634 0.7783175 -0.3565513</code></pre>
</div>
</div>
<div class="cell">
Expand Down
Binary file modified docs/Stats_review_files/figure-html/unnamed-chunk-7-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/Stats_review_files/figure-html/unnamed-chunk-8-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/Stats_review_files/figure-html/unnamed-chunk-9-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/VB_RegDiagTrans_files/figure-revealjs/unnamed-chunk-19-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/VB_RegDiagTrans_files/figure-revealjs/unnamed-chunk-7-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 23 additions & 2 deletions docs/search.json

Large diffs are not rendered by default.

0 comments on commit db20740

Please sign in to comment.