| Title: | An Implementation of the Artificial Hydrocarbon Networks |
|---|---|
| Description: | Implementation of the Artificial Hydrocarbon Networks for data modeling. |
| Authors: | Jose Roberto Ayala Solares [aut, cre] |
| Maintainer: | Jose Roberto Ayala Solares <[email protected]> |
| License: | GPL-3 | file LICENSE |
| Version: | 0.3.1 |
| Built: | 2026-06-06 09:09:27 UTC |
| Source: | https://github.com/jroberayalas/ahnr |
Function to train an Artificial Hydrocarbon Network (AHN).
fit(Sigma, n, eta, maxIter = 2000)fit(Sigma, n, eta, maxIter = 2000)
Sigma |
a list with two data frames. One for the inputs X, and one for the outputs Y. |
n |
number of particles to use. |
eta |
learning rate of the algorithm. Default is |
maxIter |
maximum number of iterations. |
an object of class "ahn" with the following components:
network: structure of the AHN trained. It contains the hydrogen coefficient H, position of the molecules Pi, data cluster ID per molecule moleculeNumber, number of molecules n, and carbon structure C
Yo: original output variable.
Ym: predicted output variable.
eta: learning rate.
minOverallError: minimum error achieved.
variableNames: names of the input variables.
# Create data x <- 2 * runif(1000) - 1; x <- sort(x) y <- (x < 0.1) * (0.05 * runif(100) + atan(pi*x)) + (x >= 0.1 & x < 0.6) * (0.05 * runif(1000) + sin(pi*x)) + (x >= 0.6) * (0.05 * runif(1000) + cos(pi*x)) # Create Sigma list Sigma <- list(X = data.frame(x = x), Y = data.frame(y = y)) # Train AHN ahn <- fit(Sigma, 5, 0.01, 500)# Create data x <- 2 * runif(1000) - 1; x <- sort(x) y <- (x < 0.1) * (0.05 * runif(100) + atan(pi*x)) + (x >= 0.1 & x < 0.6) * (0.05 * runif(1000) + sin(pi*x)) + (x >= 0.6) * (0.05 * runif(1000) + cos(pi*x)) # Create Sigma list Sigma <- list(X = data.frame(x = x), Y = data.frame(y = y)) # Train AHN ahn <- fit(Sigma, 5, 0.01, 500)
ahn objectChecks if argument is a ahn object
is.ahn(x)is.ahn(x)
x |
An R object |
Function to simulate a trained Artificial Hydrocarbon Network.
## S3 method for class 'ahn' predict(object, ...)## S3 method for class 'ahn' predict(object, ...)
object |
an object of class " |
... |
further arguments passed to or from other methods. |
predicted output values for inputs in newdata.
## Not run: # Create data x <- 2 * runif(1000) - 1; x <- sort(x) y <- (x < 0.1) * (0.05 * runif(100) + atan(pi*x)) + (x >= 0.1 & x < 0.6) * (0.05 * runif(1000) + sin(pi*x)) + (x >= 0.6) * (0.05 * runif(1000) + cos(pi*x)) # Create Sigma list Sigma <- list(X = data.frame(x = x), Y = data.frame(y = y)) # Train AHN ahn <- fit(Sigma, 5, 0.01, 500) # Test AHN X <- data.frame(x = x) ysim <- predict(ahn, X) ## End(Not run)## Not run: # Create data x <- 2 * runif(1000) - 1; x <- sort(x) y <- (x < 0.1) * (0.05 * runif(100) + atan(pi*x)) + (x >= 0.1 & x < 0.6) * (0.05 * runif(1000) + sin(pi*x)) + (x >= 0.6) * (0.05 * runif(1000) + cos(pi*x)) # Create Sigma list Sigma <- list(X = data.frame(x = x), Y = data.frame(y = y)) # Train AHN ahn <- fit(Sigma, 5, 0.01, 500) # Test AHN X <- data.frame(x = x) ysim <- predict(ahn, X) ## End(Not run)
Summary method for objects of class ahn.
## S3 method for class 'ahn' summary(object, ...)## S3 method for class 'ahn' summary(object, ...)
object |
an object of class " |
... |
further arguments passed to or from other methods. |
summary description of the AHN.
## Not run: # Create data x <- 2 * runif(1000) - 1; x <- sort(x) y <- (x < 0.1) * (0.05 * runif(100) + atan(pi*x)) + (x >= 0.1 & x < 0.6) * (0.05 * runif(1000) + sin(pi*x)) + (x >= 0.6) * (0.05 * runif(1000) + cos(pi*x)) # Create Sigma list Sigma <- list(X = data.frame(x = x), Y = data.frame(y = y)) # Train AHN ahn <- fit(Sigma, 5, 0.01, 500) # Summary AHN summary(ahn) ## End(Not run)## Not run: # Create data x <- 2 * runif(1000) - 1; x <- sort(x) y <- (x < 0.1) * (0.05 * runif(100) + atan(pi*x)) + (x >= 0.1 & x < 0.6) * (0.05 * runif(1000) + sin(pi*x)) + (x >= 0.6) * (0.05 * runif(1000) + cos(pi*x)) # Create Sigma list Sigma <- list(X = data.frame(x = x), Y = data.frame(y = y)) # Train AHN ahn <- fit(Sigma, 5, 0.01, 500) # Summary AHN summary(ahn) ## End(Not run)
Visualize method for objects of class ahn.
visualize(x, ...)visualize(x, ...)
x |
an object of class " |
... |
further arguments passed to visNetwork functions. |
dynamic visualization of the AHN.
## Not run: # Create data x <- 2 * runif(1000) - 1; x <- sort(x) y <- (x < 0.1) * (0.05 * runif(100) + atan(pi*x)) + (x >= 0.1 & x < 0.6) * (0.05 * runif(1000) + sin(pi*x)) + (x >= 0.6) * (0.05 * runif(1000) + cos(pi*x)) # Create Sigma list Sigma <- list(X = data.frame(x = x), Y = data.frame(y = y)) # Train AHN ahn <- fit(Sigma, 5, 0.01, 500) # Visualize AHN visualize(ahn) ## End(Not run)## Not run: # Create data x <- 2 * runif(1000) - 1; x <- sort(x) y <- (x < 0.1) * (0.05 * runif(100) + atan(pi*x)) + (x >= 0.1 & x < 0.6) * (0.05 * runif(1000) + sin(pi*x)) + (x >= 0.6) * (0.05 * runif(1000) + cos(pi*x)) # Create Sigma list Sigma <- list(X = data.frame(x = x), Y = data.frame(y = y)) # Train AHN ahn <- fit(Sigma, 5, 0.01, 500) # Visualize AHN visualize(ahn) ## End(Not run)