Skip to content
Snippets Groups Projects
Commit 99fd7310 authored by Eilert Tunheim's avatar Eilert Tunheim
Browse files

Started working on logistic regression, wrong formula

parent f2d7b1d5
No related branches found
No related tags found
No related merge requests found
......@@ -54,37 +54,6 @@
<orderEntry type="library" name="Maven: com.google.auto.value:auto-value-annotations:1.9" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.6.1" level="project" />
<orderEntry type="library" name="Maven: joda-time:joda-time:2.10.14" level="project" />
<orderEntry type="library" name="Maven: org.python:jython-slim:2.7.2" level="project" />
<orderEntry type="library" name="Maven: org.antlr:antlr:3.5.2" level="project" />
<orderEntry type="library" name="Maven: org.antlr:ST4:4.0.8" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: javax.servlet:javax.servlet-api:3.1.0" level="project" />
<orderEntry type="library" name="Maven: org.antlr:antlr-runtime:3.5.2" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.apache.commons:commons-compress:1.19" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.bouncycastle:bcpkix-jdk15on:1.62" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.bouncycastle:bcprov-jdk15on:1.62" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.ow2.asm:asm:7.1" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.ow2.asm:asm-commons:7.1" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.ow2.asm:asm-tree:7.1" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.ow2.asm:asm-analysis:7.1" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.ow2.asm:asm-util:7.1" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.ibm.icu:icu4j:59.1" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.carrotsearch:java-sizeof:0.0.5" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.github.jnr:jffi:1.2.20" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.github.jnr:jnr-netdb:1.1.6" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.github.jnr:jnr-ffi:2.1.10" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.github.jnr:jffi:native:1.2.19" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.github.jnr:jnr-a64asm:1.0.0" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.github.jnr:jnr-x86asm:1.0.2" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.github.jnr:jnr-posix:3.0.50" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.github.jnr:jnr-constants:0.9.12" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: jline:jline:2.14.5" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-buffer:4.1.45.Final" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-codec:4.1.45.Final" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-common:4.1.45.Final" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-handler:4.1.45.Final" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-resolver:4.1.45.Final" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: io.netty:netty-transport:4.1.45.Final" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.apache.ant:ant:1.9.7" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.apache.ant:ant-launcher:1.9.7" level="project" />
<orderEntry type="library" name="Maven: org.jblas:jblas:1.2.4" level="project" />
</component>
</module>
\ No newline at end of file
......@@ -41,9 +41,9 @@
<version>2.10.14</version>
</dependency>
<dependency>
<groupId>org.python</groupId>
<artifactId>jython-slim</artifactId>
<version>2.7.2</version>
<groupId>org.jblas</groupId>
<artifactId>jblas</artifactId>
<version>1.2.4</version>
</dependency>
</dependencies>
......
......@@ -511,6 +511,7 @@ public class DB {
formatedUtTidTorkPlussDays = addedDays.plusDays(ARJANG_NR_ADDED_DAYS).toString();
formatedUtTidTorkPlussDays = formatedUtTidTorkPlussDays.split("T")[0];
/*
if (locationID == ARJANG_LOCATION_ID) {
// Sqlstatement
......@@ -543,8 +544,12 @@ public class DB {
if(!moistureMeasured.isEmpty()){
manMoistData.put(formatedUtTidTork,moistureMeasured);
}
}
*/
......
......@@ -9,7 +9,6 @@ import org.apache.commons.math3.distribution.TDistribution;
import org.apache.commons.math3.exception.MathIllegalArgumentException;
import org.apache.commons.math3.stat.descriptive.SummaryStatistics;
import org.apache.commons.math3.stat.regression.SimpleRegression;
import org.python.util.PythonInterpreter;
import java.util.*;
......@@ -117,7 +116,7 @@ public class LineChartFunctionality {
index++;
}
//allSeries.add(newSeries);
updateLineChart(newSeries);
//updateLineChart(newSeries);
//lineChart.setOpacity(1);
}
......@@ -126,6 +125,8 @@ public class LineChartFunctionality {
// Stores the data from the confidence interval in a new map
Map<Integer, ArrayList<Double>> confidenceIntervalData = statistics(multiMap);
//getNonLinearRegression(confidenceIntervalData);
// Checks the max size for the arraylists needed for the data array later
int jMaxSize = 0;
for (int i = 0; i < confidenceIntervalData.size(); i++) {
......@@ -181,13 +182,12 @@ public class LineChartFunctionality {
for (double[] datum : data) {
//System.out.println("");
for (double v : datum) {
//System.out.println("Data: "+v);
}
}
PythonInterpreter pythonInterpreter = new PythonInterpreter();
//pythonInterpreter
......@@ -196,9 +196,10 @@ public class LineChartFunctionality {
// Connect the data to a series
//System.out.println(simpleRegression.predict(i));
regressionSeries.getData().add(new XYChart.Data<String, Number>(String.valueOf(i), simpleRegression.predict(i)));
//regressionSeries.getData().add(new XYChart.Data<String, Number>(String.valueOf(i), simpleRegression.predict(i)));
regressionSeries.getData().add(new XYChart.Data<String, Number>(String.valueOf(i), getNonLinearRegression(confidenceIntervalData,simpleRegression.getIntercept(),simpleRegression.getSlope(),i)));
}
//updateLineChart(regressionSeries);
updateLineChart(regressionSeries);
//lineChart.setOpacity(1);
......@@ -219,6 +220,36 @@ public class LineChartFunctionality {
//simpleRegression.add
return getLineChart();
}
public static double getNonLinearRegression(Map<Integer, ArrayList<Double>> confidenceIntervalData, double slope, double intercept, double j) {
//return Math.exp(intercept+slope*i)/(1+Math.exp(intercept+slope*i));
double alpha = intercept/100;
double beta = alpha/(slope/100);
double maxYValue = 0.0;
double n = confidenceIntervalData.size();
for (Map.Entry<Integer, ArrayList<Double>> entry : confidenceIntervalData.entrySet()) {
for (int i = 0; i < entry.getValue().size(); i++) {
if(maxYValue < entry.getValue().get(i)){
maxYValue = entry.getValue().get(i);
}
}
}
//System.out.println("maxYValue: " + maxYValue);
//System.out.println("j*n: "+j/n);
double p_t = ((beta*maxYValue)/(maxYValue+((beta-maxYValue)*Math.exp(-alpha*(j)))));
System.out.println("---------------------------");
System.out.println(p_t);
return p_t;
}
}
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment