This example runs a logistic regression using the GAUSS DC application. The examples uses the diabetes dataset which contains 442 observations of ten feature variables including age, sex, body mass index, average blood pressure, and six blood serum measurements and one response variable, a quantitative measure of diabetes progression one year after baseline.
Load the data
This example loads the data directly from in the saved matrix, diabetes.fmt , stored in the examples directory.
new; cls; library dc; /* ** Load Data */ mat_file = __FILE_DIR $+ "diabetes.fmt"; diabetes = loadd(mat_file); y = diabetes[., 9]; x = diabetes[., 1:8];
All parameters for the
logisticRegress procedure are stored in the
lrControl structure. An instance of the
lrControl structure must be declared for storing all parameters prior to running the
logisticRegress procedure. Once an instance is declared, the hyperparameters of the logistic regress model are controlled by changing the members within the structure:
// Declare and initialize lrControl structure struct lrControl lctl; lctl = lrGetDefaults(); // Set solver to the L2R_L2LOSS_SVC_DUAL lctl.solverType = 3; // Set cross validation to zero folds lctl.crossValidation = 0; // Turn on prediction lctl.predict = 1; // Turn on prediction plot lctl.plotPredict = 1;
Estimate the Model
The logistic regression can be estimated using the
logisticRegress procedure. This procedure takes a
lrControl structure as an input, a dependent variable matrix, y, and in independent data matrix, x, as inputs. It returns all output to a
// Call logistic regression function struct lrOut lOut; lOut = logisticRegress(lctl, y, x);
The procedure produces the following plots: