Skip to content

Commit

Permalink
documents
Browse files Browse the repository at this point in the history
  • Loading branch information
Akai01 committed May 3, 2022
1 parent 5594be4 commit e043cb2
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 53 deletions.
6 changes: 4 additions & 2 deletions R/ngb_dist.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ NGBDist <- R6::R6Class(
pdf = function(quantiles, ...){
private$dist$pdf(quantiles)
},
#' @description Log of the probability density function at x of the given RV.
#' @description Log of the probability density function at x of the given
#' RV.
#' This uses a more numerically accurate calculation if available.
#' @param quantiles The quantiles
#'
Expand Down Expand Up @@ -109,7 +110,8 @@ NGBDist <- R6::R6Class(
},

#' @description Confidence interval with equal areas around the median.
#' @param confidence Probability that an rv will be drawn from the returned range.
#' @param confidence Probability that an rv will be drawn from the returned
#' range.
#' Each value should be in the range \code{0>= confidence <=1}.
#'
#' @return nd-points of range that contain \code{100 * confidence} of
Expand Down
22 changes: 14 additions & 8 deletions R/ngbclass.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#'
#'
#' model <- NGBClassifier$new(Dist = Dist("k_categorical", K = 3),
#' Base=DecisionTreeRegressor(criterion='friedman_mse',
#' max_depth=2),
#' Base=DecisionTreeRegressor(
#' criterion='friedman_mse', max_depth=2),
#' Score = Scores("LogScore"),
#' natural_gradient=TRUE,
#' n_estimators=500,
Expand Down Expand Up @@ -64,13 +64,18 @@ NGBClassifier <- R6::R6Class(
#' data.A score from ngboost.scores, e.g. LogScore
#' @param Base Base learner to use in the boosting algorithm.
#' Any instantiated sklearn regressor, e.g. DecisionTreeRegressor()
#' @param natural_gradient Logical flag indicating whether the natural gradient should be used
#' @param natural_gradient Logical flag indicating whether the natural
#' gradient should be used
#' @param n_estimators The number of boosting iterations to fit
#' @param learning_rate The learning rate
#' @param minibatch_frac The percent subsample of rows to use in each boosting iteration
#' @param col_sample The percent subsample of columns to use in each boosting iteration
#' @param verbose Flag indicating whether output should be printed during fitting
#' @param verbose_eval Increment (in boosting iterations) at which output should be printed
#' @param minibatch_frac The percent subsample of rows to use in each
#' boosting iteration
#' @param col_sample The percent subsample of columns to use in each
#' boosting iteration
#' @param verbose Flag indicating whether output should be printed
#' during fitting
#' @param verbose_eval Increment (in boosting iterations) at which output
#' should be printed
#' @param tol Numerical tolerance to be used in optimization
#' @param random_state Seed for reproducibility.
#' @return An NGBRegressor object that can be fit.
Expand Down Expand Up @@ -118,7 +123,8 @@ NGBClassifier <- R6::R6Class(
return(self)
},
#' @description An NGBRegressor object that can be fit.
#' @param X DataFrame object or List or numpy array of predictors (n x p) in Numeric format
#' @param X DataFrame object or List or numpy array of predictors (n x p)
#' in Numeric format
#' @param Y DataFrame object or List or numpy array of outcomes (n)
#' in numeric format. Should be floats for regression and integers from 0
#' to K-1 for K-class classification
Expand Down
22 changes: 14 additions & 8 deletions R/ngbreg.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,18 @@ NGBRegression <- R6::R6Class(
#' data. A score from ngboost.scores, e.g. LogScore
#' @param Base Base learner to use in the boosting algorithm.
#' Any instantiated sklearn regressor, e.g. DecisionTreeRegressor()
#' @param natural_gradient Logical flag indicating whether the natural gradient should be used
#' @param natural_gradient Logical flag indicating whether the natural
#' gradient should be used
#' @param n_estimators The number of boosting iterations to fit
#' @param learning_rate The learning rate
#' @param minibatch_frac The percent subsample of rows to use in each boosting iteration
#' @param col_sample The percent subsample of columns to use in each boosting iteration
#' @param verbose Flag indicating whether output should be printed during fitting
#' @param verbose_eval Increment (in boosting iterations) at which output should be printed
#' @param minibatch_frac The percent subsample of rows to use in each
#' boosting iteration
#' @param col_sample The percent subsample of columns to use in each
#' boosting iteration
#' @param verbose Flag indicating whether output should be printed during
#' fitting
#' @param verbose_eval Increment (in boosting iterations) at which output
#' should be printed
#' @param tol Numerical tolerance to be used in optimization
#' @param random_state Seed for reproducibility.
#' @return An NGBRegressor object that can be fit.
Expand Down Expand Up @@ -119,7 +124,8 @@ NGBRegression <- R6::R6Class(
return(self)
},
#' @description An NGBRegressor object that can be fit.
#' @param X DataFrame object or List or numpy array of predictors (n x p) in Numeric format
#' @param X DataFrame object or List or numpy array of predictors (n x p)
#' in Numeric format
#' @param Y DataFrame object or List or numpy array of outcomes (n)
#' in numeric format. Should be floats for regression and integers from 0
#' to K-1 for K-class classification
Expand All @@ -132,8 +138,8 @@ NGBRegression <- R6::R6Class(
#' @param val_sample_weight How much to weigh each example in the validation
#' set. (defaults to 1)
#' @param train_loss_monitor A custom score or set of scores to track on the
#' training set during training. Defaults to the score defined in the NGBoost
#' constructor.
#' training set during training. Defaults to the score defined in the
#' NGBoost constructor.
#' @param val_loss_monitor A custom score or set of scores to track on the
#' validation set during training. Defaults to the score defined in the
#' NGBoost constructor
Expand Down
20 changes: 13 additions & 7 deletions R/ngbsurv.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
#' @description
#' NGBSurvival is a wrapper for the generic NGBoost class that facilitates
#' survival analysis.
#'
#' Use this class if you want to predict an outcome that could take an infinite
#' number of (ordered) values, but right-censoring is present in the observed data.
#' number of (ordered) values, but right-censoring is present in the observed
#' data.
#'
#' @author Resul Akay
#' @importFrom R6 R6Class
Expand All @@ -18,13 +20,18 @@ NGBSurvival <- R6::R6Class(
#' data. A score from ngboost.scores, e.g. LogScore
#' @param Base Base learner to use in the boosting algorithm.
#' Any instantiated sklearn regressor, e.g. DecisionTreeRegressor()
#' @param natural_gradient Logical flag indicating whether the natural gradient should be used
#' @param natural_gradient Logical flag indicating whether the natural
#' gradient should be used
#' @param n_estimators The number of boosting iterations to fit
#' @param learning_rate The learning rate
#' @param minibatch_frac The percent subsample of rows to use in each boosting iteration
#' @param col_sample The percent subsample of columns to use in each boosting iteration
#' @param verbose Flag indicating whether output should be printed during fitting
#' @param verbose_eval Increment (in boosting iterations) at which output should be printed
#' @param minibatch_frac The percent subsample of rows to use in each
#' boosting iteration
#' @param col_sample The percent subsample of columns to use in each
#' boosting iteration
#' @param verbose Flag indicating whether output should be printed during
#' fitting
#' @param verbose_eval Increment (in boosting iterations) at which output
#' should be printed
#' @param tol Numerical tolerance to be used in optimization
#' @param random_state Seed for reproducibility.
#' @return An NGBRegressor object that can be fit.
Expand Down Expand Up @@ -53,7 +60,6 @@ NGBSurvival <- R6::R6Class(
private$tol <- tol
private$random_state <- random_state

#ngboost <- reticulate::import("ngboost")
private$model <- ngboost$NGBSurvival(
Dist = private$Dist,
Score = private$Score,
Expand Down
6 changes: 4 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ Dist <- function(dist = c("Normal", "Bernoulli", "k_categorical", "StudentT",
#' \itemize{
#'
#' \item LogScore : Generic class for the log scoring rule.
#' \item CRPS : Generic class for the continuous ranked probability scoring rule.
#' \item CRPScore : Generic class for the continuous ranked probability scoring rule.
#' \item CRPS : Generic class for the continuous ranked probability scoring
#' rule.
#' \item CRPScore : Generic class for the continuous ranked probability
#' scoring rule.
#' \item MLE : Generic class for the log scoring rule.
#' }
#' @author Resul Akay
Expand Down
22 changes: 14 additions & 8 deletions man/NGBClassifier.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions man/NGBDist.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 14 additions & 8 deletions man/NGBRegression.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 13 additions & 6 deletions man/NGBSurvival.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions man/Scores.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e043cb2

Please sign in to comment.