public static void main(String[] args) throws Exception { series = TSProcessor.readFileColumn(TEST_DATA_FNAME, 0, 0); Console c = System.console(); if (c != null) { c.format("\nPress ENTER to proceed.\n"); c.readLine(); } Date start = new Date(); // motifsBF = BruteForceMotifImplementation.series2BruteForceMotifs(series, MOTIF_SIZE, // MOTIF_RANGE, ZNORM_THRESHOLD); // System.out.println(motifsBF); MotifRecord motifsEMMA = EMMAImplementation.series2EMMAMotifs(series, MOTIF_SIZE, MOTIF_RANGE, PAA_SIZE, ALPHABET_SIZE, ZNORM_THRESHOLD); Date end = new Date(); System.out.println(motifsEMMA); System.out.println("done in " + SAXProcessor.timeToString(start.getTime(), end.getTime())); } }
SAXProcessor sp = new SAXProcessor(); SAXRecords sequentialRes = sp.ts2saxViaWindow(ts, slidingWindowSize, paaSize, na.getCuts(alphabetSize), NumerosityReductionStrategy.fromString(nrStrategy), N_THRESHOLD); + SAXProcessor.timeToString(tstamp1, tstamp2)); + String.valueOf(tstamp2 - tstamp1) + ", " + SAXProcessor.timeToString(tstamp1, tstamp2));
&& sp.checkMinDistIsZero(previousString, currentString)) { continue;
public static void main(String[] args) throws IOException, SAXException { SAXProcessor sp = new SAXProcessor(); for (String fname : filenames) { String inFname = pathPrefix + fname; String outFname = inFname + ".shingled.txt"; double[] series = TSProcessor.readFileColumn(inFname, 0, 0); System.err.println("read " + inFname + ", " + series.length + " points ..."); Map<String, Integer> shingledData = sp.ts2Shingles(series, WIN_SIZE, PAA_SIZE, A_SIZE, NumerosityReductionStrategy.NONE, 0.001, LEVEL); StringBuilder shingles = new StringBuilder( BitmapParameters.SHINGLE_SIZE * (shingledData.size() + 2)); StringBuilder freqs = new StringBuilder( BitmapParameters.SHINGLE_SIZE * (shingledData.size() + 2)); TreeSet<String> keys = new TreeSet<String>(shingledData.keySet()); for (String shingle : keys) { shingles.append(QUOTE).append(shingle).append(QUOTE).append(COMMA); freqs.append(shingledData.get(shingle)).append(COMMA); } BufferedWriter bw = new BufferedWriter(new FileWriter(new File(outFname))); bw.write(shingles.delete(shingles.length() - 1, shingles.length()).toString()); bw.write(CR); bw.write(freqs.delete(freqs.length() - 1, freqs.length()).toString()); bw.write(CR); bw.close(); } }
alphabet[i] = String.valueOf(TSProcessor.ALPHABET[i]); String[] allShingles = getAllPermutations(alphabet, shingleSize); SAXRecords saxData = ts2saxViaWindow(series, windowSize, paaSize, na.getCuts(alphabetSize), strategy, nrThreshold);
SAXRecords sax = sp.ts2saxViaWindow(series, windowSize, alphabetSize, normalA.getCuts(alphabetSize), strategy, nThreshold); Date saxEnd = new Date(); LOGGER.debug("discretized in {}, words: {}, indexes: {}", SAXProcessor.timeToString(start.getTime(), saxEnd.getTime()), sax.getRecords().size(), sax.getIndexes().size()); SAXProcessor.timeToString(saxEnd.getTime(), hashEnd.getTime())); SAXProcessor.timeToString(start.getTime(), end.getTime()));
SAXProcessor sp = new SAXProcessor(); LOGGER.warn("Unable to run with {} threads. Rolling back to single-threaded implementation.", threadsNum); return sp.ts2saxViaWindow(timeseries, slidingWindowSize, paaSize, na.getCuts(alphabetSize), numRedStrategy, normalizationThreshold); if (null != oldStr && sp.checkMinDistIsZero(entry.getPayload(), oldStr)) { continue;
SAXProcessor sp = new SAXProcessor(); res = sp.ts2saxViaWindow(ts, slidingWindowSize, paaSize, na.getCuts(alphabetSize), nrStrategy, nThreshold);
SAXProcessor sp = new SAXProcessor(); saxFrequencyData = sp.ts2saxViaWindow(ts, windowSize, paaSize, na.getCuts(alphabetSize), numerosityReductionStrategy, normalizationThreshold); saxFrequencyData = sp.ts2saxByChunking(ts, paaSize, na.getCuts(alphabetSize), normalizationThreshold);
private static SAXRecords discretize(double[] series) throws SAXException { consoleLogger.info("Performing SAX conversion ..."); if (TS2GrammarParameters.NUM_WORKERS <= 1) { return sp.ts2saxViaWindow(series, TS2GrammarParameters.SAX_WINDOW_SIZE, TS2GrammarParameters.SAX_PAA_SIZE, na.getCuts(TS2GrammarParameters.SAX_ALPHABET_SIZE), TS2GrammarParameters.SAX_NR_STRATEGY, TS2GrammarParameters.SAX_NORM_THRESHOLD); } else { return psax.process(series, TS2GrammarParameters.NUM_WORKERS, TS2GrammarParameters.SAX_WINDOW_SIZE, TS2GrammarParameters.SAX_PAA_SIZE, TS2GrammarParameters.SAX_ALPHABET_SIZE, TS2GrammarParameters.SAX_NR_STRATEGY, TS2GrammarParameters.SAX_NORM_THRESHOLD); } }
/** * Get all permutations of the given alphabet of given length. * * @param alphabet the alphabet to use. * @param wordLength the word length. * @return set of permutation. */ public static String[] getAllPermutations(String[] alphabet, int wordLength) { // initialize our returned list with the number of elements calculated above String[] allLists = new String[(int) Math.pow(alphabet.length, wordLength)]; // lists of length 1 are just the original elements if (wordLength == 1) return alphabet; else { // the recursion--get all lists of length 3, length 2, all the way up to 1 String[] allSublists = getAllPermutations(alphabet, wordLength - 1); // append the sublists to each element int arrayIndex = 0; for (int i = 0; i < alphabet.length; i++) { for (int j = 0; j < allSublists.length; j++) { // add the newly appended combination to the list allLists[arrayIndex] = alphabet[i] + allSublists[j]; arrayIndex++; } } return allLists; } }
LOGGER.info("read {} points from {}", +data.length, BitmapParameters.IN_FILE); Map<String, Integer> shingledData = sp.ts2Shingles(data, BitmapParameters.SAX_WINDOW_SIZE, BitmapParameters.SAX_PAA_SIZE, BitmapParameters.SAX_ALPHABET_SIZE, BitmapParameters.SAX_NR_STRATEGY, BitmapParameters.SAX_NORM_THRESHOLD,
/** * Check for trivial mindist case. * * @param a first string. * @param b second string. * @return true if mindist between strings is zero. */ public boolean checkMinDistIsZero(char[] a, char[] b) { for (int i = 0; i < a.length; i++) { if (charDistance(a[i], b[i]) > 1) { return false; } } return true; }
for (int i = currBucketIdx + 1; i < bucketsOrder.size(); i++) { String cWord = bucketsOrder.get(i).getValue(); if (range > sp.saxMinDist(MPC.getValue().toCharArray(), cWord.toCharArray(), dm, motifSize, paaSize)) { neighborhood.addAll(buckets.get(cWord));
SAXRecords sax = sp.ts2saxViaWindow(series, windowSize, alphabetSize, normalA.getCuts(alphabetSize), strategy, nThreshold); Date saxEnd = new Date(); LOGGER.debug("discretized in {}, words: {}, indexes: {}", SAXProcessor.timeToString(start.getTime(), saxEnd.getTime()), sax.getRecords().size(), sax.getIndexes().size()); SAXProcessor.timeToString(saxEnd.getTime(), hashEnd.getTime())); SAXProcessor.timeToString(start.getTime(), end.getTime()));
SAXProcessor sp = new SAXProcessor(); LOGGER.warn("Unable to run with {} threads. Rolling back to single-threaded implementation.", threadsNum); return sp.ts2saxViaWindow(timeseries, slidingWindowSize, paaSize, na.getCuts(alphabetSize), numRedStrategy, normalizationThreshold); if (null != oldStr && sp.checkMinDistIsZero(entry.getPayload(), oldStr)) { continue;
SAXProcessor sp = new SAXProcessor(); res = sp.ts2saxViaWindow(ts, slidingWindowSize, paaSize, na.getCuts(alphabetSize), nrStrategy, nThreshold);
public static void main(String[] args) throws IOException, SAXException { SAXProcessor sp = new SAXProcessor(); for (String fname : filenames) { String inFname = pathPrefix + fname; String outFname = inFname + ".shingled.txt"; double[] series = TSProcessor.readFileColumn(inFname, 0, 0); System.err.println("read " + inFname + ", " + series.length + " points ..."); Map<String, Integer> shingledData = sp.ts2Shingles(series, WIN_SIZE, PAA_SIZE, A_SIZE, NumerosityReductionStrategy.NONE, 0.001, LEVEL); StringBuilder shingles = new StringBuilder( BitmapParameters.SHINGLE_SIZE * (shingledData.size() + 2)); StringBuilder freqs = new StringBuilder( BitmapParameters.SHINGLE_SIZE * (shingledData.size() + 2)); TreeSet<String> keys = new TreeSet<String>(shingledData.keySet()); for (String shingle : keys) { shingles.append(QUOTE).append(shingle).append(QUOTE).append(COMMA); freqs.append(shingledData.get(shingle)).append(COMMA); } BufferedWriter bw = new BufferedWriter(new FileWriter(new File(outFname))); bw.write(shingles.delete(shingles.length() - 1, shingles.length()).toString()); bw.write(CR); bw.write(freqs.delete(freqs.length() - 1, freqs.length()).toString()); bw.write(CR); bw.close(); } }
alphabet[i] = String.valueOf(TSProcessor.ALPHABET[i]); String[] allShingles = getAllPermutations(alphabet, shingleSize); SAXRecords saxData = ts2saxViaWindow(series, windowSize, paaSize, na.getCuts(alphabetSize), strategy, nrThreshold);
/** * Get all permutations of the given alphabet of given length. * * @param alphabet the alphabet to use. * @param wordLength the word length. * @return set of permutation. */ public static String[] getAllPermutations(String[] alphabet, int wordLength) { // initialize our returned list with the number of elements calculated above String[] allLists = new String[(int) Math.pow(alphabet.length, wordLength)]; // lists of length 1 are just the original elements if (wordLength == 1) return alphabet; else { // the recursion--get all lists of length 3, length 2, all the way up to 1 String[] allSublists = getAllPermutations(alphabet, wordLength - 1); // append the sublists to each element int arrayIndex = 0; for (int i = 0; i < alphabet.length; i++) { for (int j = 0; j < allSublists.length; j++) { // add the newly appended combination to the list allLists[arrayIndex] = alphabet[i] + allSublists[j]; arrayIndex++; } } return allLists; } }