_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q22900 | PCA9685GpioProvider.calculateOffPositionForPulseDuration | train | public int calculateOffPositionForPulseDuration(int duration) {
validatePwmDuration(duration);
int result = (PWM_STEPS - 1) * duration / periodDurationMicros;
if (result < 1) {
result = 1;
} else if (result > PWM_STEPS - 1) {
result = PWM_STEPS - 1;
}
... | java | {
"resource": ""
} |
q22901 | I2CFactory.getInstance | train | public static I2CBus getInstance(int busNumber, long lockAquireTimeout, TimeUnit lockAquireTimeoutUnit) throws UnsupportedBusNumberException, IOException {
return provider.getBus(busNumber, lockAquireTimeout, lockAquireTimeoutUnit);
} | java | {
"resource": ""
} |
q22902 | I2CFactory.getBusIds | train | public static int[] getBusIds() throws IOException {
Set<Integer> set = null;
for (Path device: Files.newDirectoryStream(Paths.get("/sys/bus/i2c/devices"), "*")) {
String[] tokens = device.toString().split("-");
if (tokens.length == 2) {
if (set == null) {
... | java | {
"resource": ""
} |
q22903 | SerialImpl.close | train | @Override
public void close() throws IllegalStateException, IOException {
// validate state
if (isClosed())
throw new IllegalStateException("Serial connection is not open; cannot 'close()'.");
// remove serial port listener
SerialInterrupt.removeListener(fileDescriptor);
... | java | {
"resource": ""
} |
q22904 | WDTimerImpl.open | train | public void open(String file) throws IOException {
filename = file;
if(fd>0) {
throw new IOException("File "+filename+" already open.");
}
fd = WDT.open(file);
if(fd<0) {
throw new IOException("Cannot open file handle for " + fi... | java | {
"resource": ""
} |
q22905 | WDTimerImpl.setTimeOut | train | @Override
public void setTimeOut(int timeout) throws IOException {
isOpen();
int ret = WDT.setTimeOut(fd, timeout);
if(ret<0) {
throw new IOException("Cannot set timeout for " + filename + " got " + ret + " back.");
}
} | java | {
"resource": ""
} |
q22906 | WDTimerImpl.heartbeat | train | @Override
public void heartbeat() throws IOException {
isOpen();
int ret = WDT.ping(fd);
if(ret<0) {
throw new IOException("Heartbeat error. File " + filename + " got " + ret + " back.");
}
} | java | {
"resource": ""
} |
q22907 | WDTimerImpl.disable | train | @Override
public void disable() throws IOException {
isOpen();
int ret = WDT.disable(fd);
if(ret<0) {
throw new IOException("Cannot disable WatchDog. File " + filename + " got " + ret + " back.");
}
} | java | {
"resource": ""
} |
q22908 | DefaultExecutorServiceFactory.getThreadFactory | train | private static ThreadFactory getThreadFactory(final String nameFormat) {
final ThreadFactory defaultThreadFactory = Executors.privilegedThreadFactory();
return new ThreadFactory() {
final AtomicLong count = (nameFormat != null) ? new AtomicLong(0) : null;
@Override
p... | java | {
"resource": ""
} |
q22909 | DefaultExecutorServiceFactory.newSingleThreadExecutorService | train | @Override
public ExecutorService newSingleThreadExecutorService() {
// create new single thread executor service
ExecutorService singleThreadExecutorService = Executors.newSingleThreadExecutor(getThreadFactory("pi4j-single-executor-%d"));
// add new instance to managed collection
s... | java | {
"resource": ""
} |
q22910 | DefaultExecutorServiceFactory.shutdown | train | public void shutdown() {
// shutdown each single thread executor in the managed collection
for (ExecutorService singleThreadExecutorService : singleThreadExecutorServices) {
shutdownExecutor(singleThreadExecutorService);
}
// shutdown scheduled executor instance
shut... | java | {
"resource": ""
} |
q22911 | PibrellaExample.main | train | public static void main(String args[]) throws InterruptedException, IOException {
System.out.println("<--Pi4J--> Pibrella Example ... started.");
// -----------------------------------------------------------------
// create a button listener
// ----------------------------------------... | java | {
"resource": ""
} |
q22912 | CharacteristicVector.updateGridDensity | train | public void updateGridDensity(int currTime, double decayFactor, double dl, double dm)
{
// record the last attribute
int lastAtt = this.getAttribute();
// Update the density grid's density
double densityOfG = (Math.pow(decayFactor, (currTime-this.getDensityTimeStamp())) * this.getGridDensity());
this.setGr... | java | {
"resource": ""
} |
q22913 | SamoaToWekaInstanceConverter.wekaInstance | train | public weka.core.Instance wekaInstance(Instance inst) {
weka.core.Instance wekaInstance;
if (((InstanceImpl) inst).instanceData instanceof SparseInstanceData) {
InstanceImpl instance = (InstanceImpl) inst;
SparseInstanceData sparseInstanceData = (SparseInstanceData) instance.inst... | java | {
"resource": ""
} |
q22914 | SamoaToWekaInstanceConverter.wekaInstances | train | public weka.core.Instances wekaInstances(Instances instances) {
weka.core.Instances wekaInstances = wekaInstancesInformation(instances);
//We assume that we have only one WekaInstanceInformation for SamoaToWekaInstanceConverter
this.wekaInstanceInformation = wekaInstances;
for (int i = 0... | java | {
"resource": ""
} |
q22915 | SamoaToWekaInstanceConverter.wekaInstancesInformation | train | public weka.core.Instances wekaInstancesInformation(Instances instances) {
weka.core.Instances wekaInstances;
ArrayList<weka.core.Attribute> attInfo = new ArrayList<weka.core.Attribute>();
for (int i = 0; i < instances.numAttributes(); i++) {
attInfo.add(wekaAttribute(i, instances.at... | java | {
"resource": ""
} |
q22916 | SamoaToWekaInstanceConverter.wekaAttribute | train | protected weka.core.Attribute wekaAttribute(int index, Attribute attribute) {
weka.core.Attribute wekaAttribute;
if (attribute.isNominal()) {
wekaAttribute = new weka.core.Attribute(attribute.name(), attribute.getAttributeValues(), index);
} else {
wekaAttribut... | java | {
"resource": ""
} |
q22917 | AbstractGraphPlot.setGraph | train | protected void setGraph(MeasureCollection[] measures, MeasureCollection[] stds, Color[] colors) {
this.measures = measures;
this.measureStds = stds;
this.colors = colors;
repaint();
} | java | {
"resource": ""
} |
q22918 | AbstractClassOption.stripPackagePrefix | train | public static String stripPackagePrefix(String className, Class<?> expectedType) {
if (className.startsWith(expectedType.getPackage().getName())) {
return className.substring(expectedType.getPackage().getName().length() + 1);
}
return className;
} | java | {
"resource": ""
} |
q22919 | EMProjectedClustering.getEMClusteringVariances | train | public int[][] getEMClusteringVariances(double[][] pointArray, int k) {
// initialize field and clustering
initFields(pointArray, k);
setInitialPartitions(pointArray, k);
// iterate M and E
double currentExpectation, newExpectation = 0.0;
double expectationDeviation;
int count = 0;
do{
c... | java | {
"resource": ""
} |
q22920 | EMProjectedClustering.setInitialPartitions | train | private void setInitialPartitions(double[][] pointArray, int k) {
if (pointArray.length < k) {
System.err.println("cannot cluster less than k points into k clusters...");
System.exit(0);
}
// select randomly k initial means
// TODO: choose more stable initialization (comment: this is run several... | java | {
"resource": ""
} |
q22921 | ALWindowClassificationPerformanceEvaluator.doLabelAcqReport | train | @Override
public void doLabelAcqReport(Example<Instance> trainInst, int labelAcquired) {
this.acquisitionRateEstimator.add(labelAcquired);
this.acquiredInstances += labelAcquired;
} | java | {
"resource": ""
} |
q22922 | Utils.removeSubstring | train | public static String removeSubstring(String inString, String substring) {
StringBuffer result = new StringBuffer();
int oldLoc = 0, loc = 0;
while ((loc = inString.indexOf(substring, oldLoc))!= -1) {
result.append(inString.substring(oldLoc, loc));
oldLoc = loc + substring.length();
}
re... | java | {
"resource": ""
} |
q22923 | Utils.replaceSubstring | train | public static String replaceSubstring(String inString, String subString,
String replaceString) {
StringBuffer result = new StringBuffer();
int oldLoc = 0, loc = 0;
while ((loc = inString.indexOf(subString, oldLoc))!= -1) {
result.append(inString.substring(oldLoc, loc));
result.append(repla... | java | {
"resource": ""
} |
q22924 | Utils.doubleToString | train | public static /*@pure@*/ String doubleToString(double value, int afterDecimalPoint) {
StringBuffer stringBuffer;
double temp;
int dotPosition;
long precisionValue;
temp = value * Math.pow(10.0, afterDecimalPoint);
if (Math.abs(temp) < Long.MAX_VALUE) {
precisionValue = (temp > 0... | java | {
"resource": ""
} |
q22925 | Utils.doubleToString | train | public static /*@pure@*/ String doubleToString(double value, int width,
int afterDecimalPoint) {
String tempString = doubleToString(value, afterDecimalPoint);
char[] result;
int dotPosition;
if ((afterDecimalPoint >= width)
|| (tempString.indexOf('E') != -1)) { // Protects sci n... | java | {
"resource": ""
} |
q22926 | Utils.checkForRemainingOptions | train | public static void checkForRemainingOptions(String[] options)
throws Exception {
int illegalOptionsFound = 0;
StringBuffer text = new StringBuffer();
if (options == null) {
return;
}
for (int i = 0; i < options.length; i++) {
if (options[i].length() > 0) {
illegalOptionsFound... | java | {
"resource": ""
} |
q22927 | Utils.convertNewLines | train | public static String convertNewLines(String string) {
int index;
// Replace with \n
StringBuffer newStringBuffer = new StringBuffer();
while ((index = string.indexOf('\n')) != -1) {
if (index > 0) {
newStringBuffer.append(string.substring(0, index));
}
newStringBuffer.append('\\');
... | java | {
"resource": ""
} |
q22928 | Utils.splitOptions | train | public static String[] splitOptions(String quotedOptionString) throws Exception{
Vector<String> optionsVec = new Vector<String>();
String str = new String(quotedOptionString);
int i;
while (true){
//trimLeft
i = 0;
while ((i < str.length()) && (Character.isWhitespace(str.charAt... | java | {
"resource": ""
} |
q22929 | Utils.joinOptions | train | public static String joinOptions(String[] optionArray) {
String optionString = "";
for (int i = 0; i < optionArray.length; i++) {
if (optionArray[i].equals("")) {
continue;
}
boolean escape = false;
for (int n = 0; n < optionArray[i].length(); n++) {
if (Character.isWhitespace(optionA... | java | {
"resource": ""
} |
q22930 | Utils.info | train | public static /*@pure@*/ double info(int counts[]) {
int total = 0;
double x = 0;
for (int j = 0; j < counts.length; j++) {
x -= xlogx(counts[j]);
total += counts[j];
}
return x + xlogx(total);
} | java | {
"resource": ""
} |
q22931 | Utils.kthSmallestValue | train | public static double kthSmallestValue(int[] array, int k) {
int[] index = new int[array.length];
for (int i = 0; i < index.length; i++) {
index[i] = i;
}
return array[index[select(array, index, 0, array.length - 1, k)]];
} | java | {
"resource": ""
} |
q22932 | Utils.maxIndex | train | public static /*@pure@*/ int maxIndex(int[] ints) {
int maximum = 0;
int maxIndex = 0;
for (int i = 0; i < ints.length; i++) {
if ((i == 0) || (ints[i] > maximum)) {
maxIndex = i;
maximum = ints[i];
}
}
return maxIndex;
} | java | {
"resource": ""
} |
q22933 | Utils.mean | train | public static /*@pure@*/ double mean(double[] vector) {
double sum = 0;
if (vector.length == 0) {
return 0;
}
for (int i = 0; i < vector.length; i++) {
sum += vector[i];
}
return sum / (double) vector.length;
} | java | {
"resource": ""
} |
q22934 | Utils.minIndex | train | public static /*@pure@*/ int minIndex(int[] ints) {
int minimum = 0;
int minIndex = 0;
for (int i = 0; i < ints.length; i++) {
if ((i == 0) || (ints[i] < minimum)) {
minIndex = i;
minimum = ints[i];
}
}
return minIndex;
} | java | {
"resource": ""
} |
q22935 | Utils.minIndex | train | public static /*@pure@*/ int minIndex(double[] doubles) {
double minimum = 0;
int minIndex = 0;
for (int i = 0; i < doubles.length; i++) {
if ((i == 0) || (doubles[i] < minimum)) {
minIndex = i;
minimum = doubles[i];
}
}
return minIndex;
} | java | {
"resource": ""
} |
q22936 | Utils.normalize | train | public static void normalize(double[] doubles) {
double sum = 0;
for (int i = 0; i < doubles.length; i++) {
sum += doubles[i];
}
normalize(doubles, sum);
} | java | {
"resource": ""
} |
q22937 | Utils.normalize | train | public static void normalize(double[] doubles, double sum) {
if (Double.isNaN(sum)) {
throw new IllegalArgumentException("Can't normalize array. Sum is NaN.");
}
if (sum == 0) {
// Maybe this should just be a return.
throw new IllegalArgumentException("Can't normalize array. Sum is zero."... | java | {
"resource": ""
} |
q22938 | Utils.logs2probs | train | public static double[] logs2probs(double[] a) {
double max = a[maxIndex(a)];
double sum = 0.0;
double[] result = new double[a.length];
for(int i = 0; i < a.length; i++) {
result[i] = Math.exp(a[i] - max);
sum += result[i];
}
normalize(result, sum);
return result;
} | java | {
"resource": ""
} |
q22939 | Utils.probToLogOdds | train | public static /*@pure@*/ double probToLogOdds(double prob) {
if (gr(prob, 1) || (sm(prob, 0))) {
throw new IllegalArgumentException("probToLogOdds: probability must " +
"be in [0,1] "+prob);
}
double p = SMALL + (1.0 - 2 * SMALL) * prob;
return Math.log(p / (1 - p));
} | java | {
"resource": ""
} |
q22940 | Utils.roundDouble | train | public static /*@pure@*/ double roundDouble(double value,int afterDecimalPoint) {
double mask = Math.pow(10.0, (double)afterDecimalPoint);
return (double)(Math.round(value * mask)) / mask;
} | java | {
"resource": ""
} |
q22941 | Utils.variance | train | public static /*@pure@*/ double variance(double[] vector) {
double sum = 0, sumSquared = 0;
if (vector.length <= 1) {
return 0;
}
for (int i = 0; i < vector.length; i++) {
sum += vector[i];
sumSquared += (vector[i] * vector[i]);
}
double result = (sumSquared - (sum * sum / ... | java | {
"resource": ""
} |
q22942 | Utils.sum | train | public static /*@pure@*/ int sum(int[] ints) {
int sum = 0;
for (int i = 0; i < ints.length; i++) {
sum += ints[i];
}
return sum;
} | java | {
"resource": ""
} |
q22943 | Utils.quickSort | train | private static void quickSort(/*@non_null@*/ double[] array, /*@non_null@*/ int[] index,
int left, int right) {
if (left < right) {
int middle = partition(array, index, left, right);
quickSort(array, index, left, middle);
quickSort(array, index, middle + 1, right)... | java | {
"resource": ""
} |
q22944 | Utils.breakUp | train | public static String[] breakUp(String s, int columns) {
Vector<String> result;
String line;
BreakIterator boundary;
int boundaryStart;
int boundaryEnd;
String word;
String punctuation;
int i;
String[] lines;
result = new Vector<String>();
punctuation = " .,;:!... | java | {
"resource": ""
} |
q22945 | CapabilityRequirement.isMetBy | train | public boolean isMetBy(Class<?> klass) {
// Classes which aren't capabilities handlers have an assumed
// set of capabilities
if (!CapabilitiesHandler.class.isAssignableFrom(klass))
return isMetBy(NON_HANDLER_CAPABILITIES);
// Attempt to instantiate an instance of the class
CapabilitiesHandle... | java | {
"resource": ""
} |
q22946 | CapabilityRequirement.hasAll | train | public static CapabilityRequirement hasAll(Capability... capabilities) {
return new CapabilityRequirement(c -> {
for (Capability capability : capabilities) {
if (!c.hasCapability(capability))
return false;
}
return true;
});
} | java | {
"resource": ""
} |
q22947 | GraphMultiCurve.setGraph | train | protected void setGraph(MeasureCollection[] measures, MeasureCollection[] measureStds, int[] processFrequencies, Color[] colors){
// this.processFrequencies = processFrequencies;
super.setGraph(measures, measureStds, colors);
} | java | {
"resource": ""
} |
q22948 | GraphMultiCurve.paintFullCurve | train | private void paintFullCurve(Graphics g, int i){
if (this.measures[i].getNumberOfValues(this.measureSelected) == 0) {
// no values of this measure available
return;
}
g.setColor(this.colors[i]);
int height = getHeight();
// // compute ... | java | {
"resource": ""
} |
q22949 | Measure.computeValue | train | public void computeValue(DoubleVector values) {
if (this.isType()) {
setValues(values);
double sumDif = 0.0;
this.value = this.values.sumOfValues() / (double) values.numValues();
for (int i = 0; i < this.values.numValues(); i++) {
double dif = this... | java | {
"resource": ""
} |
q22950 | AbstractGraphAxes.xAxis | train | protected void xAxis(Graphics g) {
g.setColor(Color.BLACK);
// x-axis line
g.drawLine(X_OFFSET_LEFT, calcY(0), width + X_OFFSET_LEFT, calcY(0));
drawXLabels(g);
} | java | {
"resource": ""
} |
q22951 | AbstractGraphAxes.yAxis | train | private void yAxis(Graphics g) {
// y-axis
g.setColor(Color.BLACK);
g.drawLine(X_OFFSET_LEFT, calcY(0), X_OFFSET_LEFT, Y_OFFSET_TOP);
// center horizontal line
g.setColor(new Color(220, 220, 220));
g.drawLine(X_OFFSET_LEFT, height / 2 + Y_OFFSET_TOP, getWidth(),
... | java | {
"resource": ""
} |
q22952 | MeanPreviewCollection.constructMeanStdPreviewsForParam | train | private void constructMeanStdPreviewsForParam(
int numEntriesPerPreview,
int numParamValues,
int paramValue)
{
// calculate mean
List<double[]> meanParamMeasurements = calculateMeanMeasurementsForParam(
numEntriesPerPreview, numParamValues, para... | java | {
"resource": ""
} |
q22953 | MeanPreviewCollection.calculateMeanMeasurementsForParam | train | private List<double[]> calculateMeanMeasurementsForParam(
int numEntriesPerPreview,
int numParamValues,
int paramValue)
{
List<double[]> paramMeasurementsSum =
new ArrayList<double[]>(numEntriesPerPreview);
List<double[]> meanParamMeasurements =... | java | {
"resource": ""
} |
q22954 | MeanPreviewCollection.calculateStdMeasurementsForParam | train | private List<double[]> calculateStdMeasurementsForParam(
int numEntriesPerPreview,
int numParamValues,
int paramValue,
List<double[]> meanParamMeasurements)
{
List<double[]> paramMeasurementsSquaredDiffSum =
ne... | java | {
"resource": ""
} |
q22955 | MeanPreviewCollection.addPreviewMeasurementsToSum | train | private void addPreviewMeasurementsToSum(
List<double[]> measurementsSum,
Preview preview,
int numEntriesPerPreview)
{
List<double[]> previewMeasurements = preview.getData();
// add values for each measurement in each entry
fo... | java | {
"resource": ""
} |
q22956 | MeanPreviewCollection.addPreviewMeasurementSquaredDiffsToSum | train | private void addPreviewMeasurementSquaredDiffsToSum(
List<double[]> meanMeasurements,
List<double[]> measurementsSquaredDiffSum,
Preview preview,
int numEntriesPerPreview)
{
List<double[]> previewMeasurements = preview.getData();
... | java | {
"resource": ""
} |
q22957 | NaiveBayes.doNaiveBayesPredictionLog | train | public static double[] doNaiveBayesPredictionLog(Instance inst,
DoubleVector observedClassDistribution,
AutoExpandVector<AttributeClassObserver> observers, AutoExpandVector<AttributeClassObserver> observers2) {
AttributeClassObserver obs;
double[] votes = new double[observedClass... | java | {
"resource": ""
} |
q22958 | MetaMultilabelGenerator.generatePriors | train | private double[] generatePriors(Random r, int L, double z, boolean skew) {
double P[] = new double[L];
for (int i = 0; i < L; i++) {
P[i] = r.nextDouble();
//P[i] = 1.0; // @temp
}
// normalise to z
do {
double c = Utils.sum(P) / z;
... | java | {
"resource": ""
} |
q22959 | MetaMultilabelGenerator.generateSet | train | private HashSet generateSet() {
int y[] = new int[m_L]; // [0,0,0]
int k = samplePMF(priors_norm); // k = 1 // y[k] ~ p(k==1)
y[k] = 1; // [0,1,0]
ArrayList<Integer> indices = getShuffledListToLWithoutK(m_L, k);
for (int j : indices) {
//y[j] ~ p(j==1|... | java | {
"resource": ""
} |
q22960 | MetaMultilabelGenerator.modifyPriorVector | train | protected double[] modifyPriorVector(double P[], double u, Random r, boolean skew) {
for (int j = 0; j < P.length; j++) {
if (r.nextDouble() < u) {
P[j] = r.nextDouble();
}
}
return P;
} | java | {
"resource": ""
} |
q22961 | MetaMultilabelGenerator.getTopCombinations | train | private HashSet[] getTopCombinations(int n) {
final HashMap<HashSet, Integer> count = new HashMap<HashSet, Integer>();
HashMap<HashSet, Integer> isets = new HashMap<HashSet, Integer>();
int N = 100000;
double lc = 0.0;
for (int i = 0; i < N; i++) {
HashSet Y = gener... | java | {
"resource": ""
} |
q22962 | MetaMultilabelGenerator.set2vector | train | private int[] set2vector(HashSet<Integer> Y, int L) {
int y[] = new int[L];
for (int j : Y) {
y[j] = 1;
}
return y;
} | java | {
"resource": ""
} |
q22963 | MetaMultilabelGenerator.vector2set | train | private HashSet<Integer> vector2set(int y[]) {
HashSet<Integer> Y = new HashSet<Integer>();
for (int j = 0; j < y.length; j++) {
if (y[j] > 0) {
Y.add(j);
}
}
return Y;
} | java | {
"resource": ""
} |
q22964 | JavaCLIParser.discoverOptionsViaReflection | train | public Option[] discoverOptionsViaReflection() {
//Class<? extends AbstractOptionHandler> c = this.getClass();
Class c = this.handler.getClass();
Field[] fields = c.getFields();
List<Option> optList = new LinkedList<Option>();
for (Field field : fields) {
String fName... | java | {
"resource": ""
} |
q22965 | LinearNNSearch.kNearestNeighbours | train | public Instances kNearestNeighbours(Instance target, int kNN) throws Exception {
//debug
boolean print=false;
MyHeap heap = new MyHeap(kNN);
double distance; int firstkNN=0;
for(int i=0; i<m_Instances.numInstances(); i++) {
if(target == m_Instances.instance(i)) //for hold-one-out cross-va... | java | {
"resource": ""
} |
q22966 | LinearNNSearch.update | train | public void update(Instance ins) throws Exception {
if(m_Instances==null)
throw new Exception("No instances supplied yet. Cannot update without"+
"supplying a set of instances first.");
m_DistanceFunction.update(ins);
} | java | {
"resource": ""
} |
q22967 | LinearNNSearch.addInstanceInfo | train | public void addInstanceInfo(Instance ins) {
if(m_Instances!=null)
try{ update(ins); }
catch(Exception ex) { ex.printStackTrace(); }
} | java | {
"resource": ""
} |
q22968 | AbstractOption.nameIsLegal | train | public static boolean nameIsLegal(String optionName) {
for (char illegalChar : illegalNameCharacters) {
if (optionName.indexOf(illegalChar) >= 0) {
return false;
}
}
return true;
} | java | {
"resource": ""
} |
q22969 | ProcessGraphCanvas.setGraph | train | public void setGraph(MeasureCollection[] measures, MeasureCollection[] measureStds, int[] processFrequencies, int min_processFrequency,
Color[] colors) {
this.measures = measures;
this.processFrequencies = processFrequencies;
this.min_processFrequency = min_processFrequency;
((ProcessGraphAxes) this.axesPane... | java | {
"resource": ""
} |
q22970 | MidPointOfWidestDimension.splitNode | train | public void splitNode(KDTreeNode node, int numNodesCreated,
double[][] nodeRanges, double[][] universe) throws Exception {
correctlyInitialized();
int splitDim = widestDim(nodeRanges, universe);
double splitVal = m_EuclideanDistance.getMiddle(nodeRanges[splitDim]);
int rightStart = rea... | java | {
"resource": ""
} |
q22971 | ADACC.computeStabilityIndex | train | private double computeStabilityIndex(){
int m = (int)Math.floor((this.ensemble.length-MAXPERMANENT)/2);
int[][] votes=new int[m][tau_size];
double errors=0;
int count=0;
Pair[] arr = getHalf(true);
for (int i=0;i<m;i++){
for (int j=0;j<tau_size;j++){
vote... | java | {
"resource": ""
} |
q22972 | ADACC.getBestAdaptiveClassifier | train | private Classifier getBestAdaptiveClassifier(){
//take a copy of the ensemble weights (excluding snapshots)
Pair[] newEnsembleWeights = new Pair[ensembleWeights.length-MAXPERMANENT];
for (int i = 0 ; i < newEnsembleWeights.length; i++)
newEnsembleWeights[i]=ensembleWeights[i];
//sort the weight ... | java | {
"resource": ""
} |
q22973 | AbstractGraphCanvas.scaleYResolution | train | public void scaleYResolution(double factor) {
this.y_resolution = Math.max(1.0, this.y_resolution * factor);
updateYResolution();
updateUpperYValue();
updateCanvas(true);
} | java | {
"resource": ""
} |
q22974 | AbstractGraphCanvas.getMaxSelectedValue | train | private double getMaxSelectedValue() {
double max = Double.MIN_VALUE;
for (int i = 0; i < this.measures.length; i++) {
if (this.measures[i].getMaxValue(this.measureSelected) > max) {
max = this.measures[i].getMaxValue(this.measureSelected);
}
}
re... | java | {
"resource": ""
} |
q22975 | AbstractGraphCanvas.updateMinMaxValues | train | private boolean updateMinMaxValues() {
double min_x_value_new;
double max_x_value_new;
double max_y_value_new;
if (this.measures == null) {
// no values received yet -> reset axes
min_x_value_new = 0;
max_x_value_new = 1;
max_y_value_new ... | java | {
"resource": ""
} |
q22976 | AbstractGraphCanvas.updateLowerXValue | train | private void updateLowerXValue() {
double lower = 0.0;
if (this.measures != null) {
lower = this.min_x_value * (1 - (0.1 / x_resolution));
}
this.axesPanel.setLowerXValue(lower);
this.plotPanel.setLowerXValue(lower);
} | java | {
"resource": ""
} |
q22977 | AbstractGraphCanvas.updateUpperXValue | train | private void updateUpperXValue() {
double upper = 1.0;
if (this.measures != null) {
upper = max_x_value * (1 + (0.1 / x_resolution));
}
this.axesPanel.setUpperXValue(upper);
this.plotPanel.setUpperXValue(upper);
} | java | {
"resource": ""
} |
q22978 | AbstractGraphCanvas.updateUpperYValue | train | private void updateUpperYValue() {
double upper = 1.0;
if (this.measures != null) {
upper = max_y_value * (1 + (0.1 / y_resolution));
}
this.axesPanel.setUpperYValue(upper);
this.plotPanel.setUpperYValue(upper);
} | java | {
"resource": ""
} |
q22979 | AbstractGraphCanvas.updateChildren | train | private void updateChildren() {
axesPanel.setSize(getWidth(), getHeight());
plotPanel.setSize(getWidth() - X_OFFSET_LEFT - X_OFFSET_RIGHT,
getHeight() - Y_OFFSET_BOTTOM - Y_OFFSET_TOP);
} | java | {
"resource": ""
} |
q22980 | EditableMultiChoiceOption.setOptions | train | public void setOptions(
String[] labels, String[] descriptions, int defaultIndex)
{
if (labels.length != descriptions.length) {
throw new IllegalArgumentException("Labels/descriptions mismatch.");
}
if (labels.length > 0) {
this.optionLabels = labels.clone();
this.optionDescription... | java | {
"resource": ""
} |
q22981 | CuckooHashing.put | train | public void put(long key, T element) {
Entry<T> entry = new Entry<T>(key, element);
elements.add(entry);
this.numElements++;
fileElement(entry, true);
} | java | {
"resource": ""
} |
q22982 | CuckooHashing.fileElement | train | private void fileElement(Entry<T> currentElement, boolean rehash) {
int maxFailures = Math.max((int) Math.log(this.numElements),
this.numTables * 2);
int currentTable = 0;
for (int i = 0; i < maxFailures; i++) {
int hash = this.hashfunctions.get(currentTable).hash(
currentElement.getKey());
current... | java | {
"resource": ""
} |
q22983 | CuckooHashing.increaseAndReset | train | private void increaseAndReset() {
if (this.hashSize < 30) {
this.hashSize += 1;
this.hashfunctions.clear();
for (List<Entry<T>> table : this.tables) {
this.hashfunctions.add(new DietzfelbingerHash(this.hashSize,
this.random));
((ArrayList<Entry<T>>) table)
.ensureCapacity(1 << this.hashSi... | java | {
"resource": ""
} |
q22984 | CuckooHashing.get | train | public T get(long key) {
for (int i = 0; i < this.numTables; i++) {
Entry<T> entry = this.tables.get(i).get(
this.hashfunctions.get(i).hash(key));
if (entry != null && entry.getKey() == key) {
return entry.getValue();
}
}
for (Entry<T> entry : this.stash) {
if (entry.getKey() == key) {
re... | java | {
"resource": ""
} |
q22985 | CuckooHashing.reset | train | private void reset() {
for (DietzfelbingerHash hashfunction : this.hashfunctions) {
hashfunction.nextHashFunction();
}
int sizeTables = 1 << this.hashSize;
for (List<Entry<T>> table : this.tables) {
table.clear();
for (int j = 0; j < sizeTables; j++) {
table.add(null);
}
}
this.stash.clear... | java | {
"resource": ""
} |
q22986 | CuckooHashing.clear | train | public void clear() {
this.hashSize = this.startHashSize;
this.numTables = this.startNumTables;
this.numElements = 0;
this.hashfunctions.clear();
this.tables.clear();
int sizeTables = 1 << this.startHashSize;
for (int i = 0; i < this.startNumTables; i++) {
this.hashfunctions.add(new DietzfelbingerHash... | java | {
"resource": ""
} |
q22987 | MedianOfWidestDimension.splitNode | train | public void splitNode(KDTreeNode node, int numNodesCreated,
double[][] nodeRanges, double[][] universe) throws Exception {
correctlyInitialized();
int splitDim = widestDim(nodeRanges, universe);
//In this case median is defined to be either the middle value (in case of
//odd num... | java | {
"resource": ""
} |
q22988 | MedianOfWidestDimension.select | train | public int select(int attIdx, int[] indices, int left, int right, int k) {
if (left == right) {
return left;
} else {
int middle = partition(attIdx, indices, left, right);
if ((middle - left + 1) >= k) {
return select(attIdx, indices, left, middle, k);
} else {
retur... | java | {
"resource": ""
} |
q22989 | Instances.deleteAttributeAt | train | public void deleteAttributeAt(Integer integer) {
this.instanceInformation.deleteAttributeAt(integer);
for (int i = 0; i < numInstances(); i++) {
instance(i).setDataset(null);
instance(i).deleteAttributeAt(integer);
instance(i).setDataset(this);
}
} | java | {
"resource": ""
} |
q22990 | Instances.insertAttributeAt | train | public void insertAttributeAt(Attribute attribute, int position) {
if (this.instanceInformation == null) {
this.instanceInformation = new InstanceInformation();
}
this.instanceInformation.insertAttributeAt(attribute, position);
for (int i = 0; i < numInstances(); i++) {
... | java | {
"resource": ""
} |
q22991 | Instances.trainCV | train | public Instances trainCV(int numFolds, int numFold, Random random) {
Instances train = trainCV(numFolds, numFold);
train.randomize(random);
return train;
} | java | {
"resource": ""
} |
q22992 | Instances.readInstance | train | public boolean readInstance(Reader fileReader) {
//ArffReader arff = new ArffReader(reader, this, m_Lines, 1);
Instance inst = arff.readInstance();
if (inst != null) {
inst.setDataset(this);
add(inst);
return true;
} else {
return false;
... | java | {
"resource": ""
} |
q22993 | Instances.stringWithoutHeader | train | protected String stringWithoutHeader() {
StringBuffer text = new StringBuffer();
for (int i = 0; i < numInstances(); i++) {
text.append(instance(i));
if (i < numInstances() - 1) {
text.append('\n');
}
}
return text.toString();
} | java | {
"resource": ""
} |
q22994 | Instances.computeAttributesIndices | train | private void computeAttributesIndices() {
this.hsAttributesIndices = new HashMap<String, Integer>();
// iterates through all existing attributes
// and sets an unique identifier for each one of them
for (int i = 0; i < this.numAttributes(); i++) {
hsAttributesIndices.put(thi... | java | {
"resource": ""
} |
q22995 | Instances.setIndicesRelevants | train | public void setIndicesRelevants(int[] indicesRelevants) {
this.indicesRelevants = indicesRelevants;
// -1 to skip the class attribute
int numIrrelevantFeatures = this.numAttributes() - this.indicesRelevants.length - 1;
this.indicesIrrelevants = new int[numIrrelevantFeatures];
//... | java | {
"resource": ""
} |
q22996 | SphereCluster.sample | train | public Instance sample(Random random) {
// Create sample in hypersphere coordinates
//get the center through getCenter so subclass have a chance
double[] center = getCenter();
final int dimensions = center.length;
final double sin[] = new double[dimensions - 1];
final double cos[] = new double[dimensions ... | java | {
"resource": ""
} |
q22997 | CoresetKMeans.generatekMeansPlusPlusCentroids | train | public static List<double[]> generatekMeansPlusPlusCentroids(int k,
List<double[]> input, Random random) {
int n = input.size();
assert (n > 0);
int d = input.get(0).length - 1;
assert (k <= n);
List<double[]> centerValue = new ArrayList<double[]>(k);
// Selects and copies the first centroid
double[] ... | java | {
"resource": ""
} |
q22998 | Node.isLeaf | train | protected boolean isLeaf() {
for (int i = 0; i < entries.length; i++) {
Entry entry = entries[i];
if (entry.getChild() != null) {
return false;
}
}
return true;
} | java | {
"resource": ""
} |
q22999 | Node.getNextEmptyPosition | train | private int getNextEmptyPosition(){
int counter;
for (counter = 0; counter < entries.length; counter++) {
Entry e = entries[counter];
if (e.isEmpty()) {
break;
}
}
if (counter == entries.length) {
throw new RuntimeException... | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.