repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/neuralnetwork/SGDNetworkTrainer.java
SGDNetworkTrainer.feedfoward
public Vec feedfoward(Vec x) { Vec a_lprev = x; for (int l = 0; l < layersActivation.size(); l++) { Vec z_l = new DenseVector(layerSizes[l+1]); z_l.zeroOut(); W.get(l).multiply(a_lprev, 1.0, z_l); //add the bias term back in final Vec B_l = B.get(l); z_l.mutableAdd(B_l); layersActivation.get(l).activate(z_l, z_l); a_lprev = z_l; } return a_lprev; }
java
public Vec feedfoward(Vec x) { Vec a_lprev = x; for (int l = 0; l < layersActivation.size(); l++) { Vec z_l = new DenseVector(layerSizes[l+1]); z_l.zeroOut(); W.get(l).multiply(a_lprev, 1.0, z_l); //add the bias term back in final Vec B_l = B.get(l); z_l.mutableAdd(B_l); layersActivation.get(l).activate(z_l, z_l); a_lprev = z_l; } return a_lprev; }
[ "public", "Vec", "feedfoward", "(", "Vec", "x", ")", "{", "Vec", "a_lprev", "=", "x", ";", "for", "(", "int", "l", "=", "0", ";", "l", "<", "layersActivation", ".", "size", "(", ")", ";", "l", "++", ")", "{", "Vec", "z_l", "=", "new", "DenseVec...
Feeds the given singular pattern through the network and computes its activations @param x the input vector to feed forward through the network @return the final activation for this network
[ "Feeds", "the", "given", "singular", "pattern", "through", "the", "network", "and", "computes", "its", "activations" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/neuralnetwork/SGDNetworkTrainer.java#L606-L624
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/neuralnetwork/SGDNetworkTrainer.java
SGDNetworkTrainer.applyDropout
private static void applyDropout(final Matrix X, final int randThresh, final Random rand, ExecutorService ex) { if (ex == null) { for (int i = 0; i < X.rows(); i++) for (int j = 0; j < X.cols(); j++) if (rand.nextInt() < randThresh) X.set(i, j, 0.0); } else { final CountDownLatch latch = new CountDownLatch(SystemInfo.LogicalCores); for(int id = 0; id < SystemInfo.LogicalCores; id++) { final int ID = id; ex.submit(new Runnable() { @Override public void run() { for (int i = ID; i < X.rows(); i+=SystemInfo.LogicalCores) for (int j = 0; j < X.cols(); j++) if (rand.nextInt() < randThresh) X.set(i, j, 0.0); latch.countDown(); } }); } try { latch.await(); } catch (InterruptedException ex1) { Logger.getLogger(SGDNetworkTrainer.class.getName()).log(Level.SEVERE, null, ex1); } } }
java
private static void applyDropout(final Matrix X, final int randThresh, final Random rand, ExecutorService ex) { if (ex == null) { for (int i = 0; i < X.rows(); i++) for (int j = 0; j < X.cols(); j++) if (rand.nextInt() < randThresh) X.set(i, j, 0.0); } else { final CountDownLatch latch = new CountDownLatch(SystemInfo.LogicalCores); for(int id = 0; id < SystemInfo.LogicalCores; id++) { final int ID = id; ex.submit(new Runnable() { @Override public void run() { for (int i = ID; i < X.rows(); i+=SystemInfo.LogicalCores) for (int j = 0; j < X.cols(); j++) if (rand.nextInt() < randThresh) X.set(i, j, 0.0); latch.countDown(); } }); } try { latch.await(); } catch (InterruptedException ex1) { Logger.getLogger(SGDNetworkTrainer.class.getName()).log(Level.SEVERE, null, ex1); } } }
[ "private", "static", "void", "applyDropout", "(", "final", "Matrix", "X", ",", "final", "int", "randThresh", ",", "final", "Random", "rand", ",", "ExecutorService", "ex", ")", "{", "if", "(", "ex", "==", "null", ")", "{", "for", "(", "int", "i", "=", ...
Applies dropout to the given matrix @param X the matrix to dropout values from @param randThresh the threshold that a random integer must be less than to get dropped out @param rand the source of randomness @param ex the source of threads for parlallel computation, or {@code null}
[ "Applies", "dropout", "to", "the", "given", "matrix" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/neuralnetwork/SGDNetworkTrainer.java#L778-L817
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/boosting/UpdatableStacking.java
UpdatableStacking.getPredVecR
private DataPoint getPredVecR(DataPoint data) { Vec w = new DenseVector(baseRegressors.size()); for (int i = 0; i < baseRegressors.size(); i++) w.set(i, baseRegressors.get(i).regress(data)); return new DataPoint(w); }
java
private DataPoint getPredVecR(DataPoint data) { Vec w = new DenseVector(baseRegressors.size()); for (int i = 0; i < baseRegressors.size(); i++) w.set(i, baseRegressors.get(i).regress(data)); return new DataPoint(w); }
[ "private", "DataPoint", "getPredVecR", "(", "DataPoint", "data", ")", "{", "Vec", "w", "=", "new", "DenseVector", "(", "baseRegressors", ".", "size", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "baseRegressors", ".", "size", ...
Gets the predicted vector wrapped in a new DataPoint from a data point assuming we are doing regression @param data the data point to get the classifier from @return the vector of predictions from each regressor
[ "Gets", "the", "predicted", "vector", "wrapped", "in", "a", "new", "DataPoint", "from", "a", "data", "point", "assuming", "we", "are", "doing", "regression" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/boosting/UpdatableStacking.java#L186-L192
train
EdwardRaff/JSAT
JSAT/src/jsat/utils/ClosedHashingUtil.java
ClosedHashingUtil.getNextPow2TwinPrime
public static int getNextPow2TwinPrime(int m) { int pos = Arrays.binarySearch(twinPrimesP2, m+1); if(pos >= 0) return twinPrimesP2[pos]; else return twinPrimesP2[-pos - 1]; }
java
public static int getNextPow2TwinPrime(int m) { int pos = Arrays.binarySearch(twinPrimesP2, m+1); if(pos >= 0) return twinPrimesP2[pos]; else return twinPrimesP2[-pos - 1]; }
[ "public", "static", "int", "getNextPow2TwinPrime", "(", "int", "m", ")", "{", "int", "pos", "=", "Arrays", ".", "binarySearch", "(", "twinPrimesP2", ",", "m", "+", "1", ")", ";", "if", "(", "pos", ">=", "0", ")", "return", "twinPrimesP2", "[", "pos", ...
Gets the next twin prime that is near a power of 2 and greater than or equal to the given value @param m the integer to get a twine prime larger than @return the a twin prime greater than or equal to
[ "Gets", "the", "next", "twin", "prime", "that", "is", "near", "a", "power", "of", "2", "and", "greater", "than", "or", "equal", "to", "the", "given", "value" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/utils/ClosedHashingUtil.java#L55-L62
train
EdwardRaff/JSAT
JSAT/src/jsat/DataSet.java
DataSet.replaceNumericFeatures
public void replaceNumericFeatures(List<Vec> newNumericFeatures) { if(this.size() != newNumericFeatures.size()) throw new RuntimeException("Input list does not have the same not of dataums as the dataset"); for(int i = 0; i < newNumericFeatures.size(); i++) { DataPoint dp_i = getDataPoint(i); setDataPoint(i, new DataPoint(newNumericFeatures.get(i), dp_i.getCategoricalValues(), dp_i.getCategoricalData())); } this.numNumerVals = getDataPoint(0).numNumericalValues(); if (this.numericalVariableNames != null) this.numericalVariableNames.clear(); }
java
public void replaceNumericFeatures(List<Vec> newNumericFeatures) { if(this.size() != newNumericFeatures.size()) throw new RuntimeException("Input list does not have the same not of dataums as the dataset"); for(int i = 0; i < newNumericFeatures.size(); i++) { DataPoint dp_i = getDataPoint(i); setDataPoint(i, new DataPoint(newNumericFeatures.get(i), dp_i.getCategoricalValues(), dp_i.getCategoricalData())); } this.numNumerVals = getDataPoint(0).numNumericalValues(); if (this.numericalVariableNames != null) this.numericalVariableNames.clear(); }
[ "public", "void", "replaceNumericFeatures", "(", "List", "<", "Vec", ">", "newNumericFeatures", ")", "{", "if", "(", "this", ".", "size", "(", ")", "!=", "newNumericFeatures", ".", "size", "(", ")", ")", "throw", "new", "RuntimeException", "(", "\"Input list...
This method will replace every numeric feature in this dataset with a Vec object from the given list. All vecs in the given list must be of the same size. @param newNumericFeatures the list of new numeric features to use
[ "This", "method", "will", "replace", "every", "numeric", "feature", "in", "this", "dataset", "with", "a", "Vec", "object", "from", "the", "given", "list", ".", "All", "vecs", "in", "the", "given", "list", "must", "be", "of", "the", "same", "size", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/DataSet.java#L245-L260
train
EdwardRaff/JSAT
JSAT/src/jsat/DataSet.java
DataSet.base_add
protected void base_add(DataPoint dp, double weight) { datapoints.addDataPoint(dp); setWeight(size()-1, weight); }
java
protected void base_add(DataPoint dp, double weight) { datapoints.addDataPoint(dp); setWeight(size()-1, weight); }
[ "protected", "void", "base_add", "(", "DataPoint", "dp", ",", "double", "weight", ")", "{", "datapoints", ".", "addDataPoint", "(", "dp", ")", ";", "setWeight", "(", "size", "(", ")", "-", "1", ",", "weight", ")", ";", "}" ]
Adds a new datapoint to this set.This method is protected, as not all datasets will be satisfied by adding just a data point. @param dp the datapoint to add @param weight weight of the point to add
[ "Adds", "a", "new", "datapoint", "to", "this", "set", ".", "This", "method", "is", "protected", "as", "not", "all", "datasets", "will", "be", "satisfied", "by", "adding", "just", "a", "data", "point", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/DataSet.java#L269-L273
train
EdwardRaff/JSAT
JSAT/src/jsat/DataSet.java
DataSet.getDataPointIterator
public Iterator<DataPoint> getDataPointIterator() { Iterator<DataPoint> iteData = new Iterator<DataPoint>() { int cur = 0; int to = size(); @Override public boolean hasNext() { return cur < to; } @Override public DataPoint next() { return getDataPoint(cur++); } @Override public void remove() { throw new UnsupportedOperationException("This operation is not supported for DataSet"); } }; return iteData; }
java
public Iterator<DataPoint> getDataPointIterator() { Iterator<DataPoint> iteData = new Iterator<DataPoint>() { int cur = 0; int to = size(); @Override public boolean hasNext() { return cur < to; } @Override public DataPoint next() { return getDataPoint(cur++); } @Override public void remove() { throw new UnsupportedOperationException("This operation is not supported for DataSet"); } }; return iteData; }
[ "public", "Iterator", "<", "DataPoint", ">", "getDataPointIterator", "(", ")", "{", "Iterator", "<", "DataPoint", ">", "iteData", "=", "new", "Iterator", "<", "DataPoint", ">", "(", ")", "{", "int", "cur", "=", "0", ";", "int", "to", "=", "size", "(", ...
Returns an iterator that will iterate over all data points in the set. The behavior is not defined if one attempts to modify the data set while being iterated. @return an iterator for the data points
[ "Returns", "an", "iterator", "that", "will", "iterate", "over", "all", "data", "points", "in", "the", "set", ".", "The", "behavior", "is", "not", "defined", "if", "one", "attempts", "to", "modify", "the", "data", "set", "while", "being", "iterated", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/DataSet.java#L397-L424
train
EdwardRaff/JSAT
JSAT/src/jsat/DataSet.java
DataSet.getMissingDropped
public Type getMissingDropped() { List<Integer> hasNoMissing = new IntList(); for (int i = 0; i < size(); i++) { DataPoint dp = getDataPoint(i); boolean missing = dp.getNumericalValues().countNaNs() > 0; for(int c : dp.getCategoricalValues()) if(c < 0) missing = true; if(!missing) hasNoMissing.add(i); } return getSubset(hasNoMissing); }
java
public Type getMissingDropped() { List<Integer> hasNoMissing = new IntList(); for (int i = 0; i < size(); i++) { DataPoint dp = getDataPoint(i); boolean missing = dp.getNumericalValues().countNaNs() > 0; for(int c : dp.getCategoricalValues()) if(c < 0) missing = true; if(!missing) hasNoMissing.add(i); } return getSubset(hasNoMissing); }
[ "public", "Type", "getMissingDropped", "(", ")", "{", "List", "<", "Integer", ">", "hasNoMissing", "=", "new", "IntList", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "size", "(", ")", ";", "i", "++", ")", "{", "DataPoint", "dp...
This method returns a dataset that is a subset of this dataset, where only the rows that have no missing values are kept. The new dataset is backed by this dataset. @return a subset of this dataset that has all data points with missing features dropped
[ "This", "method", "returns", "a", "dataset", "that", "is", "a", "subset", "of", "this", "dataset", "where", "only", "the", "rows", "that", "have", "no", "missing", "values", "are", "kept", ".", "The", "new", "dataset", "is", "backed", "by", "this", "data...
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/DataSet.java#L500-L514
train
EdwardRaff/JSAT
JSAT/src/jsat/DataSet.java
DataSet.randomSplit
public List<Type> randomSplit(Random rand, double... splits) { if(splits.length < 1) throw new IllegalArgumentException("Input array of split fractions must be non-empty"); IntList randOrder = new IntList(size()); ListUtils.addRange(randOrder, 0, size(), 1); Collections.shuffle(randOrder, rand); int[] stops = new int[splits.length]; double sum = 0; for(int i = 0; i < splits.length; i++) { sum += splits[i]; if(sum >= 1.001/*some flex room for numeric issues*/) throw new IllegalArgumentException("Input splits sum is greater than 1 by index " + i + " reaching a sum of " + sum); stops[i] = (int) Math.round(sum*randOrder.size()); } List<Type> datasets = new ArrayList<>(splits.length); int prev = 0; for(int i = 0; i < stops.length; i++) { datasets.add(getSubset(randOrder.subList(prev, stops[i]))); prev = stops[i]; } return datasets; }
java
public List<Type> randomSplit(Random rand, double... splits) { if(splits.length < 1) throw new IllegalArgumentException("Input array of split fractions must be non-empty"); IntList randOrder = new IntList(size()); ListUtils.addRange(randOrder, 0, size(), 1); Collections.shuffle(randOrder, rand); int[] stops = new int[splits.length]; double sum = 0; for(int i = 0; i < splits.length; i++) { sum += splits[i]; if(sum >= 1.001/*some flex room for numeric issues*/) throw new IllegalArgumentException("Input splits sum is greater than 1 by index " + i + " reaching a sum of " + sum); stops[i] = (int) Math.round(sum*randOrder.size()); } List<Type> datasets = new ArrayList<>(splits.length); int prev = 0; for(int i = 0; i < stops.length; i++) { datasets.add(getSubset(randOrder.subList(prev, stops[i]))); prev = stops[i]; } return datasets; }
[ "public", "List", "<", "Type", ">", "randomSplit", "(", "Random", "rand", ",", "double", "...", "splits", ")", "{", "if", "(", "splits", ".", "length", "<", "1", ")", "throw", "new", "IllegalArgumentException", "(", "\"Input array of split fractions must be non-...
Splits the dataset randomly into proportionally sized partitions. @param rand the source of randomness for moving data around @param splits any array, where the length is the number of datasets to create and the value of in each index is the fraction of samples that should be placed into that dataset. The sum of values must be less than or equal to 1.0 @return a list of new datasets
[ "Splits", "the", "dataset", "randomly", "into", "proportionally", "sized", "partitions", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/DataSet.java#L526-L555
train
EdwardRaff/JSAT
JSAT/src/jsat/DataSet.java
DataSet.getDataPoints
public List<DataPoint> getDataPoints() { List<DataPoint> list = new ArrayList<>(size()); for(int i = 0; i < size(); i++) list.add(getDataPoint(i)); return list; }
java
public List<DataPoint> getDataPoints() { List<DataPoint> list = new ArrayList<>(size()); for(int i = 0; i < size(); i++) list.add(getDataPoint(i)); return list; }
[ "public", "List", "<", "DataPoint", ">", "getDataPoints", "(", ")", "{", "List", "<", "DataPoint", ">", "list", "=", "new", "ArrayList", "<>", "(", "size", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "size", "(", ")", "...
Creates a list containing the same DataPoints in this set. They are soft copies, in the same order as this data set. However, altering this list will have no effect on DataSet. Altering the DataPoints in the list will effect the DataPoints in this DataSet. @return a list of the DataPoints in this DataSet.
[ "Creates", "a", "list", "containing", "the", "same", "DataPoints", "in", "this", "set", ".", "They", "are", "soft", "copies", "in", "the", "same", "order", "as", "this", "data", "set", ".", "However", "altering", "this", "list", "will", "have", "no", "ef...
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/DataSet.java#L608-L614
train
EdwardRaff/JSAT
JSAT/src/jsat/DataSet.java
DataSet.getDataVectors
public List<Vec> getDataVectors() { List<Vec> vecs = new ArrayList<>(size()); for(int i = 0; i < size(); i++) vecs.add(getDataPoint(i).getNumericalValues()); return vecs; }
java
public List<Vec> getDataVectors() { List<Vec> vecs = new ArrayList<>(size()); for(int i = 0; i < size(); i++) vecs.add(getDataPoint(i).getNumericalValues()); return vecs; }
[ "public", "List", "<", "Vec", ">", "getDataVectors", "(", ")", "{", "List", "<", "Vec", ">", "vecs", "=", "new", "ArrayList", "<>", "(", "size", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "size", "(", ")", ";", "i", ...
Creates a list of the vectors values for each data point in the correct order. @return a list of the vectors for the data points
[ "Creates", "a", "list", "of", "the", "vectors", "values", "for", "each", "data", "point", "in", "the", "correct", "order", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/DataSet.java#L620-L626
train
EdwardRaff/JSAT
JSAT/src/jsat/DataSet.java
DataSet.setWeight
public void setWeight(int i, double w) { if(i >= size() || i < 0) throw new IndexOutOfBoundsException("Dataset has only " + size() + " members, can't access index " + i ); else if(Double.isNaN(w) || Double.isInfinite(w) || w < 0) throw new ArithmeticException("Invalid weight assignment of " + w); if(w == 1 && weights == null) return;//nothing to do, already handled implicitly if(weights == null)//need to init? { weights = new double[size()]; Arrays.fill(weights, 1.0); } //make sure we have enouh space if (weights.length <= i) weights = Arrays.copyOfRange(weights, 0, Math.max(weights.length*2, i+1)); weights[i] = w; }
java
public void setWeight(int i, double w) { if(i >= size() || i < 0) throw new IndexOutOfBoundsException("Dataset has only " + size() + " members, can't access index " + i ); else if(Double.isNaN(w) || Double.isInfinite(w) || w < 0) throw new ArithmeticException("Invalid weight assignment of " + w); if(w == 1 && weights == null) return;//nothing to do, already handled implicitly if(weights == null)//need to init? { weights = new double[size()]; Arrays.fill(weights, 1.0); } //make sure we have enouh space if (weights.length <= i) weights = Arrays.copyOfRange(weights, 0, Math.max(weights.length*2, i+1)); weights[i] = w; }
[ "public", "void", "setWeight", "(", "int", "i", ",", "double", "w", ")", "{", "if", "(", "i", ">=", "size", "(", ")", "||", "i", "<", "0", ")", "throw", "new", "IndexOutOfBoundsException", "(", "\"Dataset has only \"", "+", "size", "(", ")", "+", "\"...
Sets the weight of a given datapoint within this data set. @param i the index to change the weight of @param w the new weight value.
[ "Sets", "the", "weight", "of", "a", "given", "datapoint", "within", "this", "data", "set", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/DataSet.java#L832-L853
train
EdwardRaff/JSAT
JSAT/src/jsat/DataSet.java
DataSet.getWeight
public double getWeight(int i) { if(i >= size() || i < 0) throw new IndexOutOfBoundsException("Dataset has only " + size() + " members, can't access index " + i ); if(weights == null) return 1; else if(weights.length <= i) return 1; else return weights[i]; }
java
public double getWeight(int i) { if(i >= size() || i < 0) throw new IndexOutOfBoundsException("Dataset has only " + size() + " members, can't access index " + i ); if(weights == null) return 1; else if(weights.length <= i) return 1; else return weights[i]; }
[ "public", "double", "getWeight", "(", "int", "i", ")", "{", "if", "(", "i", ">=", "size", "(", ")", "||", "i", "<", "0", ")", "throw", "new", "IndexOutOfBoundsException", "(", "\"Dataset has only \"", "+", "size", "(", ")", "+", "\" members, can't access i...
Returns the weight of the specified data point @param i the data point index to get the weight of @return the weight of the requested data point
[ "Returns", "the", "weight", "of", "the", "specified", "data", "point" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/DataSet.java#L860-L870
train
EdwardRaff/JSAT
JSAT/src/jsat/DataSet.java
DataSet.getDataWeights
public Vec getDataWeights() { final int N = this.size(); if(N == 0) return new DenseVector(0); //assume everyone has the same weight until proven otherwise. double weight = getWeight(0); double[] weights_copy = null; for(int i = 1; i < N; i++) { double w_i = getWeight(i); if(weights_copy != null || weight != w_i) { if(weights_copy==null)//need to init storage place { weights_copy = new double[N]; Arrays.fill(weights_copy, 0, i, weight); } weights_copy[i] = w_i; } } if(weights_copy == null) return new ConstantVector(weight, size()); else return new DenseVector(weights_copy); }
java
public Vec getDataWeights() { final int N = this.size(); if(N == 0) return new DenseVector(0); //assume everyone has the same weight until proven otherwise. double weight = getWeight(0); double[] weights_copy = null; for(int i = 1; i < N; i++) { double w_i = getWeight(i); if(weights_copy != null || weight != w_i) { if(weights_copy==null)//need to init storage place { weights_copy = new double[N]; Arrays.fill(weights_copy, 0, i, weight); } weights_copy[i] = w_i; } } if(weights_copy == null) return new ConstantVector(weight, size()); else return new DenseVector(weights_copy); }
[ "public", "Vec", "getDataWeights", "(", ")", "{", "final", "int", "N", "=", "this", ".", "size", "(", ")", ";", "if", "(", "N", "==", "0", ")", "return", "new", "DenseVector", "(", "0", ")", ";", "//assume everyone has the same weight until proven otherwise....
This method returns the weight of each data point in a single Vector. When all data points have the same weight, this will return a vector that uses fixed memory instead of allocating a full double backed array. @return a vector that will return the weight for each data point with the same corresponding index.
[ "This", "method", "returns", "the", "weight", "of", "each", "data", "point", "in", "a", "single", "Vector", ".", "When", "all", "data", "points", "have", "the", "same", "weight", "this", "will", "return", "a", "vector", "that", "uses", "fixed", "memory", ...
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/DataSet.java#L880-L907
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/trees/ERTrees.java
ERTrees.evaluateFeatureImportance
public <Type extends DataSet> OnLineStatistics[] evaluateFeatureImportance(DataSet<Type> data, TreeFeatureImportanceInference imp) { OnLineStatistics[] importances = new OnLineStatistics[data.getNumFeatures()]; for(int i = 0; i < importances.length; i++) importances[i] = new OnLineStatistics(); for(ExtraTree tree :forrest) { double[] feats = imp.getImportanceStats(tree, data); for(int i = 0; i < importances.length; i++) importances[i].add(feats[i]); } return importances; }
java
public <Type extends DataSet> OnLineStatistics[] evaluateFeatureImportance(DataSet<Type> data, TreeFeatureImportanceInference imp) { OnLineStatistics[] importances = new OnLineStatistics[data.getNumFeatures()]; for(int i = 0; i < importances.length; i++) importances[i] = new OnLineStatistics(); for(ExtraTree tree :forrest) { double[] feats = imp.getImportanceStats(tree, data); for(int i = 0; i < importances.length; i++) importances[i].add(feats[i]); } return importances; }
[ "public", "<", "Type", "extends", "DataSet", ">", "OnLineStatistics", "[", "]", "evaluateFeatureImportance", "(", "DataSet", "<", "Type", ">", "data", ",", "TreeFeatureImportanceInference", "imp", ")", "{", "OnLineStatistics", "[", "]", "importances", "=", "new", ...
Measures the statistics of feature importance from the trees in this forest. @param <Type> @param data the dataset to infer the feature importance from with respect to the current model. @param imp the method of determing the feature importance that will be applied to each tree in this model @return an array of statistics, which each index corresponds to a specific feature. Numeric features start from the zero index, categorical features start from the index equal to the number of numeric features.
[ "Measures", "the", "statistics", "of", "feature", "importance", "from", "the", "trees", "in", "this", "forest", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/trees/ERTrees.java#L118-L132
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/linear/NewGLMNET.java
NewGLMNET.setC
@WarmParameter(prefLowToHigh = true) public void setC(double C) { if(C <= 0 || Double.isInfinite(C) || Double.isNaN(C)) throw new IllegalArgumentException("Regularization term C must be a positive value, not " + C); this.C = C; }
java
@WarmParameter(prefLowToHigh = true) public void setC(double C) { if(C <= 0 || Double.isInfinite(C) || Double.isNaN(C)) throw new IllegalArgumentException("Regularization term C must be a positive value, not " + C); this.C = C; }
[ "@", "WarmParameter", "(", "prefLowToHigh", "=", "true", ")", "public", "void", "setC", "(", "double", "C", ")", "{", "if", "(", "C", "<=", "0", "||", "Double", ".", "isInfinite", "(", "C", ")", "||", "Double", ".", "isNaN", "(", "C", ")", ")", "...
Sets the regularization term, where smaller values indicate a larger regularization penalty. @param C the positive regularization term
[ "Sets", "the", "regularization", "term", "where", "smaller", "values", "indicate", "a", "larger", "regularization", "penalty", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/linear/NewGLMNET.java#L156-L162
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/linear/NewGLMNET.java
NewGLMNET.getM_Bar_for_w0
private double getM_Bar_for_w0(int n, int l, List<Vec> columnsOfX, double[] col_neg_class_sum, double col_neg_class_sum_bias) { /** * if w=0, then D_part[i] = 0.5 for all i */ final double D_part_i = 0.5; //algo 3, Step 1. double M_bar = 0; //algo 3, Step 2. for(int j = 0; j < n; j++) { final double w_j = 0; //2.1. Calculate H^k_{jj}, ∇_j L(w^k) and ∇^S_j f(w^k) double delta_j_L = -columnsOfX.get(j).sum()*0.5; delta_j_L = /* (l2w * w_j) not needed b/c w_j=0*/ + C * (delta_j_L + col_neg_class_sum[j]); double deltaS_j_fw; //only the w_j = 0 case applies, b/c that is what this method is for! //w_j = 0 deltaS_j_fw = signum(delta_j_L) * max(abs(delta_j_L) - alpha, 0); //done with step 2, we have all the info M_bar += abs(deltaS_j_fw); } if (useBias) { //2.1. Calculate H^k_{jj}, ∇_j L(w^k) and ∇^S_j f(w^k) double delta_j_L = 0; for (int i = 0; i < l; i++)//all have an implicit bias term delta_j_L += -D_part_i; delta_j_L = C * (delta_j_L + col_neg_class_sum_bias); double deltaS_j_fw = delta_j_L; M_bar += abs(deltaS_j_fw); } return M_bar; }
java
private double getM_Bar_for_w0(int n, int l, List<Vec> columnsOfX, double[] col_neg_class_sum, double col_neg_class_sum_bias) { /** * if w=0, then D_part[i] = 0.5 for all i */ final double D_part_i = 0.5; //algo 3, Step 1. double M_bar = 0; //algo 3, Step 2. for(int j = 0; j < n; j++) { final double w_j = 0; //2.1. Calculate H^k_{jj}, ∇_j L(w^k) and ∇^S_j f(w^k) double delta_j_L = -columnsOfX.get(j).sum()*0.5; delta_j_L = /* (l2w * w_j) not needed b/c w_j=0*/ + C * (delta_j_L + col_neg_class_sum[j]); double deltaS_j_fw; //only the w_j = 0 case applies, b/c that is what this method is for! //w_j = 0 deltaS_j_fw = signum(delta_j_L) * max(abs(delta_j_L) - alpha, 0); //done with step 2, we have all the info M_bar += abs(deltaS_j_fw); } if (useBias) { //2.1. Calculate H^k_{jj}, ∇_j L(w^k) and ∇^S_j f(w^k) double delta_j_L = 0; for (int i = 0; i < l; i++)//all have an implicit bias term delta_j_L += -D_part_i; delta_j_L = C * (delta_j_L + col_neg_class_sum_bias); double deltaS_j_fw = delta_j_L; M_bar += abs(deltaS_j_fw); } return M_bar; }
[ "private", "double", "getM_Bar_for_w0", "(", "int", "n", ",", "int", "l", ",", "List", "<", "Vec", ">", "columnsOfX", ",", "double", "[", "]", "col_neg_class_sum", ",", "double", "col_neg_class_sum_bias", ")", "{", "/**\n * if w=0, then D_part[i] = 0.5 for a...
When we perform a warm start, we want to train to the same point that we would have if we had not done a warm start. But our stopping point is based on the initial relative error. To get around that, this method computes what the error would have been for the zero weight vector @param n @param l @param columnsOfX @param col_neg_class_sum @param col_neg_class_sum_bias @return the error for M_bar that would have been computed if we were using the zero weight vector
[ "When", "we", "perform", "a", "warm", "start", "we", "want", "to", "train", "to", "the", "same", "point", "that", "we", "would", "have", "if", "we", "had", "not", "done", "a", "warm", "start", ".", "But", "our", "stopping", "point", "is", "based", "o...
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/linear/NewGLMNET.java#L856-L899
train
EdwardRaff/JSAT
JSAT/src/jsat/math/OnLineStatistics.java
OnLineStatistics.add
public void add(double x, double weight) { //See http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance if(weight < 0) throw new ArithmeticException("Can not add a negative weight"); else if(weight == 0) return; double n1 = n; n+=weight; double delta = x - mean; double delta_n = delta*weight/n; double delta_n2 = delta_n*delta_n; double term1 = delta*delta_n*n1; mean += delta_n; m4 += term1 * delta_n2 * (n*n - 3*n + 3) + 6 * delta_n2 * m2 - 4 * delta_n * m3; m3 += term1 * delta_n * (n - 2) - 3 * delta_n * m2; m2 += weight*delta*(x-mean); if(min == null) min = max = x; else { min = Math.min(min, x); max = Math.max(max, x); } }
java
public void add(double x, double weight) { //See http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance if(weight < 0) throw new ArithmeticException("Can not add a negative weight"); else if(weight == 0) return; double n1 = n; n+=weight; double delta = x - mean; double delta_n = delta*weight/n; double delta_n2 = delta_n*delta_n; double term1 = delta*delta_n*n1; mean += delta_n; m4 += term1 * delta_n2 * (n*n - 3*n + 3) + 6 * delta_n2 * m2 - 4 * delta_n * m3; m3 += term1 * delta_n * (n - 2) - 3 * delta_n * m2; m2 += weight*delta*(x-mean); if(min == null) min = max = x; else { min = Math.min(min, x); max = Math.max(max, x); } }
[ "public", "void", "add", "(", "double", "x", ",", "double", "weight", ")", "{", "//See http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance", "if", "(", "weight", "<", "0", ")", "throw", "new", "ArithmeticException", "(", "\"Can not add a negative weight\"", ...
Adds a data sample the the counts with the provided weight of influence. @param x the data value to add @param weight the weight to give the value @throws ArithmeticException if a negative weight is given
[ "Adds", "a", "data", "sample", "the", "the", "counts", "with", "the", "provided", "weight", "of", "influence", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/math/OnLineStatistics.java#L107-L136
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/svm/SBP.java
SBP.setBurnIn
public void setBurnIn(double burnIn) { if(Double.isNaN(burnIn) || burnIn < 0 || burnIn >= 1) throw new IllegalArgumentException("BurnInFraction must be in [0, 1), not " + burnIn); this.burnIn = burnIn; }
java
public void setBurnIn(double burnIn) { if(Double.isNaN(burnIn) || burnIn < 0 || burnIn >= 1) throw new IllegalArgumentException("BurnInFraction must be in [0, 1), not " + burnIn); this.burnIn = burnIn; }
[ "public", "void", "setBurnIn", "(", "double", "burnIn", ")", "{", "if", "(", "Double", ".", "isNaN", "(", "burnIn", ")", "||", "burnIn", "<", "0", "||", "burnIn", ">=", "1", ")", "throw", "new", "IllegalArgumentException", "(", "\"BurnInFraction must be in [...
Sets the burn in fraction. SBP averages the intermediate solutions from each step as the final solution. The intermediate steps of SBP are highly correlated, and the begging solutions are usually not as meaningful toward the converged solution. To overcome this issue a certain fraction of the iterations are not averaged into the final solution, making them the "burn in" fraction. A value of 0.25 would then be ignoring the initial 25% of solutions. @param burnIn the ratio int [0, 1) initial solutions to ignore
[ "Sets", "the", "burn", "in", "fraction", ".", "SBP", "averages", "the", "intermediate", "solutions", "from", "each", "step", "as", "the", "final", "solution", ".", "The", "intermediate", "steps", "of", "SBP", "are", "highly", "correlated", "and", "the", "beg...
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/svm/SBP.java#L132-L137
train
EdwardRaff/JSAT
JSAT/src/jsat/utils/IntSetFixedSize.java
IntSetFixedSize.add
public boolean add(int e) { if(e < 0 || e >= has.length) throw new IllegalArgumentException("Input must be in range [0, " + has.length + ") not " + e); else if(contains(e) ) return false; else { if (nnz == 0) { first = e; next[e] = prev[e] = STOP; } else { prev[first] = e; next[e] = first; prev[e] = STOP; first = e; } nnz++; return has[e] = true; } }
java
public boolean add(int e) { if(e < 0 || e >= has.length) throw new IllegalArgumentException("Input must be in range [0, " + has.length + ") not " + e); else if(contains(e) ) return false; else { if (nnz == 0) { first = e; next[e] = prev[e] = STOP; } else { prev[first] = e; next[e] = first; prev[e] = STOP; first = e; } nnz++; return has[e] = true; } }
[ "public", "boolean", "add", "(", "int", "e", ")", "{", "if", "(", "e", "<", "0", "||", "e", ">=", "has", ".", "length", ")", "throw", "new", "IllegalArgumentException", "(", "\"Input must be in range [0, \"", "+", "has", ".", "length", "+", "\") not \"", ...
Adds a new integer into the set @param e the value to add into the set @return {@code true} if the operation modified the set, {@code false} otherwise.
[ "Adds", "a", "new", "integer", "into", "the", "set" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/utils/IntSetFixedSize.java#L51-L74
train
EdwardRaff/JSAT
JSAT/src/jsat/utils/IntList.java
IntList.unmodifiableView
public static List<Integer> unmodifiableView(int[] array, int length) { return Collections.unmodifiableList(view(array, length)); }
java
public static List<Integer> unmodifiableView(int[] array, int length) { return Collections.unmodifiableList(view(array, length)); }
[ "public", "static", "List", "<", "Integer", ">", "unmodifiableView", "(", "int", "[", "]", "array", ",", "int", "length", ")", "{", "return", "Collections", ".", "unmodifiableList", "(", "view", "(", "array", ",", "length", ")", ")", ";", "}" ]
Creates and returns an unmodifiable view of the given int array that requires only a small object allocation. @param array the array to wrap into an unmodifiable list @param length the number of values of the array to use, starting from zero @return an unmodifiable list view of the array
[ "Creates", "and", "returns", "an", "unmodifiable", "view", "of", "the", "given", "int", "array", "that", "requires", "only", "a", "small", "object", "allocation", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/utils/IntList.java#L203-L206
train
EdwardRaff/JSAT
JSAT/src/jsat/utils/IntList.java
IntList.view
public static IntList view(int[] array, int length) { if(length > array.length || length < 0) throw new IllegalArgumentException("length must be non-negative and no more than the size of the array("+array.length+"), not " + length); return new IntList(array, length); }
java
public static IntList view(int[] array, int length) { if(length > array.length || length < 0) throw new IllegalArgumentException("length must be non-negative and no more than the size of the array("+array.length+"), not " + length); return new IntList(array, length); }
[ "public", "static", "IntList", "view", "(", "int", "[", "]", "array", ",", "int", "length", ")", "{", "if", "(", "length", ">", "array", ".", "length", "||", "length", "<", "0", ")", "throw", "new", "IllegalArgumentException", "(", "\"length must be non-ne...
Creates and returns a view of the given int array that requires only a small object allocation. Changes to the list will be reflected in the array up to a point. If the modification would require increasing the capacity of the array, a new array will be allocated - at which point operations will no longer be reflected in the original array. @param array the array to wrap by an IntList object @param length the initial length of the list @return an IntList backed by the given array, unless modified to the point of requiring the allocation of a new array
[ "Creates", "and", "returns", "a", "view", "of", "the", "given", "int", "array", "that", "requires", "only", "a", "small", "object", "allocation", ".", "Changes", "to", "the", "list", "will", "be", "reflected", "in", "the", "array", "up", "to", "a", "poin...
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/utils/IntList.java#L220-L225
train
EdwardRaff/JSAT
JSAT/src/jsat/utils/IntList.java
IntList.range
public static IntList range(int start, int end, int step) { IntList l = new IntList((end-start)/step +1); for(int i = start; i < end; i++) l.add(i); return l; }
java
public static IntList range(int start, int end, int step) { IntList l = new IntList((end-start)/step +1); for(int i = start; i < end; i++) l.add(i); return l; }
[ "public", "static", "IntList", "range", "(", "int", "start", ",", "int", "end", ",", "int", "step", ")", "{", "IntList", "l", "=", "new", "IntList", "(", "(", "end", "-", "start", ")", "/", "step", "+", "1", ")", ";", "for", "(", "int", "i", "=...
Returns a new IntList containing values in the given range @param start the starting value (inclusive) @param end the ending value (exclusive) @param step the step size @return a new IntList populated by integer values as if having run through a for loop
[ "Returns", "a", "new", "IntList", "containing", "values", "in", "the", "given", "range" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/utils/IntList.java#L260-L266
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/bayesian/ConditionalProbabilityTable.java
ConditionalProbabilityTable.dataPointToCord
public int dataPointToCord(DataPointPair<Integer> dataPoint, int targetClass, int[] cord) { if(cord.length != getDimensionSize()) throw new ArithmeticException("Storage space and CPT dimension miss match"); DataPoint dp = dataPoint.getDataPoint(); int skipVal = -1; //Set up cord for(int i = 0; i < dimSize.length; i++) { if(realIndexToCatIndex[i] == targetClass) { if(targetClass == dp.numCategoricalValues()) skipVal = dataPoint.getPair(); else skipVal = dp.getCategoricalValue(realIndexToCatIndex[i]); } if(realIndexToCatIndex[i] == predictingIndex) cord[i] = dataPoint.getPair(); else cord[i] = dp.getCategoricalValue(realIndexToCatIndex[i]); } return skipVal; }
java
public int dataPointToCord(DataPointPair<Integer> dataPoint, int targetClass, int[] cord) { if(cord.length != getDimensionSize()) throw new ArithmeticException("Storage space and CPT dimension miss match"); DataPoint dp = dataPoint.getDataPoint(); int skipVal = -1; //Set up cord for(int i = 0; i < dimSize.length; i++) { if(realIndexToCatIndex[i] == targetClass) { if(targetClass == dp.numCategoricalValues()) skipVal = dataPoint.getPair(); else skipVal = dp.getCategoricalValue(realIndexToCatIndex[i]); } if(realIndexToCatIndex[i] == predictingIndex) cord[i] = dataPoint.getPair(); else cord[i] = dp.getCategoricalValue(realIndexToCatIndex[i]); } return skipVal; }
[ "public", "int", "dataPointToCord", "(", "DataPointPair", "<", "Integer", ">", "dataPoint", ",", "int", "targetClass", ",", "int", "[", "]", "cord", ")", "{", "if", "(", "cord", ".", "length", "!=", "getDimensionSize", "(", ")", ")", "throw", "new", "Ari...
Converts a data point pair into a coordinate. The paired value contains the value for the predicting index. Though this value will not be used if the predicting class of the original data set was not used to make the table. @param dataPoint the DataPointPair to convert @param targetClass the index in the original data set of the category that we would like to predict @param cord the array to store the coordinate in. @return the value of the target class for the given data point @throws ArithmeticException if the <tt>cord</tt> array does not match the {@link #getDimensionSize() dimension} of the CPT
[ "Converts", "a", "data", "point", "pair", "into", "a", "coordinate", ".", "The", "paired", "value", "contains", "the", "value", "for", "the", "predicting", "index", ".", "Though", "this", "value", "will", "not", "be", "used", "if", "the", "predicting", "cl...
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/bayesian/ConditionalProbabilityTable.java#L102-L124
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/bayesian/ConditionalProbabilityTable.java
ConditionalProbabilityTable.query
public double query(int targetClass, int targetValue, int[] cord) { double sumVal = 0; double targetVal = 0; int realTargetIndex = catIndexToRealIndex[targetClass]; CategoricalData queryData = valid.get(targetClass); //Now do all other target class posibilty querys for (int i = 0; i < queryData.getNumOfCategories(); i++) { cord[realTargetIndex] = i; double tmp = countArray[cordToIndex(cord)]; sumVal += tmp; if (i == targetValue) targetVal = tmp; } return targetVal/sumVal; }
java
public double query(int targetClass, int targetValue, int[] cord) { double sumVal = 0; double targetVal = 0; int realTargetIndex = catIndexToRealIndex[targetClass]; CategoricalData queryData = valid.get(targetClass); //Now do all other target class posibilty querys for (int i = 0; i < queryData.getNumOfCategories(); i++) { cord[realTargetIndex] = i; double tmp = countArray[cordToIndex(cord)]; sumVal += tmp; if (i == targetValue) targetVal = tmp; } return targetVal/sumVal; }
[ "public", "double", "query", "(", "int", "targetClass", ",", "int", "targetValue", ",", "int", "[", "]", "cord", ")", "{", "double", "sumVal", "=", "0", ";", "double", "targetVal", "=", "0", ";", "int", "realTargetIndex", "=", "catIndexToRealIndex", "[", ...
Queries the CPT for the probability of the target class occurring with the specified value given the class values of the other attributes @param targetClass the index in the original data set of the class that we want to probability of @param targetValue the value of the <tt>targetClass</tt> that we want to probability of occurring @param cord the coordinate array that corresponds the the class values for the CPT, where the coordinate of the <tt>targetClass</tt> may contain any value. @return the probability in [0, 1] of the <tt>targetClass</tt> occurring with the <tt>targetValue</tt> given the information in <tt>cord</tt> @see #dataPointToCord(jsat.classifiers.DataPointPair, int, int[])
[ "Queries", "the", "CPT", "for", "the", "probability", "of", "the", "target", "class", "occurring", "with", "the", "specified", "value", "given", "the", "class", "values", "of", "the", "other", "attributes" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/bayesian/ConditionalProbabilityTable.java#L225-L248
train
EdwardRaff/JSAT
JSAT/src/jsat/parameters/Parameter.java
Parameter.toParameterMap
public static Map<String, Parameter> toParameterMap(List<Parameter> params) { Map<String, Parameter> map = new HashMap<String, Parameter>(params.size()); for(Parameter param : params) { if(map.put(param.getASCIIName(), param) != null) throw new RuntimeException("Name collision, two parameters use the name '" + param.getASCIIName() + "'"); if(!param.getName().equals(param.getASCIIName()))//Dont put it in again if(map.put(param.getName(), param) != null) throw new RuntimeException("Name collision, two parameters use the name '" + param.getName() + "'"); } return map; }
java
public static Map<String, Parameter> toParameterMap(List<Parameter> params) { Map<String, Parameter> map = new HashMap<String, Parameter>(params.size()); for(Parameter param : params) { if(map.put(param.getASCIIName(), param) != null) throw new RuntimeException("Name collision, two parameters use the name '" + param.getASCIIName() + "'"); if(!param.getName().equals(param.getASCIIName()))//Dont put it in again if(map.put(param.getName(), param) != null) throw new RuntimeException("Name collision, two parameters use the name '" + param.getName() + "'"); } return map; }
[ "public", "static", "Map", "<", "String", ",", "Parameter", ">", "toParameterMap", "(", "List", "<", "Parameter", ">", "params", ")", "{", "Map", "<", "String", ",", "Parameter", ">", "map", "=", "new", "HashMap", "<", "String", ",", "Parameter", ">", ...
Creates a map of all possible parameter names to their corresponding object. No two parameters may have the same name. @param params the list of parameters to create a map for @return a map of string names to their parameters @throws RuntimeException if two parameters have the same name
[ "Creates", "a", "map", "of", "all", "possible", "parameter", "names", "to", "their", "corresponding", "object", ".", "No", "two", "parameters", "may", "have", "the", "same", "name", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/parameters/Parameter.java#L172-L184
train
EdwardRaff/JSAT
JSAT/src/jsat/parameters/Parameter.java
Parameter.spaceCamelCase
private static String spaceCamelCase(String in) { StringBuilder sb = new StringBuilder(in.length()+5); for(int i = 0; i < in.length(); i++) { char c = in.charAt(i); if(Character.isUpperCase(c)) sb.append(' '); sb.append(c); } return sb.toString().trim(); }
java
private static String spaceCamelCase(String in) { StringBuilder sb = new StringBuilder(in.length()+5); for(int i = 0; i < in.length(); i++) { char c = in.charAt(i); if(Character.isUpperCase(c)) sb.append(' '); sb.append(c); } return sb.toString().trim(); }
[ "private", "static", "String", "spaceCamelCase", "(", "String", "in", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "in", ".", "length", "(", ")", "+", "5", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "in", ".", ...
Returns a version of the same string that has spaced inserted before each capital letter @param in the CamelCase string @return the spaced Camel Case string
[ "Returns", "a", "version", "of", "the", "same", "string", "that", "has", "spaced", "inserted", "before", "each", "capital", "letter" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/parameters/Parameter.java#L777-L788
train
EdwardRaff/JSAT
JSAT/src/jsat/datatransform/NumericalToHistogram.java
NumericalToHistogram.guessNumberOfBins
public static Distribution guessNumberOfBins(DataSet data) { if(data.size() < 20) return new UniformDiscrete(2, data.size()-1); else if(data.size() >= 1000000) return new LogUniform(50, 1000); int sqrt = (int) Math.sqrt(data.size()); return new UniformDiscrete(Math.max(sqrt/3, 2), Math.min(sqrt*3, data.size()-1)); }
java
public static Distribution guessNumberOfBins(DataSet data) { if(data.size() < 20) return new UniformDiscrete(2, data.size()-1); else if(data.size() >= 1000000) return new LogUniform(50, 1000); int sqrt = (int) Math.sqrt(data.size()); return new UniformDiscrete(Math.max(sqrt/3, 2), Math.min(sqrt*3, data.size()-1)); }
[ "public", "static", "Distribution", "guessNumberOfBins", "(", "DataSet", "data", ")", "{", "if", "(", "data", ".", "size", "(", ")", "<", "20", ")", "return", "new", "UniformDiscrete", "(", "2", ",", "data", ".", "size", "(", ")", "-", "1", ")", ";",...
Attempts to guess the number of bins to use @param data the dataset to be transforms @return a distribution of the guess
[ "Attempts", "to", "guess", "the", "number", "of", "bins", "to", "use" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/datatransform/NumericalToHistogram.java#L138-L146
train
EdwardRaff/JSAT
JSAT/src/jsat/datatransform/WhitenedPCA.java
WhitenedPCA.getSVD
private SingularValueDecomposition getSVD(DataSet dataSet) { Matrix cov = covarianceMatrix(meanVector(dataSet), dataSet); for(int i = 0; i < cov.rows(); i++)//force it to be symmetric for(int j = 0; j < i; j++) cov.set(j, i, cov.get(i, j)); EigenValueDecomposition evd = new EigenValueDecomposition(cov); //Sort form largest to smallest evd.sortByEigenValue(new Comparator<Double>() { @Override public int compare(Double o1, Double o2) { return -Double.compare(o1, o2); } }); return new SingularValueDecomposition(evd.getVRaw(), evd.getVRaw(), evd.getRealEigenvalues()); }
java
private SingularValueDecomposition getSVD(DataSet dataSet) { Matrix cov = covarianceMatrix(meanVector(dataSet), dataSet); for(int i = 0; i < cov.rows(); i++)//force it to be symmetric for(int j = 0; j < i; j++) cov.set(j, i, cov.get(i, j)); EigenValueDecomposition evd = new EigenValueDecomposition(cov); //Sort form largest to smallest evd.sortByEigenValue(new Comparator<Double>() { @Override public int compare(Double o1, Double o2) { return -Double.compare(o1, o2); } }); return new SingularValueDecomposition(evd.getVRaw(), evd.getVRaw(), evd.getRealEigenvalues()); }
[ "private", "SingularValueDecomposition", "getSVD", "(", "DataSet", "dataSet", ")", "{", "Matrix", "cov", "=", "covarianceMatrix", "(", "meanVector", "(", "dataSet", ")", ",", "dataSet", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "cov", "....
Gets a SVD for the covariance matrix of the data set @param dataSet the data set in question @return the SVD for the covariance
[ "Gets", "a", "SVD", "for", "the", "covariance", "matrix", "of", "the", "data", "set" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/datatransform/WhitenedPCA.java#L159-L176
train
EdwardRaff/JSAT
JSAT/src/jsat/math/ContinuedFraction.java
ContinuedFraction.backwardNaive
public double backwardNaive(int n, double... args) { double term = getA(n, args)/getB(n,args); for(n = n-1; n >0; n--) { term = getA(n, args)/(getB(n,args)+term); } return term + getB(0, args); }
java
public double backwardNaive(int n, double... args) { double term = getA(n, args)/getB(n,args); for(n = n-1; n >0; n--) { term = getA(n, args)/(getB(n,args)+term); } return term + getB(0, args); }
[ "public", "double", "backwardNaive", "(", "int", "n", ",", "double", "...", "args", ")", "{", "double", "term", "=", "getA", "(", "n", ",", "args", ")", "/", "getB", "(", "n", ",", "args", ")", ";", "for", "(", "n", "=", "n", "-", "1", ";", "...
Approximates the continued fraction using a naive approximation @param n the number of iterations to perform @param args the values to input for the variables of the continued fraction @return an approximation of the value of the continued fraciton
[ "Approximates", "the", "continued", "fraction", "using", "a", "naive", "approximation" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/math/ContinuedFraction.java#L41-L51
train
EdwardRaff/JSAT
JSAT/src/jsat/math/ContinuedFraction.java
ContinuedFraction.lentz
public double lentz(double... args) { double f_n = getB(0, args); if(f_n == 0.0) f_n = 1e-30; double c_n, c_0 = f_n; double d_n, d_0 = 0; double delta = 0; int j = 0; while(Math.abs(delta - 1) > 1e-15) { j++; d_n = getB(j, args) + getA(j, args)*d_0; if(d_n == 0.0) d_n = 1e-30; c_n = getB(j, args) + getA(j, args)/c_0; if(c_n == 0.0) c_n = 1e-30; d_n = 1/d_n; delta = c_n*d_n; f_n *= delta; d_0 = d_n; c_0 = c_n; } return f_n; }
java
public double lentz(double... args) { double f_n = getB(0, args); if(f_n == 0.0) f_n = 1e-30; double c_n, c_0 = f_n; double d_n, d_0 = 0; double delta = 0; int j = 0; while(Math.abs(delta - 1) > 1e-15) { j++; d_n = getB(j, args) + getA(j, args)*d_0; if(d_n == 0.0) d_n = 1e-30; c_n = getB(j, args) + getA(j, args)/c_0; if(c_n == 0.0) c_n = 1e-30; d_n = 1/d_n; delta = c_n*d_n; f_n *= delta; d_0 = d_n; c_0 = c_n; } return f_n; }
[ "public", "double", "lentz", "(", "double", "...", "args", ")", "{", "double", "f_n", "=", "getB", "(", "0", ",", "args", ")", ";", "if", "(", "f_n", "==", "0.0", ")", "f_n", "=", "1e-30", ";", "double", "c_n", ",", "c_0", "=", "f_n", ";", "dou...
Uses Thompson and Barnett's modified Lentz's algorithm create an approximation that should be accurate to full precision. @param args the numeric inputs to the continued fraction @return the approximate value of the continued fraction
[ "Uses", "Thompson", "and", "Barnett", "s", "modified", "Lentz", "s", "algorithm", "create", "an", "approximation", "that", "should", "be", "accurate", "to", "full", "precision", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/math/ContinuedFraction.java#L60-L94
train
EdwardRaff/JSAT
JSAT/src/jsat/clustering/ClustererBase.java
ClustererBase.createClusterListFromAssignmentArray
public static List<List<DataPoint>> createClusterListFromAssignmentArray(int[] assignments, DataSet dataSet) { List<List<DataPoint>> clusterings = new ArrayList<>(); for(int i = 0; i < dataSet.size(); i++) { while(clusterings.size() <= assignments[i]) clusterings.add(new ArrayList<>()); if(assignments[i] >= 0) clusterings.get(assignments[i]).add(dataSet.getDataPoint(i)); } return clusterings; }
java
public static List<List<DataPoint>> createClusterListFromAssignmentArray(int[] assignments, DataSet dataSet) { List<List<DataPoint>> clusterings = new ArrayList<>(); for(int i = 0; i < dataSet.size(); i++) { while(clusterings.size() <= assignments[i]) clusterings.add(new ArrayList<>()); if(assignments[i] >= 0) clusterings.get(assignments[i]).add(dataSet.getDataPoint(i)); } return clusterings; }
[ "public", "static", "List", "<", "List", "<", "DataPoint", ">", ">", "createClusterListFromAssignmentArray", "(", "int", "[", "]", "assignments", ",", "DataSet", "dataSet", ")", "{", "List", "<", "List", "<", "DataPoint", ">>", "clusterings", "=", "new", "Ar...
Convenient helper method. A list of lists to represent a cluster may be desirable. In such a case, this method will take in an array of cluster assignments, and return a list of lists. @param assignments the array containing cluster assignments @param dataSet the original data set, with data in the same order as was used to create the assignments array @return a List of lists where each list contains the data points for one cluster, and the lists are in order by cluster id.
[ "Convenient", "helper", "method", ".", "A", "list", "of", "lists", "to", "represent", "a", "cluster", "may", "be", "desirable", ".", "In", "such", "a", "case", "this", "method", "will", "take", "in", "an", "array", "of", "cluster", "assignments", "and", ...
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/clustering/ClustererBase.java#L35-L48
train
EdwardRaff/JSAT
JSAT/src/jsat/clustering/ClustererBase.java
ClustererBase.getDatapointsFromCluster
public static List<DataPoint> getDatapointsFromCluster(int c, int[] assignments, DataSet dataSet, int[] indexFrom) { List<DataPoint> list = new ArrayList<>(); int pos = 0; for(int i = 0; i < dataSet.size(); i++) if(assignments[i] == c) { list.add(dataSet.getDataPoint(i)); if(indexFrom != null) indexFrom[pos++] = i; } return list; }
java
public static List<DataPoint> getDatapointsFromCluster(int c, int[] assignments, DataSet dataSet, int[] indexFrom) { List<DataPoint> list = new ArrayList<>(); int pos = 0; for(int i = 0; i < dataSet.size(); i++) if(assignments[i] == c) { list.add(dataSet.getDataPoint(i)); if(indexFrom != null) indexFrom[pos++] = i; } return list; }
[ "public", "static", "List", "<", "DataPoint", ">", "getDatapointsFromCluster", "(", "int", "c", ",", "int", "[", "]", "assignments", ",", "DataSet", "dataSet", ",", "int", "[", "]", "indexFrom", ")", "{", "List", "<", "DataPoint", ">", "list", "=", "new"...
Gets a list of the datapoints in a data set that belong to the indicated cluster @param c the cluster ID to get the datapoints for @param assignments the array containing cluster assignments @param dataSet the data set to get the points from @param indexFrom stores the index from the original dataset that the datapoint is from, such that the item at index {@code i} in the returned list can be found in the original dataset at index {@code indexFrom[i]}. May be {@code null} @return a list of datapoints that were assignment to the designated cluster
[ "Gets", "a", "list", "of", "the", "datapoints", "in", "a", "data", "set", "that", "belong", "to", "the", "indicated", "cluster" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/clustering/ClustererBase.java#L61-L73
train
EdwardRaff/JSAT
JSAT/src/jsat/math/Complex.java
Complex.add
public Complex add(Complex c) { Complex ret = new Complex(real, imag); ret.mutableAdd(c); return ret; }
java
public Complex add(Complex c) { Complex ret = new Complex(real, imag); ret.mutableAdd(c); return ret; }
[ "public", "Complex", "add", "(", "Complex", "c", ")", "{", "Complex", "ret", "=", "new", "Complex", "(", "real", ",", "imag", ")", ";", "ret", ".", "mutableAdd", "(", "c", ")", ";", "return", "ret", ";", "}" ]
Creates a new complex number containing the resulting addition of this and another @param c the number to add @return <tt>this</tt>+c
[ "Creates", "a", "new", "complex", "number", "containing", "the", "resulting", "addition", "of", "this", "and", "another" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/math/Complex.java#L98-L103
train
EdwardRaff/JSAT
JSAT/src/jsat/math/Complex.java
Complex.subtract
public Complex subtract(Complex c) { Complex ret = new Complex(real, imag); ret.mutableSubtract(c); return ret; }
java
public Complex subtract(Complex c) { Complex ret = new Complex(real, imag); ret.mutableSubtract(c); return ret; }
[ "public", "Complex", "subtract", "(", "Complex", "c", ")", "{", "Complex", "ret", "=", "new", "Complex", "(", "real", ",", "imag", ")", ";", "ret", ".", "mutableSubtract", "(", "c", ")", ";", "return", "ret", ";", "}" ]
Creates a new complex number containing the resulting subtracting another from this one @param c the number to subtract @return <tt>this</tt>-c
[ "Creates", "a", "new", "complex", "number", "containing", "the", "resulting", "subtracting", "another", "from", "this", "one" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/math/Complex.java#L129-L134
train
EdwardRaff/JSAT
JSAT/src/jsat/math/Complex.java
Complex.cMul
public static void cMul(double a, double b, double c, double d, double[] results) { results[0] = a*c-b*d; results[1] = b*c+a*d; }
java
public static void cMul(double a, double b, double c, double d, double[] results) { results[0] = a*c-b*d; results[1] = b*c+a*d; }
[ "public", "static", "void", "cMul", "(", "double", "a", ",", "double", "b", ",", "double", "c", ",", "double", "d", ",", "double", "[", "]", "results", ")", "{", "results", "[", "0", "]", "=", "a", "*", "c", "-", "b", "*", "d", ";", "results", ...
Performs a complex multiplication @param a the real part of the first number @param b the imaginary part of the first number @param c the real part of the second number @param d the imaginary part of the second number @param results an array to store the real and imaginary results in. First index is the real, 2nd is the imaginary.
[ "Performs", "a", "complex", "multiplication" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/math/Complex.java#L145-L149
train
EdwardRaff/JSAT
JSAT/src/jsat/math/Complex.java
Complex.mutableMultiply
public void mutableMultiply(double c, double d) { double newR = this.real*c-this.imag*d; double newI = this.imag*c+this.real*d; this.real = newR; this.imag = newI; }
java
public void mutableMultiply(double c, double d) { double newR = this.real*c-this.imag*d; double newI = this.imag*c+this.real*d; this.real = newR; this.imag = newI; }
[ "public", "void", "mutableMultiply", "(", "double", "c", ",", "double", "d", ")", "{", "double", "newR", "=", "this", ".", "real", "*", "c", "-", "this", ".", "imag", "*", "d", ";", "double", "newI", "=", "this", ".", "imag", "*", "c", "+", "this...
Alters this complex number as if a multiplication of another complex number was performed. @param c the real part of the other number @param d the imaginary part of the other number
[ "Alters", "this", "complex", "number", "as", "if", "a", "multiplication", "of", "another", "complex", "number", "was", "performed", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/math/Complex.java#L156-L162
train
EdwardRaff/JSAT
JSAT/src/jsat/math/Complex.java
Complex.multiply
public Complex multiply(Complex c) { Complex ret = new Complex(real, imag); ret.mutableMultiply(c); return ret; }
java
public Complex multiply(Complex c) { Complex ret = new Complex(real, imag); ret.mutableMultiply(c); return ret; }
[ "public", "Complex", "multiply", "(", "Complex", "c", ")", "{", "Complex", "ret", "=", "new", "Complex", "(", "real", ",", "imag", ")", ";", "ret", ".", "mutableMultiply", "(", "c", ")", ";", "return", "ret", ";", "}" ]
Creates a new complex number containing the resulting multiplication between this and another @param c the number to multiply by @return <tt>this</tt>*c
[ "Creates", "a", "new", "complex", "number", "containing", "the", "resulting", "multiplication", "between", "this", "and", "another" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/math/Complex.java#L178-L183
train
EdwardRaff/JSAT
JSAT/src/jsat/math/Complex.java
Complex.mutableDivide
public void mutableDivide(double c, double d) { final double[] r = new double[2]; cDiv(real, imag, c, d, r); this.real = r[0]; this.imag = r[1]; }
java
public void mutableDivide(double c, double d) { final double[] r = new double[2]; cDiv(real, imag, c, d, r); this.real = r[0]; this.imag = r[1]; }
[ "public", "void", "mutableDivide", "(", "double", "c", ",", "double", "d", ")", "{", "final", "double", "[", "]", "r", "=", "new", "double", "[", "2", "]", ";", "cDiv", "(", "real", ",", "imag", ",", "c", ",", "d", ",", "r", ")", ";", "this", ...
Alters this complex number as if a division by another complex number was performed. @param c the real part of the other number @param d the imaginary part of the other number
[ "Alters", "this", "complex", "number", "as", "if", "a", "division", "by", "another", "complex", "number", "was", "performed", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/math/Complex.java#L249-L255
train
EdwardRaff/JSAT
JSAT/src/jsat/math/Complex.java
Complex.divide
public Complex divide(Complex c) { Complex ret = new Complex(real, imag); ret.mutableDivide(c); return ret; }
java
public Complex divide(Complex c) { Complex ret = new Complex(real, imag); ret.mutableDivide(c); return ret; }
[ "public", "Complex", "divide", "(", "Complex", "c", ")", "{", "Complex", "ret", "=", "new", "Complex", "(", "real", ",", "imag", ")", ";", "ret", ".", "mutableDivide", "(", "c", ")", ";", "return", "ret", ";", "}" ]
Creates a new complex number containing the resulting division of this by another @param c the number to divide by @return <tt>this</tt>/c
[ "Creates", "a", "new", "complex", "number", "containing", "the", "resulting", "division", "of", "this", "by", "another" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/math/Complex.java#L273-L278
train
EdwardRaff/JSAT
JSAT/src/jsat/driftdetectors/ADWIN.java
ADWIN.setDelta
public void setDelta(double delta) { if(delta <= 0 || delta >= 1 || Double.isNaN(delta)) throw new IllegalArgumentException("delta must be in (0,1), not " + delta); this.delta = delta; }
java
public void setDelta(double delta) { if(delta <= 0 || delta >= 1 || Double.isNaN(delta)) throw new IllegalArgumentException("delta must be in (0,1), not " + delta); this.delta = delta; }
[ "public", "void", "setDelta", "(", "double", "delta", ")", "{", "if", "(", "delta", "<=", "0", "||", "delta", ">=", "1", "||", "Double", ".", "isNaN", "(", "delta", ")", ")", "throw", "new", "IllegalArgumentException", "(", "\"delta must be in (0,1), not \""...
Sets the upper bound on the false positive rate for detecting concept drifts @param delta the upper bound on false positives in (0,1)
[ "Sets", "the", "upper", "bound", "on", "the", "false", "positive", "rate", "for", "detecting", "concept", "drifts" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/driftdetectors/ADWIN.java#L98-L103
train
EdwardRaff/JSAT
JSAT/src/jsat/driftdetectors/ADWIN.java
ADWIN.compress
private void compress() { //compress ListIterator<OnLineStatistics> listIter = windows.listIterator(); double lastSizeSeen = -Double.MAX_VALUE; int lastSizeCount = 0; while(listIter.hasNext()) { OnLineStatistics window = listIter.next(); double n = window.getSumOfWeights(); if(n == lastSizeSeen) { if(++lastSizeCount > M)//compress, can only occur if there is a previous { listIter.previous(); window.add(listIter.previous()); listIter.remove();//remove the preivous if(listIter.hasNext()) listIter.next();//back to where we were, which has been modified //so nowe we must be looking at a new range since we just promoted a window lastSizeSeen = window.getSumOfWeights(); lastSizeCount = 1; } } else { lastSizeSeen = n; lastSizeCount = 1; } } }
java
private void compress() { //compress ListIterator<OnLineStatistics> listIter = windows.listIterator(); double lastSizeSeen = -Double.MAX_VALUE; int lastSizeCount = 0; while(listIter.hasNext()) { OnLineStatistics window = listIter.next(); double n = window.getSumOfWeights(); if(n == lastSizeSeen) { if(++lastSizeCount > M)//compress, can only occur if there is a previous { listIter.previous(); window.add(listIter.previous()); listIter.remove();//remove the preivous if(listIter.hasNext()) listIter.next();//back to where we were, which has been modified //so nowe we must be looking at a new range since we just promoted a window lastSizeSeen = window.getSumOfWeights(); lastSizeCount = 1; } } else { lastSizeSeen = n; lastSizeCount = 1; } } }
[ "private", "void", "compress", "(", ")", "{", "//compress", "ListIterator", "<", "OnLineStatistics", ">", "listIter", "=", "windows", ".", "listIterator", "(", ")", ";", "double", "lastSizeSeen", "=", "-", "Double", ".", "MAX_VALUE", ";", "int", "lastSizeCount...
Compresses the current window
[ "Compresses", "the", "current", "window" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/driftdetectors/ADWIN.java#L200-L231
train
EdwardRaff/JSAT
JSAT/src/jsat/clustering/hierarchical/DivisiveLocalClusterer.java
DivisiveLocalClusterer.computeSubClusterSplit
private void computeSubClusterSplit(final int[][] subDesignation, int originalCluster, List<DataPoint> listOfDataPointsInCluster, DataSet fullDataSet, int[] fullDesignations, final int[][] originalPositions, final double[] splitEvaluation, PriorityQueue<Integer> clusterToSplit, boolean parallel) { subDesignation[originalCluster] = new int[listOfDataPointsInCluster.size()]; int pos = 0; for(int i = 0; i < fullDataSet.size(); i++) { if(fullDesignations[i] != originalCluster) continue; originalPositions[originalCluster][pos++] = i; } //Cluster the sub cluster SimpleDataSet dpSubC1DataSet = new SimpleDataSet(listOfDataPointsInCluster); try { baseClusterer.cluster(dpSubC1DataSet, 2, parallel, subDesignation[originalCluster]); splitEvaluation[originalCluster] = clusterEvaluation.evaluate(subDesignation[originalCluster], dpSubC1DataSet); clusterToSplit.add(originalCluster); } catch (ClusterFailureException ex) { splitEvaluation[originalCluster] = Double.POSITIVE_INFINITY; } }
java
private void computeSubClusterSplit(final int[][] subDesignation, int originalCluster, List<DataPoint> listOfDataPointsInCluster, DataSet fullDataSet, int[] fullDesignations, final int[][] originalPositions, final double[] splitEvaluation, PriorityQueue<Integer> clusterToSplit, boolean parallel) { subDesignation[originalCluster] = new int[listOfDataPointsInCluster.size()]; int pos = 0; for(int i = 0; i < fullDataSet.size(); i++) { if(fullDesignations[i] != originalCluster) continue; originalPositions[originalCluster][pos++] = i; } //Cluster the sub cluster SimpleDataSet dpSubC1DataSet = new SimpleDataSet(listOfDataPointsInCluster); try { baseClusterer.cluster(dpSubC1DataSet, 2, parallel, subDesignation[originalCluster]); splitEvaluation[originalCluster] = clusterEvaluation.evaluate(subDesignation[originalCluster], dpSubC1DataSet); clusterToSplit.add(originalCluster); } catch (ClusterFailureException ex) { splitEvaluation[originalCluster] = Double.POSITIVE_INFINITY; } }
[ "private", "void", "computeSubClusterSplit", "(", "final", "int", "[", "]", "[", "]", "subDesignation", ",", "int", "originalCluster", ",", "List", "<", "DataPoint", ">", "listOfDataPointsInCluster", ",", "DataSet", "fullDataSet", ",", "int", "[", "]", "fullDesi...
Takes the data set and computes the clustering of a sub cluster, and stores its information, and places the result in the queue @param subDesignation the array of arrays to store the designation array for the sub clustering @param originalCluster the originalCluster that we want to store the split information of @param listOfDataPointsInCluster the list of all data points that belong to <tt>originalCluster</tt> @param fullDataSet the full original data set @param fullDesignations the designation array for the full original data set @param originalPositions the array of arrays to store the map from and index in <tt>listOfDataPointsInCluster</tt> to its index in the full data set. @param splitEvaluation the array to store the cluster evaluation of the data set @param clusterToSplit the priority queue that stores the cluster id and sorts based on how good the sub splits were.
[ "Takes", "the", "data", "set", "and", "computes", "the", "clustering", "of", "a", "sub", "cluster", "and", "stores", "its", "information", "and", "places", "the", "result", "in", "the", "queue" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/clustering/hierarchical/DivisiveLocalClusterer.java#L168-L196
train
EdwardRaff/JSAT
JSAT/src/jsat/math/DescriptiveStatistics.java
DescriptiveStatistics.sampleCorCoeff
public static double sampleCorCoeff(Vec xData, Vec yData) { if(yData.length() != xData.length()) throw new ArithmeticException("X and Y data sets must have the same length"); double xMean = xData.mean(); double yMean = yData.mean(); double topSum = 0; for(int i = 0; i < xData.length(); i++) { topSum += (xData.get(i)-xMean)*(yData.get(i)-yMean); } return topSum/((xData.length()-1)*xData.standardDeviation()*yData.standardDeviation()); }
java
public static double sampleCorCoeff(Vec xData, Vec yData) { if(yData.length() != xData.length()) throw new ArithmeticException("X and Y data sets must have the same length"); double xMean = xData.mean(); double yMean = yData.mean(); double topSum = 0; for(int i = 0; i < xData.length(); i++) { topSum += (xData.get(i)-xMean)*(yData.get(i)-yMean); } return topSum/((xData.length()-1)*xData.standardDeviation()*yData.standardDeviation()); }
[ "public", "static", "double", "sampleCorCoeff", "(", "Vec", "xData", ",", "Vec", "yData", ")", "{", "if", "(", "yData", ".", "length", "(", ")", "!=", "xData", ".", "length", "(", ")", ")", "throw", "new", "ArithmeticException", "(", "\"X and Y data sets m...
Computes the sample correlation coefficient for two data sets X and Y. The lengths of X and Y must be the same, and each element in X should correspond to the element in Y. @param yData the Y data set @param xData the X data set @return the sample correlation coefficient
[ "Computes", "the", "sample", "correlation", "coefficient", "for", "two", "data", "sets", "X", "and", "Y", ".", "The", "lengths", "of", "X", "and", "Y", "must", "be", "the", "same", "and", "each", "element", "in", "X", "should", "correspond", "to", "the",...
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/math/DescriptiveStatistics.java#L20-L37
train
EdwardRaff/JSAT
JSAT/src/jsat/datatransform/LinearTransform.java
LinearTransform.setRange
public void setRange(double A, double B) { if(A == B) throw new RuntimeException("Values must be different"); else if(B > A) { double tmp = A; A = B; B = tmp; } this.A = A; this.B = B; }
java
public void setRange(double A, double B) { if(A == B) throw new RuntimeException("Values must be different"); else if(B > A) { double tmp = A; A = B; B = tmp; } this.A = A; this.B = B; }
[ "public", "void", "setRange", "(", "double", "A", ",", "double", "B", ")", "{", "if", "(", "A", "==", "B", ")", "throw", "new", "RuntimeException", "(", "\"Values must be different\"", ")", ";", "else", "if", "(", "B", ">", "A", ")", "{", "double", "...
Sets the min and max value to scale the data to. If given in the wrong order, this method will swap them @param A the maximum value for the transformed data set @param B the minimum value for the transformed data set
[ "Sets", "the", "min", "and", "max", "value", "to", "scale", "the", "data", "to", ".", "If", "given", "in", "the", "wrong", "order", "this", "method", "will", "swap", "them" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/datatransform/LinearTransform.java#L94-L106
train
EdwardRaff/JSAT
JSAT/src/jsat/distributions/multivariate/ProductKDE.java
ProductKDE.queryWork
private double queryWork(Vec x, Set<Integer> validIndecies, SparseVector logProd) { if(originalVecs == null) throw new UntrainedModelException("Model has not yet been created, queries can not be perfomed"); double logH = 0; for(int i = 0; i < sortedDimVals.length; i++) { double[] X = sortedDimVals[i]; double h = bandwidth[i]; logH += log(h); double xi = x.get(i); //Only values within a certain range will have an effect on the result, so we will skip to that range! int from = Arrays.binarySearch(X, xi-h*k.cutOff()); int to = Arrays.binarySearch(X, xi+h*k.cutOff()); //Mostly likely the exact value of x is not in the list, so it retursn the inseration points from = from < 0 ? -from-1 : from; to = to < 0 ? -to-1 : to; Set<Integer> subIndecies = new IntSet(); for(int j = max(0, from); j < min(X.length, to+1); j++) { int trueIndex = sortedIndexVals[i][j]; if(i == 0) { validIndecies.add(trueIndex); logProd.set(trueIndex, log(k.k( (xi-X[j])/h ))); } else if(validIndecies.contains(trueIndex)) { logProd.increment(trueIndex, log(k.k( (xi-X[j])/h ))); subIndecies.add(trueIndex); } } if (i > 0) { validIndecies.retainAll(subIndecies); if(validIndecies.isEmpty()) break; } } return logH; }
java
private double queryWork(Vec x, Set<Integer> validIndecies, SparseVector logProd) { if(originalVecs == null) throw new UntrainedModelException("Model has not yet been created, queries can not be perfomed"); double logH = 0; for(int i = 0; i < sortedDimVals.length; i++) { double[] X = sortedDimVals[i]; double h = bandwidth[i]; logH += log(h); double xi = x.get(i); //Only values within a certain range will have an effect on the result, so we will skip to that range! int from = Arrays.binarySearch(X, xi-h*k.cutOff()); int to = Arrays.binarySearch(X, xi+h*k.cutOff()); //Mostly likely the exact value of x is not in the list, so it retursn the inseration points from = from < 0 ? -from-1 : from; to = to < 0 ? -to-1 : to; Set<Integer> subIndecies = new IntSet(); for(int j = max(0, from); j < min(X.length, to+1); j++) { int trueIndex = sortedIndexVals[i][j]; if(i == 0) { validIndecies.add(trueIndex); logProd.set(trueIndex, log(k.k( (xi-X[j])/h ))); } else if(validIndecies.contains(trueIndex)) { logProd.increment(trueIndex, log(k.k( (xi-X[j])/h ))); subIndecies.add(trueIndex); } } if (i > 0) { validIndecies.retainAll(subIndecies); if(validIndecies.isEmpty()) break; } } return logH; }
[ "private", "double", "queryWork", "(", "Vec", "x", ",", "Set", "<", "Integer", ">", "validIndecies", ",", "SparseVector", "logProd", ")", "{", "if", "(", "originalVecs", "==", "null", ")", "throw", "new", "UntrainedModelException", "(", "\"Model has not yet been...
Performs the main work for performing a density query. @param x the query vector @param validIndecies the empty set that will be altered to contain the indices of vectors that had a non zero contribution to the density @param logProd an empty sparce vector that will be modified to contain the log of the product of the kernels for each data point. Some indices that have zero contribution to the density will have non zero values. <tt>validIndecies</tt> should be used to access the correct indices. @return The log product of the bandwidths that normalizes the values stored in the <tt>logProd</tt> vector.
[ "Performs", "the", "main", "work", "for", "performing", "a", "density", "query", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/distributions/multivariate/ProductKDE.java#L131-L174
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/trees/ExtraTree.java
ExtraTree.fillList
static private <T> void fillList(final int listsToAdd, Stack<List<T>> reusableLists, List<List<T>> aSplit) { for(int j = 0; j < listsToAdd; j++) if(reusableLists.isEmpty()) aSplit.add(new ArrayList<>()); else aSplit.add(reusableLists.pop()); }
java
static private <T> void fillList(final int listsToAdd, Stack<List<T>> reusableLists, List<List<T>> aSplit) { for(int j = 0; j < listsToAdd; j++) if(reusableLists.isEmpty()) aSplit.add(new ArrayList<>()); else aSplit.add(reusableLists.pop()); }
[ "static", "private", "<", "T", ">", "void", "fillList", "(", "final", "int", "listsToAdd", ",", "Stack", "<", "List", "<", "T", ">", ">", "reusableLists", ",", "List", "<", "List", "<", "T", ">", ">", "aSplit", ")", "{", "for", "(", "int", "j", "...
Add lists to a list of lists @param <T> the content type of the list @param listsToAdd the number of lists to add @param reusableLists available pre allocated lists for reuse @param aSplit the list of lists to add to
[ "Add", "lists", "to", "a", "list", "of", "lists" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/trees/ExtraTree.java#L554-L561
train
EdwardRaff/JSAT
JSAT/src/jsat/utils/IntSortedSet.java
IntSortedSet.batch_insert
private void batch_insert(Collection<Integer> set, boolean parallel) { for(int i : set) store[size++] = i; if(parallel) Arrays.parallelSort(store, 0, size); else Arrays.sort(store, 0, size); }
java
private void batch_insert(Collection<Integer> set, boolean parallel) { for(int i : set) store[size++] = i; if(parallel) Arrays.parallelSort(store, 0, size); else Arrays.sort(store, 0, size); }
[ "private", "void", "batch_insert", "(", "Collection", "<", "Integer", ">", "set", ",", "boolean", "parallel", ")", "{", "for", "(", "int", "i", ":", "set", ")", "store", "[", "size", "++", "]", "=", "i", ";", "if", "(", "parallel", ")", "Arrays", "...
more efficient insertion of many items by placing them all into the backing store, and then doing one large sort. @param set @param parallel
[ "more", "efficient", "insertion", "of", "many", "items", "by", "placing", "them", "all", "into", "the", "backing", "store", "and", "then", "doing", "one", "large", "sort", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/utils/IntSortedSet.java#L71-L79
train
EdwardRaff/JSAT
JSAT/src/jsat/distributions/LogUniform.java
LogUniform.setMinMax
public void setMinMax(double min, double max) { if(min <= 0 || Double.isNaN(min) || Double.isInfinite(min)) throw new IllegalArgumentException("min value must be positive, not " + min); else if(min >= max || Double.isNaN(max) || Double.isInfinite(max)) throw new IllegalArgumentException("max (" + max + ") must be larger than min (" + min+")" ); this.max = max; this.min = min; this.logMax = Math.log(max); this.logMin = Math.log(min); this.logDiff = logMax-logMin; this.diff = max-min; }
java
public void setMinMax(double min, double max) { if(min <= 0 || Double.isNaN(min) || Double.isInfinite(min)) throw new IllegalArgumentException("min value must be positive, not " + min); else if(min >= max || Double.isNaN(max) || Double.isInfinite(max)) throw new IllegalArgumentException("max (" + max + ") must be larger than min (" + min+")" ); this.max = max; this.min = min; this.logMax = Math.log(max); this.logMin = Math.log(min); this.logDiff = logMax-logMin; this.diff = max-min; }
[ "public", "void", "setMinMax", "(", "double", "min", ",", "double", "max", ")", "{", "if", "(", "min", "<=", "0", "||", "Double", ".", "isNaN", "(", "min", ")", "||", "Double", ".", "isInfinite", "(", "min", ")", ")", "throw", "new", "IllegalArgument...
Sets the minimum and maximum values for this distribution @param min the minimum value, must be positive @param max the maximum value, must be larger than {@code min}
[ "Sets", "the", "minimum", "and", "maximum", "values", "for", "this", "distribution" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/distributions/LogUniform.java#L59-L71
train
EdwardRaff/JSAT
JSAT/src/jsat/io/LIBSVMLoader.java
LIBSVMLoader.write
public static void write(ClassificationDataSet data, OutputStream os) { PrintWriter writer = new PrintWriter(os); for(int i = 0; i < data.size(); i++) { int pred = data.getDataPointCategory(i); Vec vals = data.getDataPoint(i).getNumericalValues(); writer.write(pred + " "); for(IndexValue iv : vals) { double val = iv.getValue(); if(Math.rint(val) == val)//cast to long before writting to save space writer.write((iv.getIndex()+1) + ":" + (long)val + " ");//+1 b/c 1 based indexing else writer.write((iv.getIndex()+1) + ":" + val + " ");//+1 b/c 1 based indexing } writer.write("\n"); } writer.flush(); writer.close(); }
java
public static void write(ClassificationDataSet data, OutputStream os) { PrintWriter writer = new PrintWriter(os); for(int i = 0; i < data.size(); i++) { int pred = data.getDataPointCategory(i); Vec vals = data.getDataPoint(i).getNumericalValues(); writer.write(pred + " "); for(IndexValue iv : vals) { double val = iv.getValue(); if(Math.rint(val) == val)//cast to long before writting to save space writer.write((iv.getIndex()+1) + ":" + (long)val + " ");//+1 b/c 1 based indexing else writer.write((iv.getIndex()+1) + ":" + val + " ");//+1 b/c 1 based indexing } writer.write("\n"); } writer.flush(); writer.close(); }
[ "public", "static", "void", "write", "(", "ClassificationDataSet", "data", ",", "OutputStream", "os", ")", "{", "PrintWriter", "writer", "=", "new", "PrintWriter", "(", "os", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "data", ".", "size...
Writes out the given classification data set as a LIBSVM data file @param data the data set to write to a file @param os the output stream to write to. The stream will not be closed or flushed by this method
[ "Writes", "out", "the", "given", "classification", "data", "set", "as", "a", "LIBSVM", "data", "file" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/io/LIBSVMLoader.java#L514-L534
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/svm/DCDs.java
DCDs.eq24
protected static double eq24(final double beta_i, final double gN, final double gP, final double U) { //6.2.2 double vi = 0;//Used as "other" value if(beta_i == 0)//if beta_i = 0 ... { //if beta_i = 0 and g'n(beta_i) >= 0 if(gN >= 0) vi = gN; else if(gP <= 0) //if beta_i = 0 and g'p(beta_i) <= 0 vi = -gP; } else//beta_i is non zero { //Two cases //if beta_i in (−U, 0), or //beta_i = −U and g'n(beta_i) <= 0 //then v_i = |g'n| //if beta_i in (0,U), or //beta_i = U and g'p(βi) >= 0 //then v_i = |g'p| if(beta_i < 0)//first set of cases { if(beta_i > -U || (beta_i == -U && gN <= 0)) vi = Math.abs(gN); } else//second case { if(beta_i < U || (beta_i == U && gP >= 0)) vi = Math.abs(gP); } } return vi; }
java
protected static double eq24(final double beta_i, final double gN, final double gP, final double U) { //6.2.2 double vi = 0;//Used as "other" value if(beta_i == 0)//if beta_i = 0 ... { //if beta_i = 0 and g'n(beta_i) >= 0 if(gN >= 0) vi = gN; else if(gP <= 0) //if beta_i = 0 and g'p(beta_i) <= 0 vi = -gP; } else//beta_i is non zero { //Two cases //if beta_i in (−U, 0), or //beta_i = −U and g'n(beta_i) <= 0 //then v_i = |g'n| //if beta_i in (0,U), or //beta_i = U and g'p(βi) >= 0 //then v_i = |g'p| if(beta_i < 0)//first set of cases { if(beta_i > -U || (beta_i == -U && gN <= 0)) vi = Math.abs(gN); } else//second case { if(beta_i < U || (beta_i == U && gP >= 0)) vi = Math.abs(gP); } } return vi; }
[ "protected", "static", "double", "eq24", "(", "final", "double", "beta_i", ",", "final", "double", "gN", ",", "final", "double", "gP", ",", "final", "double", "U", ")", "{", "//6.2.2\r", "double", "vi", "=", "0", ";", "//Used as \"other\" value\r", "if", "...
returns the result of evaluation equation 24 of an individual index @param beta_i the weight coefficent value @param gN the g'<sub>n</sub>(beta_i) value @param gP the g'<sub>p</sub>(beta_i) value @param U the upper bound value obtained from {@link #getU(double) } @return the result of equation 24
[ "returns", "the", "result", "of", "evaluation", "equation", "24", "of", "an", "individual", "index" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/svm/DCDs.java#L678-L715
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/trees/DecisionStump.java
DecisionStump.getSplittingAttribute
public int getSplittingAttribute() { //TODO refactor the splittingAttribute to just be in this order already if(splittingAttribute < catAttributes.length)//categorical feature return numNumericFeatures+splittingAttribute; //else, is Numerical attribute int numerAttribute = splittingAttribute - catAttributes.length; return numerAttribute; }
java
public int getSplittingAttribute() { //TODO refactor the splittingAttribute to just be in this order already if(splittingAttribute < catAttributes.length)//categorical feature return numNumericFeatures+splittingAttribute; //else, is Numerical attribute int numerAttribute = splittingAttribute - catAttributes.length; return numerAttribute; }
[ "public", "int", "getSplittingAttribute", "(", ")", "{", "//TODO refactor the splittingAttribute to just be in this order already", "if", "(", "splittingAttribute", "<", "catAttributes", ".", "length", ")", "//categorical feature", "return", "numNumericFeatures", "+", "splittin...
Returns the attribute that this stump has decided to use to compute results. Numeric features start from 0, and categorical features start from the number of numeric features. @return the attribute that this stump has decided to use to compute results.
[ "Returns", "the", "attribute", "that", "this", "stump", "has", "decided", "to", "use", "to", "compute", "results", ".", "Numeric", "features", "start", "from", "0", "and", "categorical", "features", "start", "from", "the", "number", "of", "numeric", "features"...
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/trees/DecisionStump.java#L176-L184
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/trees/DecisionStump.java
DecisionStump.getGain
protected double getGain(ImpurityScore origScore, ClassificationDataSet source, List<IntList> aSplit) { ImpurityScore[] scores = getSplitScores(source, aSplit); return ImpurityScore.gain(origScore, scores); }
java
protected double getGain(ImpurityScore origScore, ClassificationDataSet source, List<IntList> aSplit) { ImpurityScore[] scores = getSplitScores(source, aSplit); return ImpurityScore.gain(origScore, scores); }
[ "protected", "double", "getGain", "(", "ImpurityScore", "origScore", ",", "ClassificationDataSet", "source", ",", "List", "<", "IntList", ">", "aSplit", ")", "{", "ImpurityScore", "[", "]", "scores", "=", "getSplitScores", "(", "source", ",", "aSplit", ")", ";...
From the score for the original set that is being split, this computes the gain as the improvement in classification from the original split. @param origScore the score of the unsplit set @param source @param aSplit the splitting of the data points @return the gain score for this split
[ "From", "the", "score", "for", "the", "original", "set", "that", "is", "being", "split", "this", "computes", "the", "gain", "as", "the", "improvement", "in", "classification", "from", "the", "original", "split", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/trees/DecisionStump.java#L233-L239
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/trees/DecisionStump.java
DecisionStump.whichPath
public int whichPath(DataPoint data) { int paths = getNumberOfPaths(); if(paths < 0) return paths;//Not trained else if(paths == 1)//ONLY one option, entropy was zero return 0; else if(splittingAttribute < catAttributes.length)//Same for classification and regression return data.getCategoricalValue(splittingAttribute); //else, is Numerical attribute - but regression or classification? int numerAttribute = splittingAttribute - catAttributes.length; double val = data.getNumericalValues().get(numerAttribute); if(Double.isNaN(val)) return -1;//missing if (results != null)//Categorical! { int pos = Collections.binarySearch(boundries, val); pos = pos < 0 ? -pos-1 : pos; return owners.get(pos); } else//Regression! It is trained, it would have been grabed at the top if not { if(regressionResults.length == 1) return 0; else if(val <= regressionResults[2]) return 0; else return 1; } }
java
public int whichPath(DataPoint data) { int paths = getNumberOfPaths(); if(paths < 0) return paths;//Not trained else if(paths == 1)//ONLY one option, entropy was zero return 0; else if(splittingAttribute < catAttributes.length)//Same for classification and regression return data.getCategoricalValue(splittingAttribute); //else, is Numerical attribute - but regression or classification? int numerAttribute = splittingAttribute - catAttributes.length; double val = data.getNumericalValues().get(numerAttribute); if(Double.isNaN(val)) return -1;//missing if (results != null)//Categorical! { int pos = Collections.binarySearch(boundries, val); pos = pos < 0 ? -pos-1 : pos; return owners.get(pos); } else//Regression! It is trained, it would have been grabed at the top if not { if(regressionResults.length == 1) return 0; else if(val <= regressionResults[2]) return 0; else return 1; } }
[ "public", "int", "whichPath", "(", "DataPoint", "data", ")", "{", "int", "paths", "=", "getNumberOfPaths", "(", ")", ";", "if", "(", "paths", "<", "0", ")", "return", "paths", ";", "//Not trained", "else", "if", "(", "paths", "==", "1", ")", "//ONLY on...
Determines which split path this data point would follow from this decision stump. Works for both classification and regression. @param data the data point in question @return the integer indicating which path to take. -1 returned if stump is not trained
[ "Determines", "which", "split", "path", "this", "data", "point", "would", "follow", "from", "this", "decision", "stump", ".", "Works", "for", "both", "classification", "and", "regression", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/trees/DecisionStump.java#L265-L295
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/trees/DecisionStump.java
DecisionStump.result
public CategoricalResults result(int i) { if(i < 0 || i >= getNumberOfPaths()) throw new IndexOutOfBoundsException("Invalid path, can to return a result for path " + i); return results[i]; }
java
public CategoricalResults result(int i) { if(i < 0 || i >= getNumberOfPaths()) throw new IndexOutOfBoundsException("Invalid path, can to return a result for path " + i); return results[i]; }
[ "public", "CategoricalResults", "result", "(", "int", "i", ")", "{", "if", "(", "i", "<", "0", "||", "i", ">=", "getNumberOfPaths", "(", ")", ")", "throw", "new", "IndexOutOfBoundsException", "(", "\"Invalid path, can to return a result for path \"", "+", "i", "...
Returns the categorical result of the i'th path. @param i the path to get the result for @return the result that would be returned if a data point went down the given path @throws IndexOutOfBoundsException if an invalid path is given @throws NullPointerException if the stump has not been trained for classification
[ "Returns", "the", "categorical", "result", "of", "the", "i", "th", "path", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/trees/DecisionStump.java#L345-L350
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/trees/DecisionStump.java
DecisionStump.trainC
public List<ClassificationDataSet> trainC(ClassificationDataSet dataPoints, Set<Integer> options) { return trainC(dataPoints, options, false); }
java
public List<ClassificationDataSet> trainC(ClassificationDataSet dataPoints, Set<Integer> options) { return trainC(dataPoints, options, false); }
[ "public", "List", "<", "ClassificationDataSet", ">", "trainC", "(", "ClassificationDataSet", "dataPoints", ",", "Set", "<", "Integer", ">", "options", ")", "{", "return", "trainC", "(", "dataPoints", ",", "options", ",", "false", ")", ";", "}" ]
This is a helper function that does the work of training this stump. It may be called directly by other classes that are creating decision trees to avoid redundant repackaging of lists. @param dataPoints the lists of datapoint to train on, paired with the true category of each training point @param options the set of attributes that this classifier may choose from. The attribute it does choose will be removed from the set. @return the a list of lists, containing all the datapoints that would have followed each path. Useful for training a decision tree
[ "This", "is", "a", "helper", "function", "that", "does", "the", "work", "of", "training", "this", "stump", ".", "It", "may", "be", "called", "directly", "by", "other", "classes", "that", "are", "creating", "decision", "trees", "to", "avoid", "redundant", "...
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/trees/DecisionStump.java#L373-L376
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/trees/DecisionStump.java
DecisionStump.distributMissing
static protected <T> void distributMissing(List<ClassificationDataSet> splits, double[] fracs, ClassificationDataSet source, IntList hadMissing) { for (int i : hadMissing) { DataPoint dp = source.getDataPoint(i); for (int j = 0; j < fracs.length; j++) { double nw = fracs[j] * source.getWeight(i); if (Double.isNaN(nw))//happens when no weight is available continue; if (nw <= 1e-13) continue; splits.get(j).addDataPoint(dp, source.getDataPointCategory(i), nw); } } }
java
static protected <T> void distributMissing(List<ClassificationDataSet> splits, double[] fracs, ClassificationDataSet source, IntList hadMissing) { for (int i : hadMissing) { DataPoint dp = source.getDataPoint(i); for (int j = 0; j < fracs.length; j++) { double nw = fracs[j] * source.getWeight(i); if (Double.isNaN(nw))//happens when no weight is available continue; if (nw <= 1e-13) continue; splits.get(j).addDataPoint(dp, source.getDataPointCategory(i), nw); } } }
[ "static", "protected", "<", "T", ">", "void", "distributMissing", "(", "List", "<", "ClassificationDataSet", ">", "splits", ",", "double", "[", "]", "fracs", ",", "ClassificationDataSet", "source", ",", "IntList", "hadMissing", ")", "{", "for", "(", "int", "...
Distributes a list of datapoints that had missing values to each split, re-weighted by the indicated fractions @param <T> @param splits a list of lists, where each inner list is a split @param fracs the fraction of weight to each split, should sum to one @param source @param hadMissing the list of datapoints that had missing values
[ "Distributes", "a", "list", "of", "datapoints", "that", "had", "missing", "values", "to", "each", "split", "re", "-", "weighted", "by", "the", "indicated", "fractions" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/trees/DecisionStump.java#L723-L740
train
EdwardRaff/JSAT
JSAT/src/jsat/text/tokenizer/NaiveTokenizer.java
NaiveTokenizer.setMaxTokenLength
public void setMaxTokenLength(int maxTokenLength) { if(maxTokenLength < 1) throw new IllegalArgumentException("Max token length must be positive, not " + maxTokenLength); if(maxTokenLength <= minTokenLength) throw new IllegalArgumentException("Max token length must be larger than the min token length"); this.maxTokenLength = maxTokenLength; }
java
public void setMaxTokenLength(int maxTokenLength) { if(maxTokenLength < 1) throw new IllegalArgumentException("Max token length must be positive, not " + maxTokenLength); if(maxTokenLength <= minTokenLength) throw new IllegalArgumentException("Max token length must be larger than the min token length"); this.maxTokenLength = maxTokenLength; }
[ "public", "void", "setMaxTokenLength", "(", "int", "maxTokenLength", ")", "{", "if", "(", "maxTokenLength", "<", "1", ")", "throw", "new", "IllegalArgumentException", "(", "\"Max token length must be positive, not \"", "+", "maxTokenLength", ")", ";", "if", "(", "ma...
Sets the maximum allowed length for any token. Any token discovered exceeding the length will not be accepted and skipped over. The default is unbounded. @param maxTokenLength the maximum token length to accept as a valid token
[ "Sets", "the", "maximum", "allowed", "length", "for", "any", "token", ".", "Any", "token", "discovered", "exceeding", "the", "length", "will", "not", "be", "accepted", "and", "skipped", "over", ".", "The", "default", "is", "unbounded", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/text/tokenizer/NaiveTokenizer.java#L137-L144
train
EdwardRaff/JSAT
JSAT/src/jsat/text/tokenizer/NaiveTokenizer.java
NaiveTokenizer.setMinTokenLength
public void setMinTokenLength(int minTokenLength) { if(minTokenLength < 0) throw new IllegalArgumentException("Minimum token length must be non negative, not " + minTokenLength); if(minTokenLength > maxTokenLength) throw new IllegalArgumentException("Minimum token length can not exced the maximum token length"); this.minTokenLength = minTokenLength; }
java
public void setMinTokenLength(int minTokenLength) { if(minTokenLength < 0) throw new IllegalArgumentException("Minimum token length must be non negative, not " + minTokenLength); if(minTokenLength > maxTokenLength) throw new IllegalArgumentException("Minimum token length can not exced the maximum token length"); this.minTokenLength = minTokenLength; }
[ "public", "void", "setMinTokenLength", "(", "int", "minTokenLength", ")", "{", "if", "(", "minTokenLength", "<", "0", ")", "throw", "new", "IllegalArgumentException", "(", "\"Minimum token length must be non negative, not \"", "+", "minTokenLength", ")", ";", "if", "(...
Sets the minimum allowed token length. Any token discovered shorter than the minimum length will not be accepted and skipped over. The default is 0. @param minTokenLength the minimum length for a token to be used
[ "Sets", "the", "minimum", "allowed", "token", "length", ".", "Any", "token", "discovered", "shorter", "than", "the", "minimum", "length", "will", "not", "be", "accepted", "and", "skipped", "over", ".", "The", "default", "is", "0", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/text/tokenizer/NaiveTokenizer.java#L161-L168
train
EdwardRaff/JSAT
JSAT/src/jsat/distributions/kernels/KernelPoints.java
KernelPoints.addNewKernelPoint
public void addNewKernelPoint() { KernelPoint source = points.get(0); KernelPoint toAdd = new KernelPoint(k, errorTolerance); toAdd.setMaxBudget(maxBudget); toAdd.setBudgetStrategy(budgetStrategy); standardMove(toAdd, source); toAdd.kernelAccel = source.kernelAccel; toAdd.vecs = source.vecs; toAdd.alpha = new DoubleList(source.alpha.size()); for (int i = 0; i < source.alpha.size(); i++) toAdd.alpha.add(0.0); points.add(toAdd); }
java
public void addNewKernelPoint() { KernelPoint source = points.get(0); KernelPoint toAdd = new KernelPoint(k, errorTolerance); toAdd.setMaxBudget(maxBudget); toAdd.setBudgetStrategy(budgetStrategy); standardMove(toAdd, source); toAdd.kernelAccel = source.kernelAccel; toAdd.vecs = source.vecs; toAdd.alpha = new DoubleList(source.alpha.size()); for (int i = 0; i < source.alpha.size(); i++) toAdd.alpha.add(0.0); points.add(toAdd); }
[ "public", "void", "addNewKernelPoint", "(", ")", "{", "KernelPoint", "source", "=", "points", ".", "get", "(", "0", ")", ";", "KernelPoint", "toAdd", "=", "new", "KernelPoint", "(", "k", ",", "errorTolerance", ")", ";", "toAdd", ".", "setMaxBudget", "(", ...
Adds a new Kernel Point to the internal list this object represents. The new Kernel Point will be equivalent to creating a new KernelPoint directly.
[ "Adds", "a", "new", "Kernel", "Point", "to", "the", "internal", "list", "this", "object", "represents", ".", "The", "new", "Kernel", "Point", "will", "be", "equivalent", "to", "creating", "a", "new", "KernelPoint", "directly", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/distributions/kernels/KernelPoints.java#L579-L593
train
EdwardRaff/JSAT
JSAT/src/jsat/distributions/kernels/KernelPoints.java
KernelPoints.standardMove
private void standardMove(KernelPoint destination, KernelPoint source) { destination.InvK = source.InvK; destination.InvKExpanded = source.InvKExpanded; destination.K = source.K; destination.KExpanded = source.KExpanded; }
java
private void standardMove(KernelPoint destination, KernelPoint source) { destination.InvK = source.InvK; destination.InvKExpanded = source.InvKExpanded; destination.K = source.K; destination.KExpanded = source.KExpanded; }
[ "private", "void", "standardMove", "(", "KernelPoint", "destination", ",", "KernelPoint", "source", ")", "{", "destination", ".", "InvK", "=", "source", ".", "InvK", ";", "destination", ".", "InvKExpanded", "=", "source", ".", "InvKExpanded", ";", "destination",...
Updates the gram matrix storage of the destination to point at the exact same objects as the ones from the source. @param destination the destination object @param source the source object
[ "Updates", "the", "gram", "matrix", "storage", "of", "the", "destination", "to", "point", "at", "the", "exact", "same", "objects", "as", "the", "ones", "from", "the", "source", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/distributions/kernels/KernelPoints.java#L601-L607
train
EdwardRaff/JSAT
JSAT/src/jsat/distributions/kernels/KernelPoints.java
KernelPoints.getRawBasisVecs
public List<Vec> getRawBasisVecs() { List<Vec> vecs = new ArrayList<Vec>(getBasisSize()); vecs.addAll(this.points.get(0).vecs); return vecs; }
java
public List<Vec> getRawBasisVecs() { List<Vec> vecs = new ArrayList<Vec>(getBasisSize()); vecs.addAll(this.points.get(0).vecs); return vecs; }
[ "public", "List", "<", "Vec", ">", "getRawBasisVecs", "(", ")", "{", "List", "<", "Vec", ">", "vecs", "=", "new", "ArrayList", "<", "Vec", ">", "(", "getBasisSize", "(", ")", ")", ";", "vecs", ".", "addAll", "(", "this", ".", "points", ".", "get", ...
Returns a list of the raw vectors being used by the kernel points. Altering this vectors will alter the same vectors used by these objects and will cause inconsistent results. @return the list of raw basis vectors used by the Kernel points
[ "Returns", "a", "list", "of", "the", "raw", "vectors", "being", "used", "by", "the", "kernel", "points", ".", "Altering", "this", "vectors", "will", "alter", "the", "same", "vectors", "used", "by", "these", "objects", "and", "will", "cause", "inconsistent", ...
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/distributions/kernels/KernelPoints.java#L628-L633
train
EdwardRaff/JSAT
JSAT/src/jsat/distributions/kernels/KernelPoints.java
KernelPoints.addMissingZeros
private void addMissingZeros() { //go back and add 0s for the onces we missed for (int i = 0; i < points.size(); i++) while(points.get(i).alpha.size() < this.points.get(0).vecs.size()) points.get(i).alpha.add(0.0); }
java
private void addMissingZeros() { //go back and add 0s for the onces we missed for (int i = 0; i < points.size(); i++) while(points.get(i).alpha.size() < this.points.get(0).vecs.size()) points.get(i).alpha.add(0.0); }
[ "private", "void", "addMissingZeros", "(", ")", "{", "//go back and add 0s for the onces we missed", "for", "(", "int", "i", "=", "0", ";", "i", "<", "points", ".", "size", "(", ")", ";", "i", "++", ")", "while", "(", "points", ".", "get", "(", "i", ")...
Adds zeros to all alpha vecs that are not of the same length as the vec list
[ "Adds", "zeros", "to", "all", "alpha", "vecs", "that", "are", "not", "of", "the", "same", "length", "as", "the", "vec", "list" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/distributions/kernels/KernelPoints.java#L654-L660
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/linear/kernelized/OSKL.java
OSKL.updateAverage
private void updateAverage() { if(t == last_t || t < burnIn) return; else if(last_t < burnIn)//first update since done burning { for(int i = 0; i < alphaAveraged.size(); i++) alphaAveraged.set(i, alphas.get(i)); } double w = t-last_t;//time elapsed for(int i = 0; i < alphaAveraged.size(); i++) { double delta = alphas.getD(i) - alphaAveraged.getD(i); alphaAveraged.set(i, alphaAveraged.getD(i)+delta*w/t); } last_t = t;//average done }
java
private void updateAverage() { if(t == last_t || t < burnIn) return; else if(last_t < burnIn)//first update since done burning { for(int i = 0; i < alphaAveraged.size(); i++) alphaAveraged.set(i, alphas.get(i)); } double w = t-last_t;//time elapsed for(int i = 0; i < alphaAveraged.size(); i++) { double delta = alphas.getD(i) - alphaAveraged.getD(i); alphaAveraged.set(i, alphaAveraged.getD(i)+delta*w/t); } last_t = t;//average done }
[ "private", "void", "updateAverage", "(", ")", "{", "if", "(", "t", "==", "last_t", "||", "t", "<", "burnIn", ")", "return", ";", "else", "if", "(", "last_t", "<", "burnIn", ")", "//first update since done burning ", "{", "for", "(", "int", "i", "=", "0...
Updates the average model to reflect the current time average
[ "Updates", "the", "average", "model", "to", "reflect", "the", "current", "time", "average" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/linear/kernelized/OSKL.java#L419-L435
train
EdwardRaff/JSAT
JSAT/src/jsat/distributions/kernels/GeneralRBFKernel.java
GeneralRBFKernel.setSigma
public void setSigma(double sigma) { if(sigma <= 0 || Double.isNaN(sigma) || Double.isInfinite(sigma)) throw new IllegalArgumentException("Sigma must be a positive constant, not " + sigma); this.sigma = sigma; this.sigmaSqrd2Inv = 0.5/(sigma*sigma); }
java
public void setSigma(double sigma) { if(sigma <= 0 || Double.isNaN(sigma) || Double.isInfinite(sigma)) throw new IllegalArgumentException("Sigma must be a positive constant, not " + sigma); this.sigma = sigma; this.sigmaSqrd2Inv = 0.5/(sigma*sigma); }
[ "public", "void", "setSigma", "(", "double", "sigma", ")", "{", "if", "(", "sigma", "<=", "0", "||", "Double", ".", "isNaN", "(", "sigma", ")", "||", "Double", ".", "isInfinite", "(", "sigma", ")", ")", "throw", "new", "IllegalArgumentException", "(", ...
Sets the kernel width parameter, which must be a positive value. Larger values indicate a larger width @param sigma the sigma value
[ "Sets", "the", "kernel", "width", "parameter", "which", "must", "be", "a", "positive", "value", ".", "Larger", "values", "indicate", "a", "larger", "width" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/distributions/kernels/GeneralRBFKernel.java#L57-L63
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/linear/StochasticSTLinearL1.java
StochasticSTLinearL1.setMaxScaled
public void setMaxScaled(double maxFeature) { if(Double.isNaN(maxFeature)) throw new ArithmeticException("NaN is not a valid feature value"); else if(maxFeature > 1) throw new ArithmeticException("Maximum possible feature value is 1, can not use " + maxFeature); else if(maxFeature <= minScaled) throw new ArithmeticException("Maximum feature value must be learger than the minimum"); this.maxScaled = maxFeature; }
java
public void setMaxScaled(double maxFeature) { if(Double.isNaN(maxFeature)) throw new ArithmeticException("NaN is not a valid feature value"); else if(maxFeature > 1) throw new ArithmeticException("Maximum possible feature value is 1, can not use " + maxFeature); else if(maxFeature <= minScaled) throw new ArithmeticException("Maximum feature value must be learger than the minimum"); this.maxScaled = maxFeature; }
[ "public", "void", "setMaxScaled", "(", "double", "maxFeature", ")", "{", "if", "(", "Double", ".", "isNaN", "(", "maxFeature", ")", ")", "throw", "new", "ArithmeticException", "(", "\"NaN is not a valid feature value\"", ")", ";", "else", "if", "(", "maxFeature"...
Sets the maximum value of any feature after scaling is applied. This value can be no greater than 1. @param maxFeature the maximum feature value after scaling
[ "Sets", "the", "maximum", "value", "of", "any", "feature", "after", "scaling", "is", "applied", ".", "This", "value", "can", "be", "no", "greater", "than", "1", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/linear/StochasticSTLinearL1.java#L233-L242
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/linear/StochasticSTLinearL1.java
StochasticSTLinearL1.setMinScaled
public void setMinScaled(double minFeature) { if(Double.isNaN(minFeature)) throw new ArithmeticException("NaN is not a valid feature value"); else if(minFeature < -1) throw new ArithmeticException("Minimum possible feature value is -1, can not use " + minFeature); else if(minFeature >= maxScaled) throw new ArithmeticException("Minimum feature value must be smaller than the maximum"); this.minScaled = minFeature; }
java
public void setMinScaled(double minFeature) { if(Double.isNaN(minFeature)) throw new ArithmeticException("NaN is not a valid feature value"); else if(minFeature < -1) throw new ArithmeticException("Minimum possible feature value is -1, can not use " + minFeature); else if(minFeature >= maxScaled) throw new ArithmeticException("Minimum feature value must be smaller than the maximum"); this.minScaled = minFeature; }
[ "public", "void", "setMinScaled", "(", "double", "minFeature", ")", "{", "if", "(", "Double", ".", "isNaN", "(", "minFeature", ")", ")", "throw", "new", "ArithmeticException", "(", "\"NaN is not a valid feature value\"", ")", ";", "else", "if", "(", "minFeature"...
Sets the minimum value of any feature after scaling is applied. This value can be no smaller than -1 @param minFeature the minimum feature value after scaling
[ "Sets", "the", "minimum", "value", "of", "any", "feature", "after", "scaling", "is", "applied", ".", "This", "value", "can", "be", "no", "smaller", "than", "-", "1" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/linear/StochasticSTLinearL1.java#L258-L267
train
EdwardRaff/JSAT
JSAT/src/jsat/distributions/kernels/PukKernel.java
PukKernel.setOmega
public void setOmega(double omega) { if(omega <= 0 || Double.isNaN(omega) || Double.isInfinite(omega)) throw new ArithmeticException("omega must be positive, not " + omega); this.omega = omega; this.cnst = Math.sqrt(Math.pow(2, 1/omega)-1); }
java
public void setOmega(double omega) { if(omega <= 0 || Double.isNaN(omega) || Double.isInfinite(omega)) throw new ArithmeticException("omega must be positive, not " + omega); this.omega = omega; this.cnst = Math.sqrt(Math.pow(2, 1/omega)-1); }
[ "public", "void", "setOmega", "(", "double", "omega", ")", "{", "if", "(", "omega", "<=", "0", "||", "Double", ".", "isNaN", "(", "omega", ")", "||", "Double", ".", "isInfinite", "(", "omega", ")", ")", "throw", "new", "ArithmeticException", "(", "\"om...
Sets the omega parameter value, which controls the shape of the kernel @param omega the positive parameter value
[ "Sets", "the", "omega", "parameter", "value", "which", "controls", "the", "shape", "of", "the", "kernel" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/distributions/kernels/PukKernel.java#L47-L53
train
EdwardRaff/JSAT
JSAT/src/jsat/distributions/kernels/PukKernel.java
PukKernel.setSigma
public void setSigma(double sigma) { if(sigma <= 0 || Double.isNaN(sigma) || Double.isInfinite(sigma)) throw new ArithmeticException("sigma must be positive, not " + sigma); this.sigma = sigma; }
java
public void setSigma(double sigma) { if(sigma <= 0 || Double.isNaN(sigma) || Double.isInfinite(sigma)) throw new ArithmeticException("sigma must be positive, not " + sigma); this.sigma = sigma; }
[ "public", "void", "setSigma", "(", "double", "sigma", ")", "{", "if", "(", "sigma", "<=", "0", "||", "Double", ".", "isNaN", "(", "sigma", ")", "||", "Double", ".", "isInfinite", "(", "sigma", ")", ")", "throw", "new", "ArithmeticException", "(", "\"si...
Sets the sigma parameter value, which controls the width of the kernel @param sigma the positive parameter value
[ "Sets", "the", "sigma", "parameter", "value", "which", "controls", "the", "width", "of", "the", "kernel" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/distributions/kernels/PukKernel.java#L64-L69
train
EdwardRaff/JSAT
JSAT/src/jsat/datatransform/PCA.java
PCA.getColumn
private static Vec getColumn(Matrix x) { Vec t; for(int i = 0; i < x.cols(); i++) { t = x.getColumn(i); if(t.dot(t) > 0 ) return t; } throw new ArithmeticException("Matrix is essentially zero"); }
java
private static Vec getColumn(Matrix x) { Vec t; for(int i = 0; i < x.cols(); i++) { t = x.getColumn(i); if(t.dot(t) > 0 ) return t; } throw new ArithmeticException("Matrix is essentially zero"); }
[ "private", "static", "Vec", "getColumn", "(", "Matrix", "x", ")", "{", "Vec", "t", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "x", ".", "cols", "(", ")", ";", "i", "++", ")", "{", "t", "=", "x", ".", "getColumn", "(", "i", ")", ...
Returns the first non zero column @param x the matrix to get a column from @return the first non zero column
[ "Returns", "the", "first", "non", "zero", "column" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/datatransform/PCA.java#L246-L258
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/linear/LinearBatch.java
LinearBatch.doWarmStartIfNotNull
private void doWarmStartIfNotNull(Object warmSolution) throws FailedToFitException { if(warmSolution != null ) { if(warmSolution instanceof SimpleWeightVectorModel) { SimpleWeightVectorModel warm = (SimpleWeightVectorModel) warmSolution; if(warm.numWeightsVecs() != ws.length) throw new FailedToFitException("Warm solution has " + warm.numWeightsVecs() + " weight vectors instead of " + ws.length); for(int i = 0; i < ws.length; i++) { warm.getRawWeight(i).copyTo(ws[i]); if(useBiasTerm) bs[i] = warm.getBias(i); } } else throw new FailedToFitException("Can not warm warm from " + warmSolution.getClass().getCanonicalName()); } }
java
private void doWarmStartIfNotNull(Object warmSolution) throws FailedToFitException { if(warmSolution != null ) { if(warmSolution instanceof SimpleWeightVectorModel) { SimpleWeightVectorModel warm = (SimpleWeightVectorModel) warmSolution; if(warm.numWeightsVecs() != ws.length) throw new FailedToFitException("Warm solution has " + warm.numWeightsVecs() + " weight vectors instead of " + ws.length); for(int i = 0; i < ws.length; i++) { warm.getRawWeight(i).copyTo(ws[i]); if(useBiasTerm) bs[i] = warm.getBias(i); } } else throw new FailedToFitException("Can not warm warm from " + warmSolution.getClass().getCanonicalName()); } }
[ "private", "void", "doWarmStartIfNotNull", "(", "Object", "warmSolution", ")", "throws", "FailedToFitException", "{", "if", "(", "warmSolution", "!=", "null", ")", "{", "if", "(", "warmSolution", "instanceof", "SimpleWeightVectorModel", ")", "{", "SimpleWeightVectorMo...
Performs a warm start if the given object is of the appropriate class. Nothing happens if input it null. @param warmSolution @throws FailedToFitException
[ "Performs", "a", "warm", "start", "if", "the", "given", "object", "is", "of", "the", "appropriate", "class", ".", "Nothing", "happens", "if", "input", "it", "null", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/linear/LinearBatch.java#L328-L347
train
EdwardRaff/JSAT
JSAT/src/jsat/utils/ListUtils.java
ListUtils.mergedView
public static <T> List<T> mergedView(final List<T> left, final List<T> right) { List<T> merged = new AbstractList<T>() { @Override public T get(int index) { if(index < left.size()) return left.get(index); else if(index-left.size() < right.size()) return right.get(index-left.size()); else throw new IndexOutOfBoundsException("List of lengt " + size() + " has no index " + index); } @Override public int size() { return left.size() + right.size(); } }; return merged; }
java
public static <T> List<T> mergedView(final List<T> left, final List<T> right) { List<T> merged = new AbstractList<T>() { @Override public T get(int index) { if(index < left.size()) return left.get(index); else if(index-left.size() < right.size()) return right.get(index-left.size()); else throw new IndexOutOfBoundsException("List of lengt " + size() + " has no index " + index); } @Override public int size() { return left.size() + right.size(); } }; return merged; }
[ "public", "static", "<", "T", ">", "List", "<", "T", ">", "mergedView", "(", "final", "List", "<", "T", ">", "left", ",", "final", "List", "<", "T", ">", "right", ")", "{", "List", "<", "T", ">", "merged", "=", "new", "AbstractList", "<", "T", ...
Returns a new unmodifiable view that is the merging of two lists @param <T> the type the lists hold @param left the left portion of the merged view @param right the right portion of the merged view @return a list view that contains bot the left and right lists
[ "Returns", "a", "new", "unmodifiable", "view", "that", "is", "the", "merging", "of", "two", "lists" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/utils/ListUtils.java#L66-L89
train
EdwardRaff/JSAT
JSAT/src/jsat/utils/ListUtils.java
ListUtils.collectFutures
public static <T> List<T> collectFutures(Collection<Future<T>> futures) throws ExecutionException, InterruptedException { ArrayList<T> collected = new ArrayList<T>(futures.size()); for (Future<T> future : futures) collected.add(future.get()); return collected; }
java
public static <T> List<T> collectFutures(Collection<Future<T>> futures) throws ExecutionException, InterruptedException { ArrayList<T> collected = new ArrayList<T>(futures.size()); for (Future<T> future : futures) collected.add(future.get()); return collected; }
[ "public", "static", "<", "T", ">", "List", "<", "T", ">", "collectFutures", "(", "Collection", "<", "Future", "<", "T", ">", ">", "futures", ")", "throws", "ExecutionException", ",", "InterruptedException", "{", "ArrayList", "<", "T", ">", "collected", "="...
Collects all future values in a collection into a list, and returns said list. This method will block until all future objects are collected. @param <T> the type of future object @param futures the collection of future objects @return a list containing the object from the future. @throws ExecutionException @throws InterruptedException
[ "Collects", "all", "future", "values", "in", "a", "collection", "into", "a", "list", "and", "returns", "said", "list", ".", "This", "method", "will", "block", "until", "all", "future", "objects", "are", "collected", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/utils/ListUtils.java#L112-L120
train
EdwardRaff/JSAT
JSAT/src/jsat/utils/ListUtils.java
ListUtils.range
public static IntList range(int start, int to, int step) { if(to < start) throw new RuntimeException("starting index " + start + " must be less than or equal to ending index" + to); else if(step < 1) throw new RuntimeException("Step size must be a positive integer, not " + step); IntList toRet = new IntList((to-start)/step); for(int i = start; i < to; i+=step) toRet.add(i); return toRet; }
java
public static IntList range(int start, int to, int step) { if(to < start) throw new RuntimeException("starting index " + start + " must be less than or equal to ending index" + to); else if(step < 1) throw new RuntimeException("Step size must be a positive integer, not " + step); IntList toRet = new IntList((to-start)/step); for(int i = start; i < to; i+=step) toRet.add(i); return toRet; }
[ "public", "static", "IntList", "range", "(", "int", "start", ",", "int", "to", ",", "int", "step", ")", "{", "if", "(", "to", "<", "start", ")", "throw", "new", "RuntimeException", "(", "\"starting index \"", "+", "start", "+", "\" must be less than or equal...
Returns a list of integers with values in the given range @param start the starting integer value (inclusive) @param to the ending integer value (exclusive) @param step the step size between values @return a list of integers containing the specified range of integers
[ "Returns", "a", "list", "of", "integers", "with", "values", "in", "the", "given", "range" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/utils/ListUtils.java#L160-L170
train
EdwardRaff/JSAT
JSAT/src/jsat/distributions/discrete/DiscreteDistribution.java
DiscreteDistribution.invCdfRootFinding
protected double invCdfRootFinding(double p, double tol) { if (p < 0 || p > 1) throw new ArithmeticException("Value of p must be in the range [0,1], not " + p); //two special case checks, as they can cause a failure to get a positive and negative value on the ends, which means we can't do a search for the root //Special case check, p < min value if(min() >= Integer.MIN_VALUE) if(p <= cdf(min())) return min(); //special case check, p >= max value if(max() < Integer.MAX_VALUE) if(p > cdf(max()-1)) return max(); //stewpwise nature fo discrete can cause problems for search, so we will use a smoothed cdf to pass in // double toRet= invCdf(p, ); //Lets use an interpolated version of the CDF so that our numerical methods will behave better Function1D cdfInterpolated = (double x) -> { double query = x; //if it happens to fall on an int we just compute the regular value if(Math.rint(query) == query) return cdf((int)query) - p; //else, interpolate double larger = query+1; double diff = larger-query; return cdf(query)*diff + cdf(larger)*(1-diff) - p; }; double a = Double.isInfinite(min()) ? Integer.MIN_VALUE*.95 : min(); double b = Double.isInfinite(max()) ? Integer.MAX_VALUE*.95 : max(); double toRet = Zeroin.root(tol, a, b, cdfInterpolated); return Math.round(toRet); }
java
protected double invCdfRootFinding(double p, double tol) { if (p < 0 || p > 1) throw new ArithmeticException("Value of p must be in the range [0,1], not " + p); //two special case checks, as they can cause a failure to get a positive and negative value on the ends, which means we can't do a search for the root //Special case check, p < min value if(min() >= Integer.MIN_VALUE) if(p <= cdf(min())) return min(); //special case check, p >= max value if(max() < Integer.MAX_VALUE) if(p > cdf(max()-1)) return max(); //stewpwise nature fo discrete can cause problems for search, so we will use a smoothed cdf to pass in // double toRet= invCdf(p, ); //Lets use an interpolated version of the CDF so that our numerical methods will behave better Function1D cdfInterpolated = (double x) -> { double query = x; //if it happens to fall on an int we just compute the regular value if(Math.rint(query) == query) return cdf((int)query) - p; //else, interpolate double larger = query+1; double diff = larger-query; return cdf(query)*diff + cdf(larger)*(1-diff) - p; }; double a = Double.isInfinite(min()) ? Integer.MIN_VALUE*.95 : min(); double b = Double.isInfinite(max()) ? Integer.MAX_VALUE*.95 : max(); double toRet = Zeroin.root(tol, a, b, cdfInterpolated); return Math.round(toRet); }
[ "protected", "double", "invCdfRootFinding", "(", "double", "p", ",", "double", "tol", ")", "{", "if", "(", "p", "<", "0", "||", "p", ">", "1", ")", "throw", "new", "ArithmeticException", "(", "\"Value of p must be in the range [0,1], not \"", "+", "p", ")", ...
Helper method that computes the inverse CDF by performing root-finding on the CDF of the function. This provides a convenient default method for any invCdfRootFinding implementation, but may not be as fast or accurate as possible. @param p the probability value @param tol the search tolerance @return the value such that the CDF would return p
[ "Helper", "method", "that", "computes", "the", "inverse", "CDF", "by", "performing", "root", "-", "finding", "on", "the", "CDF", "of", "the", "function", ".", "This", "provides", "a", "convenient", "default", "method", "for", "any", "invCdfRootFinding", "imple...
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/distributions/discrete/DiscreteDistribution.java#L87-L122
train
EdwardRaff/JSAT
JSAT/src/jsat/math/optimization/stochastic/SGDMomentum.java
SGDMomentum.setMomentum
public void setMomentum(double momentum) { if(momentum <= 0 || momentum >= 1 || Double.isNaN(momentum)) throw new IllegalArgumentException("Momentum must be in (0,1) not " + momentum); this.momentum = momentum; }
java
public void setMomentum(double momentum) { if(momentum <= 0 || momentum >= 1 || Double.isNaN(momentum)) throw new IllegalArgumentException("Momentum must be in (0,1) not " + momentum); this.momentum = momentum; }
[ "public", "void", "setMomentum", "(", "double", "momentum", ")", "{", "if", "(", "momentum", "<=", "0", "||", "momentum", ">=", "1", "||", "Double", ".", "isNaN", "(", "momentum", ")", ")", "throw", "new", "IllegalArgumentException", "(", "\"Momentum must be...
Sets the momentum for accumulating gradients. @param momentum the momentum buildup term in (0, 1)
[ "Sets", "the", "momentum", "for", "accumulating", "gradients", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/math/optimization/stochastic/SGDMomentum.java#L70-L75
train
EdwardRaff/JSAT
JSAT/src/jsat/distributions/Normal.java
Normal.logPdf
public static double logPdf(double x, double mu, double sigma) { return -0.5*log(2*PI) - log(sigma) + -pow(x-mu,2)/(2*sigma*sigma); }
java
public static double logPdf(double x, double mu, double sigma) { return -0.5*log(2*PI) - log(sigma) + -pow(x-mu,2)/(2*sigma*sigma); }
[ "public", "static", "double", "logPdf", "(", "double", "x", ",", "double", "mu", ",", "double", "sigma", ")", "{", "return", "-", "0.5", "*", "log", "(", "2", "*", "PI", ")", "-", "log", "(", "sigma", ")", "+", "-", "pow", "(", "x", "-", "mu", ...
Computes the log probability of a given value @param x the value to the get log(pdf) of @param mu the mean of the distribution @param sigma the standard deviation of the distribution @return the log probability
[ "Computes", "the", "log", "probability", "of", "a", "given", "value" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/distributions/Normal.java#L152-L155
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/linear/SMIDAS.java
SMIDAS.setEta
public void setEta(double eta) { if(Double.isNaN(eta) || Double.isInfinite(eta) || eta <= 0) throw new ArithmeticException("convergence parameter must be a positive value"); this.eta = eta; }
java
public void setEta(double eta) { if(Double.isNaN(eta) || Double.isInfinite(eta) || eta <= 0) throw new ArithmeticException("convergence parameter must be a positive value"); this.eta = eta; }
[ "public", "void", "setEta", "(", "double", "eta", ")", "{", "if", "(", "Double", ".", "isNaN", "(", "eta", ")", "||", "Double", ".", "isInfinite", "(", "eta", ")", "||", "eta", "<=", "0", ")", "throw", "new", "ArithmeticException", "(", "\"convergence ...
Sets the learning rate used during training @param eta the learning rate to use
[ "Sets", "the", "learning", "rate", "used", "during", "training" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/linear/SMIDAS.java#L90-L95
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/knn/DANN.java
DANN.setEpsilon
public void setEpsilon(double eps) { if(eps < 0 || Double.isInfinite(eps) || Double.isNaN(eps)) throw new ArithmeticException("Regularization must be a positive value"); this.eps = eps; }
java
public void setEpsilon(double eps) { if(eps < 0 || Double.isInfinite(eps) || Double.isNaN(eps)) throw new ArithmeticException("Regularization must be a positive value"); this.eps = eps; }
[ "public", "void", "setEpsilon", "(", "double", "eps", ")", "{", "if", "(", "eps", "<", "0", "||", "Double", ".", "isInfinite", "(", "eps", ")", "||", "Double", ".", "isNaN", "(", "eps", ")", ")", "throw", "new", "ArithmeticException", "(", "\"Regulariz...
Sets the regularization to apply the the diagonal of the scatter matrix when creating each new metric. @param eps the regularization value
[ "Sets", "the", "regularization", "to", "apply", "the", "the", "diagonal", "of", "the", "scatter", "matrix", "when", "creating", "each", "new", "metric", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/knn/DANN.java#L212-L217
train
EdwardRaff/JSAT
JSAT/src/jsat/clustering/OPTICS.java
OPTICS.threshHoldExtractCluster
private int threshHoldExtractCluster(List<Integer> orderedFile, int[] designations) { int clustersFound = 0; OnLineStatistics stats = new OnLineStatistics(); for(double r : reach_d) if(!Double.isInfinite(r)) stats.add(r); double thresh = stats.getMean()+stats.getStandardDeviation(); for(int i = 0; i < orderedFile.size(); i++) { if(reach_d[orderedFile.get(i)] >= thresh) continue; //Everything in between is part of the cluster while(i < orderedFile.size() && reach_d[orderedFile.get(i)] < thresh) designations[i++] = clustersFound; //Climb up to the top of the hill, everything we climbed over is part of the cluster while(i+1 < orderedFile.size() && reach_d[orderedFile.get(i)] < reach_d[orderedFile.get(i+1)]) designations[i++] = clustersFound; clustersFound++; } return clustersFound; }
java
private int threshHoldExtractCluster(List<Integer> orderedFile, int[] designations) { int clustersFound = 0; OnLineStatistics stats = new OnLineStatistics(); for(double r : reach_d) if(!Double.isInfinite(r)) stats.add(r); double thresh = stats.getMean()+stats.getStandardDeviation(); for(int i = 0; i < orderedFile.size(); i++) { if(reach_d[orderedFile.get(i)] >= thresh) continue; //Everything in between is part of the cluster while(i < orderedFile.size() && reach_d[orderedFile.get(i)] < thresh) designations[i++] = clustersFound; //Climb up to the top of the hill, everything we climbed over is part of the cluster while(i+1 < orderedFile.size() && reach_d[orderedFile.get(i)] < reach_d[orderedFile.get(i+1)]) designations[i++] = clustersFound; clustersFound++; } return clustersFound; }
[ "private", "int", "threshHoldExtractCluster", "(", "List", "<", "Integer", ">", "orderedFile", ",", "int", "[", "]", "designations", ")", "{", "int", "clustersFound", "=", "0", ";", "OnLineStatistics", "stats", "=", "new", "OnLineStatistics", "(", ")", ";", ...
Finds clusters by segmenting the reachability plot witha line that is the mean reachability distance times @param orderedFile the ordering of the data points @param designations the storage array for their cluster assignment @return the number of clusters found
[ "Finds", "clusters", "by", "segmenting", "the", "reachability", "plot", "witha", "line", "that", "is", "the", "mean", "reachability", "distance", "times" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/clustering/OPTICS.java#L334-L356
train
EdwardRaff/JSAT
JSAT/src/jsat/text/topicmodel/OnlineLDAsvi.java
OnlineLDAsvi.setK
public void setK(final int K) { if(K < 2) throw new IllegalArgumentException("At least 2 topics must be learned"); this.K = K; gammaLocal = new ThreadLocal<Vec>() { @Override protected Vec initialValue() { return new DenseVector(K); } }; logThetaLocal = new ThreadLocal<Vec>() { @Override protected Vec initialValue() { return new DenseVector(K); } }; expLogThetaLocal = new ThreadLocal<Vec>() { @Override protected Vec initialValue() { return new DenseVector(K); } }; lambda = null; }
java
public void setK(final int K) { if(K < 2) throw new IllegalArgumentException("At least 2 topics must be learned"); this.K = K; gammaLocal = new ThreadLocal<Vec>() { @Override protected Vec initialValue() { return new DenseVector(K); } }; logThetaLocal = new ThreadLocal<Vec>() { @Override protected Vec initialValue() { return new DenseVector(K); } }; expLogThetaLocal = new ThreadLocal<Vec>() { @Override protected Vec initialValue() { return new DenseVector(K); } }; lambda = null; }
[ "public", "void", "setK", "(", "final", "int", "K", ")", "{", "if", "(", "K", "<", "2", ")", "throw", "new", "IllegalArgumentException", "(", "\"At least 2 topics must be learned\"", ")", ";", "this", ".", "K", "=", "K", ";", "gammaLocal", "=", "new", "T...
Sets the number of topics that LDA will try to learn @param K the number of topics to learn
[ "Sets", "the", "number", "of", "topics", "that", "LDA", "will", "try", "to", "learn" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/text/topicmodel/OnlineLDAsvi.java#L165-L196
train
EdwardRaff/JSAT
JSAT/src/jsat/text/topicmodel/OnlineLDAsvi.java
OnlineLDAsvi.setTau0
public void setTau0(double tau0) { if(tau0 <= 0 || Double.isInfinite(tau0) || Double.isNaN(tau0)) throw new IllegalArgumentException("Eta must be a positive constant, not " + tau0); this.tau0 = tau0; }
java
public void setTau0(double tau0) { if(tau0 <= 0 || Double.isInfinite(tau0) || Double.isNaN(tau0)) throw new IllegalArgumentException("Eta must be a positive constant, not " + tau0); this.tau0 = tau0; }
[ "public", "void", "setTau0", "(", "double", "tau0", ")", "{", "if", "(", "tau0", "<=", "0", "||", "Double", ".", "isInfinite", "(", "tau0", ")", "||", "Double", ".", "isNaN", "(", "tau0", ")", ")", "throw", "new", "IllegalArgumentException", "(", "\"Et...
A learning rate constant to control the influence of early iterations on the solution. Larger values reduce the influence of earlier iterations, smaller values increase the weight of earlier iterations. @param tau0 a learning rate parameter that must be greater than 0 (usually at least 1)
[ "A", "learning", "rate", "constant", "to", "control", "the", "influence", "of", "early", "iterations", "on", "the", "solution", ".", "Larger", "values", "reduce", "the", "influence", "of", "earlier", "iterations", "smaller", "values", "increase", "the", "weight"...
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/text/topicmodel/OnlineLDAsvi.java#L299-L304
train
EdwardRaff/JSAT
JSAT/src/jsat/text/topicmodel/OnlineLDAsvi.java
OnlineLDAsvi.setKappa
public void setKappa(double kappa) { if(kappa < 0.5 || kappa > 1.0 || Double.isNaN(kappa)) throw new IllegalArgumentException("Kapp must be in [0.5, 1], not " + kappa); this.kappa = kappa; }
java
public void setKappa(double kappa) { if(kappa < 0.5 || kappa > 1.0 || Double.isNaN(kappa)) throw new IllegalArgumentException("Kapp must be in [0.5, 1], not " + kappa); this.kappa = kappa; }
[ "public", "void", "setKappa", "(", "double", "kappa", ")", "{", "if", "(", "kappa", "<", "0.5", "||", "kappa", ">", "1.0", "||", "Double", ".", "isNaN", "(", "kappa", ")", ")", "throw", "new", "IllegalArgumentException", "(", "\"Kapp must be in [0.5, 1], not...
The "forgetfulness" factor in the learning rate. Larger values increase the rate at which old information is "forgotten" @param kappa the forgetfulness factor in [0.5, 1]
[ "The", "forgetfulness", "factor", "in", "the", "learning", "rate", ".", "Larger", "values", "increase", "the", "rate", "at", "which", "old", "information", "is", "forgotten" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/text/topicmodel/OnlineLDAsvi.java#L331-L336
train
EdwardRaff/JSAT
JSAT/src/jsat/text/topicmodel/OnlineLDAsvi.java
OnlineLDAsvi.getTopicVec
public Vec getTopicVec(int k) { return new ScaledVector(1.0/lambda.get(k).sum(), lambda.get(k)); }
java
public Vec getTopicVec(int k) { return new ScaledVector(1.0/lambda.get(k).sum(), lambda.get(k)); }
[ "public", "Vec", "getTopicVec", "(", "int", "k", ")", "{", "return", "new", "ScaledVector", "(", "1.0", "/", "lambda", ".", "get", "(", "k", ")", ".", "sum", "(", ")", ",", "lambda", ".", "get", "(", "k", ")", ")", ";", "}" ]
Returns the topic vector for a given topic. The vector should not be altered, and is scaled so that the sum of all term weights sums to one. @param k the topic to get the vector for @return the raw topic vector for the requested topic.
[ "Returns", "the", "topic", "vector", "for", "a", "given", "topic", ".", "The", "vector", "should", "not", "be", "altered", "and", "is", "scaled", "so", "that", "the", "sum", "of", "all", "term", "weights", "sums", "to", "one", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/text/topicmodel/OnlineLDAsvi.java#L365-L368
train
EdwardRaff/JSAT
JSAT/src/jsat/text/topicmodel/OnlineLDAsvi.java
OnlineLDAsvi.model
public void model(DataSet dataSet, int topics, ExecutorService ex) { if(ex == null) ex = new FakeExecutor(); //Use notation same as original paper setK(topics); setD(dataSet.size()); setVocabSize(dataSet.getNumNumericalVars()); final List<Vec> docs = dataSet.getDataVectors(); for(int epoch = 0; epoch < epochs; epoch++) { Collections.shuffle(docs); for(int i = 0; i < D; i+=miniBatchSize) { int to = Math.min(i+miniBatchSize, D); update(docs.subList(i, to), ex); } } }
java
public void model(DataSet dataSet, int topics, ExecutorService ex) { if(ex == null) ex = new FakeExecutor(); //Use notation same as original paper setK(topics); setD(dataSet.size()); setVocabSize(dataSet.getNumNumericalVars()); final List<Vec> docs = dataSet.getDataVectors(); for(int epoch = 0; epoch < epochs; epoch++) { Collections.shuffle(docs); for(int i = 0; i < D; i+=miniBatchSize) { int to = Math.min(i+miniBatchSize, D); update(docs.subList(i, to), ex); } } }
[ "public", "void", "model", "(", "DataSet", "dataSet", ",", "int", "topics", ",", "ExecutorService", "ex", ")", "{", "if", "(", "ex", "==", "null", ")", "ex", "=", "new", "FakeExecutor", "(", ")", ";", "//Use notation same as original paper", "setK", "(", "...
Fits the LDA model against the given data set @param dataSet the data set to learn a topic model for @param topics the number of topics to learn @param ex the source of threads for parallel execution
[ "Fits", "the", "LDA", "model", "against", "the", "given", "data", "set" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/text/topicmodel/OnlineLDAsvi.java#L560-L581
train
EdwardRaff/JSAT
JSAT/src/jsat/text/topicmodel/OnlineLDAsvi.java
OnlineLDAsvi.prepareGammaTheta
private void prepareGammaTheta(Vec gamma_i, Vec eLogTheta_i, Vec expLogTheta_i, Random rand) { final double lambdaInv = (W * K) / (D * 100.0); for (int j = 0; j < gamma_i.length(); j++) gamma_i.set(j, sampleExpoDist(lambdaInv, rand.nextDouble()) + eta); expandPsiMinusPsiSum(gamma_i, gamma_i.sum(), eLogTheta_i); for (int j = 0; j < eLogTheta_i.length(); j++) expLogTheta_i.set(j, FastMath.exp(eLogTheta_i.get(j))); }
java
private void prepareGammaTheta(Vec gamma_i, Vec eLogTheta_i, Vec expLogTheta_i, Random rand) { final double lambdaInv = (W * K) / (D * 100.0); for (int j = 0; j < gamma_i.length(); j++) gamma_i.set(j, sampleExpoDist(lambdaInv, rand.nextDouble()) + eta); expandPsiMinusPsiSum(gamma_i, gamma_i.sum(), eLogTheta_i); for (int j = 0; j < eLogTheta_i.length(); j++) expLogTheta_i.set(j, FastMath.exp(eLogTheta_i.get(j))); }
[ "private", "void", "prepareGammaTheta", "(", "Vec", "gamma_i", ",", "Vec", "eLogTheta_i", ",", "Vec", "expLogTheta_i", ",", "Random", "rand", ")", "{", "final", "double", "lambdaInv", "=", "(", "W", "*", "K", ")", "/", "(", "D", "*", "100.0", ")", ";",...
Prepares gamma and the associated theta expectations are initialized so that the iterative updates to them can begin. @param gamma_i will be completely overwritten @param eLogTheta_i will be completely overwritten @param expLogTheta_i will be completely overwritten @param rand the source of randomness
[ "Prepares", "gamma", "and", "the", "associated", "theta", "expectations", "are", "initialized", "so", "that", "the", "iterative", "updates", "to", "them", "can", "begin", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/text/topicmodel/OnlineLDAsvi.java#L678-L687
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/bayesian/graphicalmodel/DirectedGraph.java
DirectedGraph.addNode
public void addNode(N node) { if(!nodes.containsKey(node)) nodes.put(node, new Pair<HashSet<N>, HashSet<N>>(new HashSet<N>(), new HashSet<N>())); }
java
public void addNode(N node) { if(!nodes.containsKey(node)) nodes.put(node, new Pair<HashSet<N>, HashSet<N>>(new HashSet<N>(), new HashSet<N>())); }
[ "public", "void", "addNode", "(", "N", "node", ")", "{", "if", "(", "!", "nodes", ".", "containsKey", "(", "node", ")", ")", "nodes", ".", "put", "(", "node", ",", "new", "Pair", "<", "HashSet", "<", "N", ">", ",", "HashSet", "<", "N", ">", ">"...
Adds a new node to the graph @param node the object to make a node
[ "Adds", "a", "new", "node", "to", "the", "graph" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/bayesian/graphicalmodel/DirectedGraph.java#L108-L112
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/bayesian/graphicalmodel/DirectedGraph.java
DirectedGraph.getParents
public Set<N> getParents(N n) { Pair<HashSet<N>, HashSet<N>> p = nodes.get(n); if(p == null) return null; return p.getIncoming(); }
java
public Set<N> getParents(N n) { Pair<HashSet<N>, HashSet<N>> p = nodes.get(n); if(p == null) return null; return p.getIncoming(); }
[ "public", "Set", "<", "N", ">", "getParents", "(", "N", "n", ")", "{", "Pair", "<", "HashSet", "<", "N", ">", ",", "HashSet", "<", "N", ">", ">", "p", "=", "nodes", ".", "get", "(", "n", ")", ";", "if", "(", "p", "==", "null", ")", "return"...
Returns the set of all parents of the requested node, or null if the node does not exist in the graph @param n the node to obtain the parents of @return the set of parents, or null if the node is not in the graph
[ "Returns", "the", "set", "of", "all", "parents", "of", "the", "requested", "node", "or", "null", "if", "the", "node", "does", "not", "exist", "in", "the", "graph" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/bayesian/graphicalmodel/DirectedGraph.java#L119-L127
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/bayesian/graphicalmodel/DirectedGraph.java
DirectedGraph.getChildren
public Set<N> getChildren(N n) { Pair<HashSet<N>, HashSet<N>> p = nodes.get(n); if(p == null) return null; return p.getOutgoing(); }
java
public Set<N> getChildren(N n) { Pair<HashSet<N>, HashSet<N>> p = nodes.get(n); if(p == null) return null; return p.getOutgoing(); }
[ "public", "Set", "<", "N", ">", "getChildren", "(", "N", "n", ")", "{", "Pair", "<", "HashSet", "<", "N", ">", ",", "HashSet", "<", "N", ">", ">", "p", "=", "nodes", ".", "get", "(", "n", ")", ";", "if", "(", "p", "==", "null", ")", "return...
Returns the set of all children of the requested node, or null if the node does not exist in the graph. @param n the node to obtain the children of @return the set of parents, or null if the node is not in the graph
[ "Returns", "the", "set", "of", "all", "children", "of", "the", "requested", "node", "or", "null", "if", "the", "node", "does", "not", "exist", "in", "the", "graph", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/bayesian/graphicalmodel/DirectedGraph.java#L134-L142
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/bayesian/graphicalmodel/DirectedGraph.java
DirectedGraph.removeNode
public void removeNode(N node) { Pair<HashSet<N>, HashSet<N>> p = nodes.remove(node); if(p == null) return; //Outgoing edges we can ignore removint he node drops them. We need to avoid dangling incoming edges to this node we have removed HashSet<N> incomingNodes = p.getIncoming(); for(N incomingNode : incomingNodes) nodes.get(incomingNode).getOutgoing().remove(node); }
java
public void removeNode(N node) { Pair<HashSet<N>, HashSet<N>> p = nodes.remove(node); if(p == null) return; //Outgoing edges we can ignore removint he node drops them. We need to avoid dangling incoming edges to this node we have removed HashSet<N> incomingNodes = p.getIncoming(); for(N incomingNode : incomingNodes) nodes.get(incomingNode).getOutgoing().remove(node); }
[ "public", "void", "removeNode", "(", "N", "node", ")", "{", "Pair", "<", "HashSet", "<", "N", ">", ",", "HashSet", "<", "N", ">", ">", "p", "=", "nodes", ".", "remove", "(", "node", ")", ";", "if", "(", "p", "==", "null", ")", "return", ";", ...
Removes the specified node from the graph. If the node was not in the graph, not change occurs @param node the node to remove from the graph
[ "Removes", "the", "specified", "node", "from", "the", "graph", ".", "If", "the", "node", "was", "not", "in", "the", "graph", "not", "change", "occurs" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/bayesian/graphicalmodel/DirectedGraph.java#L148-L157
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/bayesian/graphicalmodel/DiscreteBayesNetwork.java
DiscreteBayesNetwork.depends
public void depends(int parent, int child) { dag.addNode(child); dag.addNode(parent); dag.addEdge(parent, child); }
java
public void depends(int parent, int child) { dag.addNode(child); dag.addNode(parent); dag.addEdge(parent, child); }
[ "public", "void", "depends", "(", "int", "parent", ",", "int", "child", ")", "{", "dag", ".", "addNode", "(", "child", ")", ";", "dag", ".", "addNode", "(", "parent", ")", ";", "dag", ".", "addEdge", "(", "parent", ",", "child", ")", ";", "}" ]
Adds a dependency relation ship between two variables that will be in the network. The integer value corresponds the the index of the i'th categorical variable, where the class target's value is the number of categorical variables. @param parent the parent variable, which will be explained in part by the child @param child the child variable, which contributes to the conditional probability of the parent.
[ "Adds", "a", "dependency", "relation", "ship", "between", "two", "variables", "that", "will", "be", "in", "the", "network", ".", "The", "integer", "value", "corresponds", "the", "the", "index", "of", "the", "i", "th", "categorical", "variable", "where", "the...
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/bayesian/graphicalmodel/DiscreteBayesNetwork.java#L98-L103
train
EdwardRaff/JSAT
JSAT/src/jsat/math/decayrates/PowerDecay.java
PowerDecay.setTau
public void setTau(double tau) { if(tau <= 0 || Double.isInfinite(tau) || Double.isNaN(tau)) throw new IllegalArgumentException("tau must be a positive constant, not " + tau); this.tau = tau; }
java
public void setTau(double tau) { if(tau <= 0 || Double.isInfinite(tau) || Double.isNaN(tau)) throw new IllegalArgumentException("tau must be a positive constant, not " + tau); this.tau = tau; }
[ "public", "void", "setTau", "(", "double", "tau", ")", "{", "if", "(", "tau", "<=", "0", "||", "Double", ".", "isInfinite", "(", "tau", ")", "||", "Double", ".", "isNaN", "(", "tau", ")", ")", "throw", "new", "IllegalArgumentException", "(", "\"tau mus...
Controls the rate early in time, but has a decreasing impact on the rate returned as time goes forward. Larger values of &tau; dampen the initial rates returned, while lower values let the initial rates start higher. @param tau the early rate dampening parameter
[ "Controls", "the", "rate", "early", "in", "time", "but", "has", "a", "decreasing", "impact", "on", "the", "rate", "returned", "as", "time", "goes", "forward", ".", "Larger", "values", "of", "&tau", ";", "dampen", "the", "initial", "rates", "returned", "whi...
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/math/decayrates/PowerDecay.java#L75-L80
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/trees/TreeNodeVisitor.java
TreeNodeVisitor.regress
public double regress(DataPoint dp) { TreeNodeVisitor node = this; while(!node.isLeaf()) { int path = node.getPath(dp); if(path < 0 )//missing value case { double sum = 0; double resultSum = 0; for(int child = 0; child < childrenCount(); child++) { if(node.isPathDisabled(child)) continue; double child_result = node.getChild(child).regress(dp); sum += node.getPathWeight(child); resultSum += node.getPathWeight(child)*child_result; } if(sum == 0)//all paths disabled? break;//break out and do local classify if(sum < 1.0-1e-5)//re-normalize our result resultSum /= (sum+1e-6); return resultSum; } if(node.isPathDisabled(path))//if missing value makes path < 0, return local regression dec break; node = node.getChild(path); } return node.localRegress(dp); }
java
public double regress(DataPoint dp) { TreeNodeVisitor node = this; while(!node.isLeaf()) { int path = node.getPath(dp); if(path < 0 )//missing value case { double sum = 0; double resultSum = 0; for(int child = 0; child < childrenCount(); child++) { if(node.isPathDisabled(child)) continue; double child_result = node.getChild(child).regress(dp); sum += node.getPathWeight(child); resultSum += node.getPathWeight(child)*child_result; } if(sum == 0)//all paths disabled? break;//break out and do local classify if(sum < 1.0-1e-5)//re-normalize our result resultSum /= (sum+1e-6); return resultSum; } if(node.isPathDisabled(path))//if missing value makes path < 0, return local regression dec break; node = node.getChild(path); } return node.localRegress(dp); }
[ "public", "double", "regress", "(", "DataPoint", "dp", ")", "{", "TreeNodeVisitor", "node", "=", "this", ";", "while", "(", "!", "node", ".", "isLeaf", "(", ")", ")", "{", "int", "path", "=", "node", ".", "getPath", "(", "dp", ")", ";", "if", "(", ...
Performs regression on the given data point by following it down the tree until it finds the correct terminal node. @param dp the data point to regress @return the regression result from the tree starting from the current node
[ "Performs", "regression", "on", "the", "given", "data", "point", "by", "following", "it", "down", "the", "tree", "until", "it", "finds", "the", "correct", "terminal", "node", "." ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/trees/TreeNodeVisitor.java#L185-L216
train
EdwardRaff/JSAT
JSAT/src/jsat/utils/concurrent/AtomicDouble.java
AtomicDouble.updateAndGet
public final double updateAndGet(DoubleUnaryOperator updateFunction) { double prev, next; do { prev = get(); next = updateFunction.applyAsDouble(prev); } while (!compareAndSet(prev, next)); return next; }
java
public final double updateAndGet(DoubleUnaryOperator updateFunction) { double prev, next; do { prev = get(); next = updateFunction.applyAsDouble(prev); } while (!compareAndSet(prev, next)); return next; }
[ "public", "final", "double", "updateAndGet", "(", "DoubleUnaryOperator", "updateFunction", ")", "{", "double", "prev", ",", "next", ";", "do", "{", "prev", "=", "get", "(", ")", ";", "next", "=", "updateFunction", ".", "applyAsDouble", "(", "prev", ")", ";...
Atomically updates the current value with the results of applying the given function, returning the updated value. The function should be side-effect-free, since it may be re-applied when attempted updates fail due to contention among threads. @param updateFunction a side-effect-free function @return the updated value
[ "Atomically", "updates", "the", "current", "value", "with", "the", "results", "of", "applying", "the", "given", "function", "returning", "the", "updated", "value", ".", "The", "function", "should", "be", "side", "-", "effect", "-", "free", "since", "it", "ma...
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/utils/concurrent/AtomicDouble.java#L72-L82
train
EdwardRaff/JSAT
JSAT/src/jsat/utils/concurrent/AtomicDouble.java
AtomicDouble.getAndAccumulate
public final double getAndAccumulate(double x, DoubleBinaryOperator accumulatorFunction) { double prev, next; do { prev = get(); next = accumulatorFunction.applyAsDouble(prev, x); } while (!compareAndSet(prev, next)); return prev; }
java
public final double getAndAccumulate(double x, DoubleBinaryOperator accumulatorFunction) { double prev, next; do { prev = get(); next = accumulatorFunction.applyAsDouble(prev, x); } while (!compareAndSet(prev, next)); return prev; }
[ "public", "final", "double", "getAndAccumulate", "(", "double", "x", ",", "DoubleBinaryOperator", "accumulatorFunction", ")", "{", "double", "prev", ",", "next", ";", "do", "{", "prev", "=", "get", "(", ")", ";", "next", "=", "accumulatorFunction", ".", "app...
Atomically updates the current value with the results of applying the given function to the current and given values, returning the previous value. The function should be side-effect-free, since it may be re-applied when attempted updates fail due to contention among threads. The function is applied with the current value as its first argument, and the given update as the second argument. @param x the update value @param accumulatorFunction a side-effect-free function of two arguments @return the previous value
[ "Atomically", "updates", "the", "current", "value", "with", "the", "results", "of", "applying", "the", "given", "function", "to", "the", "current", "and", "given", "values", "returning", "the", "previous", "value", ".", "The", "function", "should", "be", "side...
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/utils/concurrent/AtomicDouble.java#L118-L128
train
EdwardRaff/JSAT
JSAT/src/jsat/text/stemming/Stemmer.java
Stemmer.applyTo
public void applyTo(List<String> list) { for(int i = 0; i < list.size(); i++) list.set(i, stem(list.get(i))); }
java
public void applyTo(List<String> list) { for(int i = 0; i < list.size(); i++) list.set(i, stem(list.get(i))); }
[ "public", "void", "applyTo", "(", "List", "<", "String", ">", "list", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "list", ".", "size", "(", ")", ";", "i", "++", ")", "list", ".", "set", "(", "i", ",", "stem", "(", "list", "."...
Replaces each value in the list with the stemmed version of the word @param list the list to apply stemming to
[ "Replaces", "each", "value", "in", "the", "list", "with", "the", "stemmed", "version", "of", "the", "word" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/text/stemming/Stemmer.java#L34-L38
train
EdwardRaff/JSAT
JSAT/src/jsat/text/stemming/Stemmer.java
Stemmer.applyTo
public void applyTo(String[] arr) { for(int i = 0; i < arr.length; i++) arr[i] = stem(arr[i]); }
java
public void applyTo(String[] arr) { for(int i = 0; i < arr.length; i++) arr[i] = stem(arr[i]); }
[ "public", "void", "applyTo", "(", "String", "[", "]", "arr", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "arr", ".", "length", ";", "i", "++", ")", "arr", "[", "i", "]", "=", "stem", "(", "arr", "[", "i", "]", ")", ";", "}"...
Replaces each value in the array with the stemmed version of the word @param arr the array to apply stemming to
[ "Replaces", "each", "value", "in", "the", "array", "with", "the", "stemmed", "version", "of", "the", "word" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/text/stemming/Stemmer.java#L44-L48
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/svm/PlattSMO.java
PlattSMO.updateSetsLabeled
private void updateSetsLabeled(int i1, final double a1, final double C) { final double y_i = label[i1]; I1[i1] = a1 == 0 && y_i == 1; I2[i1] = a1 == C && y_i == -1; I3[i1] = a1 == C && y_i == 1; I4[i1] = a1 == 0 && y_i == -1; }
java
private void updateSetsLabeled(int i1, final double a1, final double C) { final double y_i = label[i1]; I1[i1] = a1 == 0 && y_i == 1; I2[i1] = a1 == C && y_i == -1; I3[i1] = a1 == C && y_i == 1; I4[i1] = a1 == 0 && y_i == -1; }
[ "private", "void", "updateSetsLabeled", "(", "int", "i1", ",", "final", "double", "a1", ",", "final", "double", "C", ")", "{", "final", "double", "y_i", "=", "label", "[", "i1", "]", ";", "I1", "[", "i1", "]", "=", "a1", "==", "0", "&&", "y_i", "...
Updates the index sets @param i1 the index to update for @param a1 the alphas value for the index @param C the regularization value to use for this datum
[ "Updates", "the", "index", "sets" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/svm/PlattSMO.java#L469-L476
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/svm/PlattSMO.java
PlattSMO.updateThreshold
private void updateThreshold(int i) { double Fi = fcache[i]; double F_tilde_i = b_low; if (I0_b[i] || I2[i]) F_tilde_i = Fi + epsilon; else if (I0_a[i] || I1[i]) F_tilde_i = Fi - epsilon; double F_bar_i = b_up; if (I0_a[i] || I3[i]) F_bar_i = Fi - epsilon; else if (I0_b[i] || I1[i]) F_bar_i = Fi + epsilon; //update the bounds if (b_low < F_tilde_i) { b_low = F_tilde_i; i_low = i; } if (b_up > F_bar_i) { b_up = F_bar_i; i_up = i; } }
java
private void updateThreshold(int i) { double Fi = fcache[i]; double F_tilde_i = b_low; if (I0_b[i] || I2[i]) F_tilde_i = Fi + epsilon; else if (I0_a[i] || I1[i]) F_tilde_i = Fi - epsilon; double F_bar_i = b_up; if (I0_a[i] || I3[i]) F_bar_i = Fi - epsilon; else if (I0_b[i] || I1[i]) F_bar_i = Fi + epsilon; //update the bounds if (b_low < F_tilde_i) { b_low = F_tilde_i; i_low = i; } if (b_up > F_bar_i) { b_up = F_bar_i; i_up = i; } }
[ "private", "void", "updateThreshold", "(", "int", "i", ")", "{", "double", "Fi", "=", "fcache", "[", "i", "]", ";", "double", "F_tilde_i", "=", "b_low", ";", "if", "(", "I0_b", "[", "i", "]", "||", "I2", "[", "i", "]", ")", "F_tilde_i", "=", "Fi"...
Updates the threshold for regression based off of "using only i1, i2, and indices in I_0" @param i the index to update from that MUST have a value in {@link #fcache}
[ "Updates", "the", "threshold", "for", "regression", "based", "off", "of", "using", "only", "i1", "i2", "and", "indices", "in", "I_0" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/svm/PlattSMO.java#L822-L851
train
EdwardRaff/JSAT
JSAT/src/jsat/classifiers/svm/PlattSMO.java
PlattSMO.decisionFunction
protected double decisionFunction(int v) { double sum = 0; for(int i = 0; i < vecs.size(); i++) if(alphas[i] > 0) sum += alphas[i] * label[i] * kEval(v, i); return sum; }
java
protected double decisionFunction(int v) { double sum = 0; for(int i = 0; i < vecs.size(); i++) if(alphas[i] > 0) sum += alphas[i] * label[i] * kEval(v, i); return sum; }
[ "protected", "double", "decisionFunction", "(", "int", "v", ")", "{", "double", "sum", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "vecs", ".", "size", "(", ")", ";", "i", "++", ")", "if", "(", "alphas", "[", "i", "]", ">"...
Returns the local decision function for classification training purposes without the bias term @param v the index of the point to select @return the decision function output sans bias
[ "Returns", "the", "local", "decision", "function", "for", "classification", "training", "purposes", "without", "the", "bias", "term" ]
0ff53b7b39684b2379cc1da522f5b3a954b15cfb
https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/svm/PlattSMO.java#L1047-L1055
train