Skip to content

Commit

Permalink
Added the Logistics regression data simulation in the vignette .Rmd f…
Browse files Browse the repository at this point in the history
…ile.
  • Loading branch information
SinghRavin committed Mar 29, 2023
1 parent 183e763 commit bcc99f5
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions vignettes/BackPropNN.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,47 @@ knitr::opts_chunk$set(
library(BackPropNN)
```

# Simulated data - Logistics data.

```{r}
num_obs <- 10000 # Number of observations
# Setting coefficients values for the logit function.
beta0 <- -2.5
beta1 <- 0.02
beta2 <- 0.01
# Simulating the independent variables.
X1 <- runif(n=num_obs, min=18, max=60)
X2 <- runif(n=num_obs, min=100, max=250)
prob <- exp(beta0 + beta1*X1 + beta2*X2) / (1 + exp(beta0 + beta1*X1 + beta2*X2))
# Generating binary outcome variable.
Y <- rbinom(n=num_obs, size=1, prob=prob)
data <- data.frame(X1, X2, Y)
```

# Running the functions of BackPropNN package.

```{r}
set.seed(100)
i <- 2 # number of input nodes
h <- 4 # number of hidden nodes
o <- 1 # number of output nodes
learning_rate <- 0.1 # The learning rate of the algorithm
activation_func <- "sigmoid" # the activation function
nn_model <- back_propagation_training(i, h, o, learning_rate, activation_func, data)
```

# Summarizing the results of nn_model.

```{r}
plot(nn_model)
summary(nn_model)
print(nn_model)
```

# Simulated data - AND data.

```{r}
Expand Down

0 comments on commit bcc99f5

Please sign in to comment.