/** * Constructor. */ public SAXProcessor() { super(); this.tsProcessor = new TSProcessor(); this.na = new NormalAlphabet(); this.ed = new EuclideanDistance(); }
/** * Constructor. */ public SAXProcessor() { super(); this.tsProcessor = new TSProcessor(); this.na = new NormalAlphabet(); this.ed = new EuclideanDistance(); }
NormalAlphabet na = new NormalAlphabet(); SAXProcessor sp = new SAXProcessor();
NormalAlphabet na = new NormalAlphabet(); SAXProcessor sp = new SAXProcessor();
@Override public HashMap<Integer, char[]> call() throws Exception { NormalAlphabet na = new NormalAlphabet(); TSProcessor tsp = new TSProcessor();
@Override public HashMap<Integer, char[]> call() throws Exception { NormalAlphabet na = new NormalAlphabet(); TSProcessor tsp = new TSProcessor();
private static Map<Integer, Integer[]> getPatternLocationsForTheClass(String className, Map<String, List<double[]>> trainData, String pattern, Params params) throws IndexOutOfBoundsException, Exception { Alphabet a = new NormalAlphabet(); Map<Integer, Integer[]> res = new HashMap<Integer, Integer[]>(); int seriesCounter = 0; for (double[] series : trainData.get(className)) { List<Integer> arr = new ArrayList<Integer>(); for (int i = 0; i <= series.length - params.getWindowSize(); i++) { double[] paa = tsp.paa(tsp.znorm(tsp.subseriesByCopy(series, i, i + params.getWindowSize()), params.getnThreshold()), params.getPaaSize()); char[] sax = tsp.ts2String(paa, a.getCuts(params.getAlphabetSize())); if (pattern.equalsIgnoreCase(String.valueOf(sax))) { arr.add(i); } } res.put(seriesCounter, arr.toArray(new Integer[0])); seriesCounter++; } return res; } }
NormalAlphabet normalA = new NormalAlphabet(); SAXRecords sax = sp.ts2saxViaWindow(series, windowSize, alphabetSize, normalA.getCuts(alphabetSize), strategy, nThreshold);
NormalAlphabet normalA = new NormalAlphabet(); SAXRecords sax = sp.ts2saxViaWindow(series, windowSize, alphabetSize, normalA.getCuts(alphabetSize), strategy, nThreshold);
private static double[] seriesValuesAsHeat(double[] series, String className, HashMap<String, HashMap<String, Double>> tfidf, Params params) throws Exception { Alphabet a = new NormalAlphabet(); double[] weights = new double[series.length]; HashMap<String, Integer> words = new HashMap<String, Integer>(); for (int i = 0; i <= series.length - params.getWindowSize(); i++) { double[] subseries = tsp.subseriesByCopy(series, i, i + params.getWindowSize()); double[] paa = tsp.paa(tsp.znorm(subseries, params.getnThreshold()), params.getPaaSize()); char[] sax = tsp.ts2String(paa, a.getCuts(params.getAlphabetSize())); words.put(String.valueOf(sax), i); } for (Entry<String, HashMap<String, Double>> e : tfidf.entrySet()) { for (Entry<String, Double> e1 : e.getValue().entrySet()) { if (words.containsKey(e1.getKey())) { int idx = words.get(e1.getKey()); double increment = 0.0; if (className.equalsIgnoreCase(e.getKey())) { increment = e1.getValue(); } else { // increment = -e1.getValue(); } for (int i = 0; i < params.getWindowSize(); i++) { weights[idx + i] = weights[idx + i] + increment; } } } } return weights; }
NormalAlphabet normalA = new NormalAlphabet(); SAXRecords sax = sp.ts2saxViaWindow(series, windowSize, paaSize, normalA.getCuts(alphabetSize), strategy, nThreshold);
NormalAlphabet na = new NormalAlphabet(); SAXProcessor sp = new SAXProcessor();
NormalAlphabet na = new NormalAlphabet(); SAXProcessor sp = new SAXProcessor();
NormalAlphabet normalA = new NormalAlphabet(); SAXRecords sax = sp.ts2saxViaWindow(series, windowSize, paaSize, normalA.getCuts(alphabetSize), strategy, nThreshold);
NormalAlphabet na = new NormalAlphabet();
NormalAlphabet na = new NormalAlphabet();
public static void main(String[] args) throws IOException, SAXException { double[] ts = { 0, 0, 0, 0, 0, -0.270340178359072, -0.367828308500142, 0.666980581124872, 1.87088147328446, 2.14548907684624, -0.480859313143032, -0.72911654245842, -0.490308602315934, -0.66152028906509, -0.221049033806403, 0.367003418871239, 0.631073992586373, 0.0487728723414486, 0.762655178750436, 0.78574757843331, 0.338239686422963, 0.784206454089066, -2.14265084073625, 2.11325193044223, 0.186018356196443, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.519132472499234, -2.604783141655, -0.244519550114012, -1.6570790528784, 3.34184602886343, 2.10361226260999, 1.9796808733979, -0.822247322003058, 1.06850578033292, -0.678811824405992, 0.804225748913681, 0.57363964388698, 0.437113583759113, 0.437208643628268, 0.989892093383503, 1.76545983424176, 0.119483882364649, -0.222311941138971, -0.74669456611669, -0.0663660879732063, 0, 0, 0, 0, 0 }; SAXProcessor sp = new SAXProcessor(); NormalAlphabet na = new NormalAlphabet(); SAXRecords saxExact = sp.ts2saxViaWindow(ts, 30, 3, na.getCuts(3), NumerosityReductionStrategy.EXACT, 0.01); saxExact.buildIndex(); for (int i : saxExact.getAllIndices()) { System.out.println(i + " -> " + saxExact.getByIndex(i)); } System.out.println(" ===================== "); SAXRecords saxMindist = sp.ts2saxViaWindow(ts, 30, 6, na.getCuts(5), NumerosityReductionStrategy.MINDIST, 0.01); saxExact.buildIndex(); for (int i : saxMindist.getAllIndices()) { System.out.println(i + " -> " + saxMindist.getByIndex(i)); } }
public static void main(String[] args) throws IOException, SAXException { double[] ts = { 0, 0, 0, 0, 0, -0.270340178359072, -0.367828308500142, 0.666980581124872, 1.87088147328446, 2.14548907684624, -0.480859313143032, -0.72911654245842, -0.490308602315934, -0.66152028906509, -0.221049033806403, 0.367003418871239, 0.631073992586373, 0.0487728723414486, 0.762655178750436, 0.78574757843331, 0.338239686422963, 0.784206454089066, -2.14265084073625, 2.11325193044223, 0.186018356196443, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.519132472499234, -2.604783141655, -0.244519550114012, -1.6570790528784, 3.34184602886343, 2.10361226260999, 1.9796808733979, -0.822247322003058, 1.06850578033292, -0.678811824405992, 0.804225748913681, 0.57363964388698, 0.437113583759113, 0.437208643628268, 0.989892093383503, 1.76545983424176, 0.119483882364649, -0.222311941138971, -0.74669456611669, -0.0663660879732063, 0, 0, 0, 0, 0 }; SAXProcessor sp = new SAXProcessor(); NormalAlphabet na = new NormalAlphabet(); SAXRecords saxExact = sp.ts2saxViaWindow(ts, 30, 3, na.getCuts(3), NumerosityReductionStrategy.EXACT, 0.01); saxExact.buildIndex(); for (int i : saxExact.getAllIndices()) { System.out.println(i + " -> " + saxExact.getByIndex(i)); } System.out.println(" ===================== "); SAXRecords saxMindist = sp.ts2saxViaWindow(ts, 30, 6, na.getCuts(5), NumerosityReductionStrategy.MINDIST, 0.01); saxExact.buildIndex(); for (int i : saxMindist.getAllIndices()) { System.out.println(i + " -> " + saxMindist.getByIndex(i)); } }
numerosityReductionStrategy, windowSize, paaSize, alphabetSize, normalizationThreshold); NormalAlphabet na = new NormalAlphabet();