/** * Reads the parameters from a file and populates an array of context objects. * @param outcomePatterns The outcomes patterns for the model. The first index refers to which * outcome pattern (a set of outcomes that occurs with a context) is being specified. The * second index specifies the number of contexts which use this pattern at index 0, and the * index of each outcomes which make up this pattern in indicies 1-n. * @return An array of context objects. * @throws java.io.IOException when the model file does not match the outcome patterns or can not be read. */ protected Context[] getParameters(int[][] outcomePatterns) throws java.io.IOException { Context[] params = new Context[NUM_PREDS]; int pid = 0; for (int i = 0; i < outcomePatterns.length; i++) { //construct outcome pattern int[] outcomePattern = new int[outcomePatterns[i].length - 1]; System.arraycopy(outcomePatterns[i], 1, outcomePattern, 0, outcomePatterns[i].length - 1); //populate parameters for each context which uses this outcome pattern. for (int j = 0; j < outcomePatterns[i][0]; j++) { double[] contextParameters = new double[outcomePatterns[i].length - 1]; for (int k = 1; k < outcomePatterns[i].length; k++) { contextParameters[k - 1] = readDouble(); } params[pid] = new Context(outcomePattern,contextParameters); pid++; } } return params; }
/** * Reads the parameters from a file and populates an array of context objects. * @param outcomePatterns The outcomes patterns for the model. The first index refers to which * outcome pattern (a set of outcomes that occurs with a context) is being specified. The * second index specifies the number of contexts which use this pattern at index 0, and the * index of each outcomes which make up this pattern in indicies 1-n. * @return An array of context objects. * @throws java.io.IOException when the model file does not match the outcome patterns or can not be read. */ protected Context[] getParameters(int[][] outcomePatterns) throws java.io.IOException { Context[] params = new Context[NUM_PREDS]; int pid = 0; for (int i = 0; i < outcomePatterns.length; i++) { //construct outcome pattern int[] outcomePattern = new int[outcomePatterns[i].length - 1]; System.arraycopy(outcomePatterns[i], 1, outcomePattern, 0, outcomePatterns[i].length - 1); //populate parameters for each context which uses this outcome pattern. for (int j = 0; j < outcomePatterns[i][0]; j++) { double[] contextParameters = new double[outcomePatterns[i].length - 1]; for (int k = 1; k < outcomePatterns[i].length; k++) { contextParameters[k - 1] = readDouble(); } params[pid] = new Context(outcomePattern,contextParameters); pid++; } } return params; }
/** * Reads the parameters from a file and populates an array of context objects. * @param outcomePatterns The outcomes patterns for the model. The first index refers to which * outcome pattern (a set of outcomes that occurs with a context) is being specified. The * second index specifies the number of contexts which use this pattern at index 0, and the * index of each outcomes which make up this pattern in indicies 1-n. * @return An array of context objects. * @throws java.io.IOException when the model file does not match the outcome patterns or can not be read. */ protected Context[] getParameters(int[][] outcomePatterns) throws java.io.IOException { Context[] params = new Context[NUM_PREDS]; int pid = 0; for (int i = 0; i < outcomePatterns.length; i++) { //construct outcome pattern int[] outcomePattern = new int[outcomePatterns[i].length - 1]; System.arraycopy(outcomePatterns[i], 1, outcomePattern, 0, outcomePatterns[i].length - 1); //populate parameters for each context which uses this outcome pattern. for (int j = 0; j < outcomePatterns[i][0]; j++) { double[] contextParameters = new double[outcomePatterns[i].length - 1]; for (int k = 1; k < outcomePatterns[i].length; k++) { contextParameters[k - 1] = readDouble(); } params[pid] = new Context(outcomePattern,contextParameters); pid++; } } return params; }