code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
protected void keepTopFeatures(Map<Object, Double> featureScores, int maxFeatures) {
logger.debug("keepTopFeatures()");
logger.debug("Estimating the minPermittedScore");
Double minPermittedScore = SelectKth.largest(featureScores.values().iterator(), maxFeatures);
//remove any entry wit... | java |
protected void removeRareFeatures(Map<Object, Double> featureCounts, int rareFeatureThreshold) {
logger.debug("removeRareFeatures()");
Iterator<Map.Entry<Object, Double>> it = featureCounts.entrySet().iterator();
while(it.hasNext()) {
Map.Entry<Object, Double> entry = it.next();
... | java |
public static TransposeDataCollection weightedProbabilitySampling(AssociativeArray2D strataFrequencyTable, AssociativeArray nh, boolean withReplacement) {
TransposeDataCollection sampledIds = new TransposeDataCollection();
for(Map.Entry<Object, AssociativeArray> entry : strataFrequencyTable.entryS... | java |
public static TransposeDataCollection randomSampling(TransposeDataList strataIdList, AssociativeArray nh, boolean withReplacement) {
TransposeDataCollection sampledIds = new TransposeDataCollection();
for(Map.Entry<Object, FlatDataList> entry : strataIdList.entrySet()) {
Object strata =... | java |
public static double variance(TransposeDataCollection sampleDataCollection, AssociativeArray populationNh) {
double variance = 0.0;
int populationN = 0;
double mean = mean(sampleDataCollection, populationNh);
for(Map.Entry<Object, FlatDataCollection> entry : sa... | java |
public static double std(TransposeDataCollection sampleDataCollection, AssociativeArray populationNh) {
return Math.sqrt(variance(sampleDataCollection, populationNh));
} | java |
public static AssociativeArray optimumSampleSize(int n, AssociativeArray populationNh, AssociativeArray populationStdh) {
AssociativeArray nh = new AssociativeArray();
double sumNhSh = 0.0;
for(Map.Entry<Object, Object> entry : populationNh.entrySet()) {
Object strata = entr... | java |
public static <T> void throttledExecution(Stream<T> stream, Consumer<T> consumer, ConcurrencyConfiguration concurrencyConfiguration) {
if(concurrencyConfiguration.isParallelized()) {
int maxThreads = concurrencyConfiguration.getMaxNumberOfThreadsPerTask();
int maxTasks = 2*maxThreads;
... | java |
protected static double betinc(double x, double A, double B) {
double A0=0.0;
double B0=1.0;
double A1=1.0;
double B1=1.0;
double M9=0.0;
double A2=0.0;
while (Math.abs((A1-A2)/A1)>0.00001) {
A2=A1;
double C9=-(A+M9)*(A+B+M9)*x/(A+2.0*M9)/(... | java |
public static double exponentialCdf(double x, double lamda) {
if(x<0 || lamda<=0) {
throw new IllegalArgumentException("All the parameters must be positive.");
}
double probability = 1.0 - Math.exp(-lamda*x);
return probability;
} | java |
public static double betaCdf(double x, double a, double b) {
if(x<0 || a<=0 || b<=0) {
throw new IllegalArgumentException("All the parameters must be positive.");
}
double Bcdf = 0.0;
if(x==0) {
return Bcdf;
}
else if (x>=1) {
... | java |
public static double fCdf(double x, int f1, int f2) {
if(x<0 || f1<=0 || f2<=0) {
throw new IllegalArgumentException("All the parameters must be positive.");
}
double Z = x/(x + (double)f2/f1);
double FCdf = betaCdf(Z,f1/2.0,f2/2.0);
return FCdf;
... | java |
public static double gammaCdf(double x, double a, double b) {
if(a<=0 || b<=0) {
throw new IllegalArgumentException("All the parameters must be positive.");
}
double GammaCdf = ContinuousDistributions.gammaCdf(x/b, a);
return GammaCdf;
} | java |
public static double uniformCdf(double x, double a, double b) {
if(a>=b) {
throw new IllegalArgumentException("The a must be smaller than b.");
}
double probabilitySum;
if(x<a) {
probabilitySum=0.0;
}
else if(x<b) {
probability... | java |
public static double kolmogorov(double z) {
//Kolmogorov distribution. Error<.0000001
if (z<0.27) {
return 0.0;
}
else if (z>3.2) {
return 1.1;
}
double ks=0;
double y=-2*z*z;
for(int i=27;i>=1;i=i-2) {
ks=Math.exp(i*... | java |
public static double dirichletPdf(double[] pi, double[] ai) {
double probability=1.0;
double sumAi=0.0;
double productGammaAi=1.0;
double tmp;
int piLength=pi.length;
for(int i=0;i<piLength;++i) {
tmp=ai[i];
sumAi+= tmp;
produc... | java |
public static double dirichletPdf(double[] pi, double a) {
double probability=1.0;
int piLength=pi.length;
for(int i=0;i<piLength;++i) {
probability*=Math.pow(pi[i], a-1);
}
double sumAi=piLength*a;
double productGammaAi=Math.pow(gam... | java |
public static double[] multinomialGaussianSample(double[] mean, double[][] covariance) {
MultivariateNormalDistribution gaussian = new
MultivariateNormalDistribution(mean, covariance);
gaussian.reseedRandomGenerator(RandomGenerator.getThreadLocalRandom().nextLong());
return gaussian... | java |
public static double multinomialGaussianPdf(double[] mean, double[][] covariance, double[] x) {
MultivariateNormalDistribution gaussian = new
MultivariateNormalDistribution(mean, covariance);
return gaussian.density(x);
} | java |
public static Map.Entry<Object, Double> selectMaxKeyValue(Map<Object, Double> keyValueMap) {
Double maxValue=Double.NEGATIVE_INFINITY;
Object maxValueKey = null;
for(Map.Entry<Object, Double> entry : keyValueMap.entrySet()) {
Double value = entry.getValue();
if(v... | java |
public static Map.Entry<Object, Object> selectMinKeyValue(AssociativeArray keyValueMap) {
Double minValue=Double.POSITIVE_INFINITY;
Object minValueKey = null;
for(Map.Entry<Object, Object> entry : keyValueMap.entrySet()) {
Double value = TypeInference.toDouble(entry.getValue... | java |
public static <K, V> Map<K, V> sortNumberMapByKeyAscending(Map<K, V> map) {
return sortNumberMapByKeyAscending(map.entrySet());
} | java |
public static <K, V> Map<K, V> sortNumberMapByKeyDescending(Map<K, V> map) {
return sortNumberMapByKeyDescending(map.entrySet());
} | java |
public static <K, V> Map<K, V> sortNumberMapByValueDescending(Map<K, V> map) {
ArrayList<Map.Entry<K, V>> entries = new ArrayList<>(map.entrySet());
Collections.sort(entries, (Map.Entry<K, V> a, Map.Entry<K, V> b) -> {
Double va = TypeInference.toDouble(a.getValue());
Double vb =... | java |
public static AssociativeArray sortAssociativeArrayByValueAscending(AssociativeArray associativeArray) {
ArrayList<Map.Entry<Object, Object>> entries = new ArrayList<>(associativeArray.entrySet());
Collections.sort(entries, (Map.Entry<Object, Object> a, Map.Entry<Object, Object> b) -> {
Doub... | java |
private static String unescapeHtml(final String input) {
StringBuilder writer = null;
int len = input.length();
int i = 1;
int st = 0;
while (true) {
// look for '&'
while (i < len && input.charAt(i-1) != '&') {
i++;
}
... | java |
public static String replaceImgWithAlt(String html) {
Matcher m = IMG_ALT_TITLE_PATTERN.matcher(html);
if (m.find()) {
return m.replaceAll(" $1 ");
}
return html;
} | java |
public static String safeRemoveAllTags(String html) {
html = removeNonTextTags(html);
html = unsafeRemoveAllTags(html);
return html;
} | java |
public static String extractText(String html) {
//return Jsoup.parse(text).text();
html = replaceImgWithAlt(html);
html = safeRemoveAllTags(html);
html = unescapeHtml(html);
return html;
} | java |
public static String extractTitle(String html) {
Matcher m = TITLE_PATTERN.matcher(html);
if (m.find()) {
return clear(m.group(0));
}
return null;
} | java |
public static Map<HyperlinkPart, List<String>> extractHyperlinks(String html) {
Map<HyperlinkPart, List<String>> hyperlinksMap = new HashMap<>();
hyperlinksMap.put(HyperlinkPart.HTMLTAG, new ArrayList<>());
hyperlinksMap.put(HyperlinkPart.URL, new ArrayList<>());
hyperlinksMap.put(Hyperl... | java |
public static Map<String, String> extractMetatags(String html) {
Map<String, String> metatagsMap = new HashMap<>();
Matcher m = METATAG_PATTERN.matcher(html);
while (m.find()) {
if(m.groupCount()==2) {
String name = m.group(1);
String ... | java |
public static double normalDistribution(Double x, AssociativeArray params) {
double mean= params.getDouble("mean");
double variance= params.getDouble("variance");
//standardize the x value
double z=(x-mean)/Math.sqrt(variance);
return ContinuousDistributions.gaussCdf(z);
} | java |
public static double bernoulliCdf(int k, double p) {
if(p<0) {
throw new IllegalArgumentException("The probability p can't be negative.");
}
double probabilitySum=0.0;
if(k<0) {
}
else if(k<1) { //aka k==0
probabilitySum=(1-p)... | java |
public static double binomial(int k, double p, int n) {
if(k<0 || p<0 || n<1) {
throw new IllegalArgumentException("All the parameters must be positive and n larger than 1.");
}
k = Math.min(k, n);
/*
//Slow and can't handle large numbers
$... | java |
public static double binomialCdf(int k, double p, int n) {
if(k<0 || p<0 || n<1) {
throw new IllegalArgumentException("All the parameters must be positive and n larger than 1.");
}
k = Math.min(k, n);
double probabilitySum = approxBinomialCdf(k,p,n);
... | java |
private static double approxBinomialCdf(int k, double p, int n) {
//use an approximation as described at http://www.math.ucla.edu/~tom/distributions/binomial.html
double Z = p;
double A=k+1;
double B=n-k;
double S=A+B;
double BT=Math.exp(ContinuousDistributions.logGamma(S... | java |
public static double geometric(int k, double p) {
if(k<=0 || p<0) {
throw new IllegalArgumentException("All the parameters must be positive.");
}
double probability = Math.pow(1-p,k-1)*p;
return probability;
} | java |
public static double geometricCdf(int k, double p) {
if(k<=0 || p<0) {
throw new IllegalArgumentException("All the parameters must be positive.");
}
double probabilitySum = 0.0;
for(int i=1;i<=k;++i) {
probabilitySum += geometric(i, p);
}
... | java |
public static double negativeBinomial(int n, int r, double p) {
//tested its validity with http://www.mathcelebrity.com/binomialneg.php
if(n<0 || r<0 || p<0) {
throw new IllegalArgumentException("All the parameters must be positive.");
}
n = Math.max(n,r);//obvisouly the tota... | java |
public static double negativeBinomialCdf(int n, int r, double p) {
if(n<0 || r<0 || p<0) {
throw new IllegalArgumentException("All the parameters must be positive.");
}
n = Math.max(n,r);
double probabilitySum = 0.0;
for(int i=0;i<=r;++i) {
probab... | java |
public static double uniformCdf(int k, int n) {
if(k<0 || n<1) {
throw new IllegalArgumentException("All the parameters must be positive and n larger than 1.");
}
k = Math.min(k, n);
double probabilitySum = k*uniform(n);
return probabilitySum;
} | java |
public static double hypergeometric(int k, int n, int Kp, int Np) {
if(k<0 || n<0 || Kp<0 || Np<0) {
throw new IllegalArgumentException("All the parameters must be positive.");
}
Kp = Math.max(k, Kp);
Np = Math.max(n, Np);
/*
//slow!
$probabil... | java |
public static double hypergeometricCdf(int k, int n, int Kp, int Np) {
if(k<0 || n<0 || Kp<0 || Np<0) {
throw new IllegalArgumentException("All the parameters must be positive.");
}
Kp = Math.max(k, Kp);
Np = Math.max(n, Np);
/*
//slow!
$proba... | java |
public static double poisson(int k, double lamda) {
if(k<0 || lamda<0) {
throw new IllegalArgumentException("All the parameters must be positive.");
}
/*
//Slow
$probability=pow($lamda,$k)*exp(-$lamda)/StatsUtilities::factorial($k);
*/
//fast... | java |
public static double poissonCdf(int k, double lamda) {
if(k<0 || lamda<0) {
throw new IllegalArgumentException("All the parameters must be positive.");
}
/*
//Slow!
$probabilitySum=0;
for($i=0;$i<=$k;++$i) {
$probabilitySum+=self::poisson(... | java |
public static int count(Iterable it) {
int n = 0;
for(Object v: it) {
if(v != null) {
++n;
}
}
return n;
} | java |
public static double sum(FlatDataCollection flatDataCollection) {
double sum = 0.0;
Iterator<Double> it = flatDataCollection.iteratorDouble();
while(it.hasNext()) {
Double value = it.next();
if(value != null) {
sum+= value;
}
}... | java |
public static double mean(FlatDataCollection flatDataCollection) {
int n = 0;
double mean = 0.0;
Iterator<Double> it = flatDataCollection.iteratorDouble();
while(it.hasNext()) {
Double value = it.next();
if(value != null) {
++n;
mea... | java |
public static double meanSE(FlatDataCollection flatDataCollection) {
double std = std(flatDataCollection, true);
double meanSE = std/Math.sqrt(count(flatDataCollection));
return meanSE;
} | java |
public static double median(FlatDataCollection flatDataCollection) {
double[] doubleArray = flatDataCollection.stream().filter(x -> x!=null).mapToDouble(TypeInference::toDouble).toArray();
int n = doubleArray.length;
if(n==0) {
throw new IllegalArgumentException("The provided collect... | java |
public static double min(FlatDataCollection flatDataCollection) {
double min=Double.POSITIVE_INFINITY;
Iterator<Double> it = flatDataCollection.iteratorDouble();
while(it.hasNext()) {
Double v = it.next();
if(v != null && min > v) {
min=v;
... | java |
public static double max(FlatDataCollection flatDataCollection) {
double max=Double.NEGATIVE_INFINITY;
Iterator<Double> it = flatDataCollection.iteratorDouble();
while(it.hasNext()) {
Double v = it.next();
if(v != null && max < v) {
max=v;
... | java |
public static double minAbsolute(FlatDataCollection flatDataCollection) {
double minAbs=Double.POSITIVE_INFINITY;
Iterator<Double> it = flatDataCollection.iteratorDouble();
while(it.hasNext()) {
Double v = it.next();
if(v != null) {
minAbs= Math.min(minAb... | java |
public static double maxAbsolute(FlatDataCollection flatDataCollection) {
double maxAbs=0.0;
Iterator<Double> it = flatDataCollection.iteratorDouble();
while(it.hasNext()) {
Double v = it.next();
if(v != null) {
maxAbs= Math.max(maxAbs, Math.abs(v));
... | java |
public static double geometricMean(FlatDataCollection flatDataCollection) {
int n = 0;
double geometricMean = 0.0;
Iterator<Double> it = flatDataCollection.iteratorDouble();
while(it.hasNext()) {
Double v = it.next();
if(v != null) {
if(v <= 0.0) {
... | java |
public static double harmonicMean(FlatDataCollection flatDataCollection) {
int n = 0;
double harmonicMean = 0.0;
Iterator<Double> it = flatDataCollection.iteratorDouble();
while(it.hasNext()) {
Double v = it.next();
if(v!=null) {
++n;
... | java |
public static double variance(FlatDataCollection flatDataCollection, boolean isSample) {
/* Uses the formal Variance = E(X^2) - mean^2 */
int n = 0;
double mean = 0.0;
double squaredMean = 0.0;
Iterator<Double> it = flatDataCollection.iteratorDouble();
while(it.hasNext())... | java |
public static double std(FlatDataCollection flatDataCollection, boolean isSample) {
double variance = variance(flatDataCollection, isSample);
double std = Math.sqrt(variance);
return std;
} | java |
public static double cv(double std, double mean) {
if(mean==0) {
return Double.POSITIVE_INFINITY;
}
double cv = std/mean;
return cv;
} | java |
public static double moment(FlatDataCollection flatDataCollection, int r) {
double mean = mean(flatDataCollection);
return moment(flatDataCollection, r, mean);
} | java |
public static double moment(FlatDataCollection flatDataCollection, int r, double mean) {
int n = 0;
double moment=0.0;
Iterator<Double> it = flatDataCollection.iteratorDouble();
while(it.hasNext()) {
Double v = it.next();
if(v != null) {
+... | java |
public static AssociativeArray percentiles(FlatDataCollection flatDataCollection, int cutPoints) {
double[] doubleArray = flatDataCollection.stream().filter(x -> x!=null).mapToDouble(TypeInference::toDouble).toArray();
int n = doubleArray.length;
if(n<=0 || cutPoints<=0 || n<cutPoints) {
... | java |
public static double autocorrelation(FlatDataList flatDataList, int lags) {
int n = count(flatDataList);
if(n<=0 || lags<=0 || n<lags) {
throw new IllegalArgumentException("All the parameters must be positive and n larger than lags.");
}
FlatDataCollection flatDataCo... | java |
public static AssociativeArray frequencies(FlatDataCollection flatDataCollection) {
AssociativeArray frequencies = new AssociativeArray();
for (Object value : flatDataCollection) {
Object counter = frequencies.get(value);
if(counter==null) {
frequencies.p... | java |
public static void normalize(AssociativeArray associativeArray) {
double sum = 0.0;
//Prevents numeric underflow by subtracting the max. References: http://www.youtube.com/watch?v=-RVM21Voo7Q
for(Map.Entry<Object, Object> entry : associativeArray.entrySet()) {
Double value = TypeInfe... | java |
public static void normalizeExp(AssociativeArray associativeArray) {
double max = max(associativeArray.toFlatDataCollection());
double sum = 0.0;
//Prevents numeric underflow by subtracting the max. References: http://www.youtube.com/watch?v=-RVM21Voo7Q
for(Map.Entry<Object, Object> ent... | java |
@Override
public Map<Integer, String> extract(final String text) {
Set<String> tmpKwd = new LinkedHashSet<>(generateTokenizer().tokenize(text));
Map<Integer, String> keywordSequence = new LinkedHashMap<>();
int position = 0;
for(String keyword : tmpKwd) {
... | java |
private static void setStorageEngine(Dataframe dataset) {
//create a single storage engine for all the MapRealMatrixes
if (storageEngine == null) {
synchronized(DataframeMatrix.class) {
if (storageEngine == null) {
String storageName = "mdf" + RandomGenera... | java |
public static DataframeMatrix newInstance(Dataframe dataset, boolean addConstantColumn, Map<Integer, Integer> recordIdsReference, Map<Object, Integer> featureIdsReference) {
if(!featureIdsReference.isEmpty()) {
throw new IllegalArgumentException("The featureIdsReference map should be empty.");
... | java |
public static RealVector parseRecord(Record r, Map<Object, Integer> featureIdsReference) {
if(featureIdsReference.isEmpty()) {
throw new IllegalArgumentException("The featureIdsReference map should not be empty.");
}
int d = featureIdsReference.size();
//create an M... | java |
public void setMaxNumberOfThreadsPerTask(Integer maxNumberOfThreadsPerTask) {
if(maxNumberOfThreadsPerTask<0) {
throw new IllegalArgumentException("The max number of threads can not be negative.");
}
else if(maxNumberOfThreadsPerTask==0) {
this.maxNumberOfThreadsPerTask =... | java |
public <T> void forEach(Stream<T> stream, Consumer<? super T> action) {
Runnable runnable = () -> stream.forEach(action);
ThreadMethods.forkJoinExecution(runnable, concurrencyConfiguration, stream.isParallel());
} | java |
public <T, R> Stream<R> map(Stream<T> stream, Function<? super T, ? extends R> mapper) {
Callable<Stream<R>> callable = () -> stream.map(mapper);
return ThreadMethods.forkJoinExecution(callable, concurrencyConfiguration, stream.isParallel());
} | java |
public <T, R, A> R collect(Stream<T> stream, Collector<? super T, A, R> collector) {
Callable<R> callable = () -> stream.collect(collector);
return ThreadMethods.forkJoinExecution(callable, concurrencyConfiguration, stream.isParallel());
} | java |
public <T> Optional<T> min(Stream<T> stream, Comparator<? super T> comparator) {
Callable<Optional<T>> callable = () -> stream.min(comparator);
return ThreadMethods.forkJoinExecution(callable, concurrencyConfiguration, stream.isParallel());
} | java |
public double sum(DoubleStream stream) {
Callable<Double> callable = () -> stream.sum();
return ThreadMethods.forkJoinExecution(callable, concurrencyConfiguration, stream.isParallel());
} | java |
public void save(String storageName) {
//store the objects on storage
storageEngine.saveObject("modelParameters", modelParameters);
storageEngine.saveObject("trainingParameters", trainingParameters);
//rename the storage
storageEngine.rename(storageName);
//reload the m... | java |
protected AbstractTokenizer generateTokenizer() {
Class<? extends AbstractTokenizer> tokenizer = parameters.getTokenizer();
if(tokenizer==null) {
return null;
}
try {
return tokenizer.newInstance();
}
catch (InstantiationException | IllegalAccess... | java |
public static <T extends AbstractTextExtractor, TP extends AbstractTextExtractor.AbstractParameters> T newInstance(TP parameters) {
try {
//By convention the Parameters are enclosed in the Extactor.
Class<T> tClass = (Class<T>) parameters.getClass().getEnclosingClass();
retur... | java |
public static AssociativeArray2D survivalFunction(FlatDataCollection flatDataCollection) {
AssociativeArray2D survivalFunction = new AssociativeArray2D(); //AssociativeArray2D is important to maintain the order of the first keys
Queue<Double> censoredData = new PriorityQueue<>();
Queue<... | java |
public static double median(AssociativeArray2D survivalFunction) {
Double ApointTi = null;
Double BpointTi = null;
int n = survivalFunction.size();
if(n==0) {
throw new IllegalArgumentException("The provided collection can't be empty.");
}
f... | java |
private static double ar(AssociativeArray2D survivalFunction, int r) {
if(survivalFunction.isEmpty()) {
throw new IllegalArgumentException("The provided collection can't be empty.");
}
AssociativeArray2D survivalFunctionCopy = survivalFunction;
//check if la... | java |
public static double meanVariance(AssociativeArray2D survivalFunction) {
double meanVariance=0;
int m=0;
int n=0;
for(Map.Entry<Object, AssociativeArray> entry : survivalFunction.entrySet()) {
//Object ti = entry.getKey();
AssociativeArray row = entry.getValue();... | java |
public VM validate(Iterator<Split> dataSplits, TrainingParameters trainingParameters) {
AbstractModeler modeler = MLBuilder.create(trainingParameters, configuration);
List<VM> validationMetricsList = new LinkedList<>();
while (dataSplits.hasNext()) {
Split s = dataSplits.next();
... | java |
public static <K> void updateWeights(double l1, double learningRate, Map<K, Double> weights, Map<K, Double> newWeights) {
if(l1 > 0.0) {
/*
//SGD-L1 (Naive)
for(Map.Entry<K, Double> e : weights.entrySet()) {
K column = e.getKey();
newWeights.pu... | java |
public static <K> double estimatePenalty(double l1, Map<K, Double> weights) {
double penalty = 0.0;
if(l1 > 0.0) {
double sumAbsWeights = 0.0;
for(double w : weights.values()) {
sumAbsWeights += Math.abs(w);
}
penalty = l1*sumAbsWeights;
... | java |
public static DataType getDataType(Object v) {
//NOTE: DO NOT CHANGE THE ORDER OF THE IFS!!!
if(DataType.BOOLEAN.isInstance(v)) {
return DataType.BOOLEAN;
}
else if(DataType.ORDINAL.isInstance(v)) {
return DataType.ORDINAL;
}
else if(DataType.NUMER... | java |
public static Double toDouble(Object v) {
if (v == null) {
return null;
}
if (v instanceof Boolean) {
return ((Boolean) v) ? 1.0 : 0.0;
}
return ((Number) v).doubleValue();
} | java |
public static Integer toInteger(Object v) {
if (v == null) {
return null;
}
if (v instanceof Boolean) {
return ((Boolean) v) ? 1 : 0;
}
return ((Number) v).intValue();
} | java |
public static double calculateScore(FlatDataList errorList) {
double DWdeltasquare=0;
double DWetsquare=0;
int n = errorList.size();
for(int i=0;i<n;++i) {
Double error = errorList.getDouble(i);
if(i>=1) {
Double errorPrevious = errorList.getDoubl... | java |
public final Iterator<Double> iteratorDouble() {
return new Iterator<Double>() {
private final Iterator<Object> objectIterator = (Iterator<Object>) internalData.iterator();
/** {@inheritDoc} */
@Override
public boolean hasNext() {
retu... | java |
public static double euclidean(AssociativeArray a1, AssociativeArray a2) {
Map<Object, Double> columnDistances = columnDistances(a1, a2, null);
double distance = 0.0;
for(double columnDistance : columnDistances.values()) {
distance+=(columnDistance*columnDistance);
}... | java |
public static double euclideanWeighted(AssociativeArray a1, AssociativeArray a2, Map<Object, Double> columnWeights) {
Map<Object, Double> columnDistances = columnDistances(a1, a2, columnWeights.keySet());
double distance = 0.0;
for(Map.Entry<Object, Double> entry : columnDistances.entry... | java |
public static double manhattan(AssociativeArray a1, AssociativeArray a2) {
Map<Object, Double> columnDistances = columnDistances(a1, a2, null);
double distance = 0.0;
for(double columnDistance : columnDistances.values()) {
distance+=Math.abs(columnDistance);
}
... | java |
public static double manhattanWeighted(AssociativeArray a1, AssociativeArray a2, Map<Object, Double> columnWeights) {
Map<Object, Double> columnDistances = columnDistances(a1, a2, columnWeights.keySet());
double distance = 0.0;
for(Map.Entry<Object, Double> entry : columnDistances.entry... | java |
public static AssociativeArray getRanksFromValues(FlatDataList flatDataCollection) {
AssociativeArray tiesCounter = new AssociativeArray();
Map<Object, Double> key2AvgRank = new LinkedHashMap<>();
_buildRankArrays(flatDataCollection, tiesCounter, key2AvgRank);
int i = 0;
for (Obj... | java |
public static AssociativeArray getRanksFromValues(AssociativeArray associativeArray) {
AssociativeArray tiesCounter = new AssociativeArray();
Map<Object, Double> key2AvgRank = new LinkedHashMap<>();
_buildRankArrays(associativeArray.toFlatDataList(), tiesCounter, key2AvgRank);
for (Map.E... | java |
public void fit(Map<Object, URI> datasets) {
TrainingParameters tp = (TrainingParameters) knowledgeBase.getTrainingParameters();
Dataframe trainingData = Dataframe.Builder.parseTextFiles(datasets,
AbstractTextExtractor.newInstance(tp.getTextExtractorParameters()),
knowled... | java |
public Dataframe predict(URI datasetURI) {
//create a dummy dataset map
Map<Object, URI> dataset = new HashMap<>();
dataset.put(null, datasetURI);
TrainingParameters trainingParameters = (TrainingParameters) knowledgeBase.getTrainingParameters();
Dataframe testD... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.