Skip to content

Commit

Permalink
analysis: compute OR from logistic regression coefficient, #126
Browse files Browse the repository at this point in the history
  • Loading branch information
jtarraga committed Jun 9, 2017
1 parent 01f7ead commit 3e6393d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package org.opencb.hpg.bigdata.analysis.variant;

import org.apache.spark.ml.classification.BinaryLogisticRegressionSummary;
import org.apache.spark.ml.classification.LogisticRegression;
import org.apache.spark.ml.classification.LogisticRegressionModel;
import org.apache.spark.ml.classification.LogisticRegressionTrainingSummary;
import org.apache.spark.mllib.linalg.Vectors;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SparkSession;
import org.apache.spark.sql.functions;

/**
* Created by jtarraga on 30/05/17.
Expand All @@ -26,13 +28,13 @@ public void execute() {
// print the coefficients and intercept for linear regression
System.out.println("Coefficients: "
+ lrModel.coefficients() + " Intercept: " + lrModel.intercept());
System.out.println("OR (for coeff.) = " + Math.exp(lrModel.coefficients().apply(1)));

// summarize the model over the training set and print out some metrics
LogisticRegressionTrainingSummary trainingSummary = lrModel.summary();
System.out.println("numIterations: " + trainingSummary.totalIterations());
System.out.println("objectiveHistory: " + Vectors.dense(trainingSummary.objectiveHistory()));

/*
// obtain the loss per iteration
double[] objectiveHistory = trainingSummary.objectiveHistory();
for (double lossPerIteration : objectiveHistory) {
Expand All @@ -58,7 +60,6 @@ public void execute() {
double bestThreshold = fMeasure.where(fMeasure.col("F-Measure").equalTo(maxFMeasure))
.select("threshold").head().getDouble(0);
lrModel.setThreshold(bestThreshold);
*/
}

public LogisticRegressionAnalysis(String datasetName, String studyName, String depVarName, String indepVarName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public void assoc() {
commandLine.append(" -i ").append(inPath);
commandLine.append(" -o ").append(outPath);
commandLine.append(" --dataset noname");
//commandLine.append(" --logistic");
commandLine.append(" --linear");
commandLine.append(" --pheno Age:s");
commandLine.append(" --logistic");
//commandLine.append(" --linear");
//commandLine.append(" --pheno Age:s");

VariantQueryCLITest.execute(commandLine.toString());
} catch (Exception e) {
Expand Down

0 comments on commit 3e6393d

Please sign in to comment.