Java Code Examples for org.datavec.api.writable.Writable#toDouble()
The following examples show how to use
org.datavec.api.writable.Writable#toDouble() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DoubleMetaData.java From DataVec with Apache License 2.0 | 6 votes |
@Override public boolean isValid(Writable writable) { double d; try { d = writable.toDouble(); } catch (Exception e) { return false; } if (allowNaN && Double.isNaN(d)) return true; if (allowInfinite && Double.isInfinite(d)) return true; if (minAllowedValue != null && d < minAllowedValue) return false; if (maxAllowedValue != null && d > maxAllowedValue) return false; return true; }
Example 2
Source File: DoubleHistogramCounter.java From deeplearning4j with Apache License 2.0 | 6 votes |
@Override public HistogramCounter add(Writable w) { double d = w.toDouble(); //Not super efficient, but linear search on 20-50 items should be good enough int idx = -1; for (int i = 0; i < nBins; i++) { if (d >= bins[i] && d < bins[i + 1]) { idx = i; break; } } if (idx == -1) idx = nBins - 1; binCounts[idx]++; return this; }
Example 3
Source File: DoubleHistogramCounter.java From DataVec with Apache License 2.0 | 6 votes |
@Override public HistogramCounter add(Writable w) { double d = w.toDouble(); //Not super efficient, but linear search on 20-50 items should be good enough int idx = -1; for (int i = 0; i < nBins; i++) { if (d >= bins[i] && d < bins[i + 1]) { idx = i; break; } } if (idx == -1) idx = nBins - 1; binCounts[idx]++; return this; }
Example 4
Source File: DoubleMetaData.java From deeplearning4j with Apache License 2.0 | 6 votes |
@Override public boolean isValid(Writable writable) { double d; try { d = writable.toDouble(); } catch (Exception e) { return false; } if (allowNaN && Double.isNaN(d)) return true; if (allowInfinite && Double.isInfinite(d)) return true; if (minAllowedValue != null && d < minAllowedValue) return false; if (maxAllowedValue != null && d > maxAllowedValue) return false; return true; }
Example 5
Source File: MinMaxNormalizer.java From DataVec with Apache License 2.0 | 5 votes |
@Override public Writable map(Writable writable) { double val = writable.toDouble(); if (Double.isNaN(val)) return new DoubleWritable(0); return new DoubleWritable(ratio * (val - min) + newMin); }
Example 6
Source File: ConvertToDouble.java From DataVec with Apache License 2.0 | 5 votes |
@Override public DoubleWritable map(Writable writable) { if(writable.getType() == WritableType.Double){ return (DoubleWritable)writable; } return new DoubleWritable(writable.toDouble()); }
Example 7
Source File: DoubleAnalysisCounter.java From deeplearning4j with Apache License 2.0 | 5 votes |
@Override public DoubleAnalysisCounter add(Writable writable) { double value = writable.toDouble(); if (value == 0) countZero++; if (value == Double.NaN) countNaN++; if (value == getMinValueSeen()) countMinValue++; else if (value < getMinValueSeen()) { countMinValue = 1; } if (value == getMaxValueSeen()) countMaxValue++; else if (value > getMaxValueSeen()) { countMaxValue = 1; } if (value >= 0) { countPositive++; } else { countNegative++; } ; digest.add(value); counter.add(value); return this; }
Example 8
Source File: DoubleAnalysisCounter.java From DataVec with Apache License 2.0 | 5 votes |
@Override public DoubleAnalysisCounter add(Writable writable) { double value = writable.toDouble(); if (value == 0) countZero++; if (value == Double.NaN) countNaN++; if (value == getMinValueSeen()) countMinValue++; else if (value < getMinValueSeen()) { countMinValue = 1; } if (value == getMaxValueSeen()) countMaxValue++; else if (value > getMaxValueSeen()) { countMaxValue = 1; } if (value >= 0) { countPositive++; } else { countNegative++; } ; digest.add(value); counter.merge(value); return this; }
Example 9
Source File: ConvertToDouble.java From deeplearning4j with Apache License 2.0 | 5 votes |
@Override public DoubleWritable map(Writable writable) { if(writable.getType() == WritableType.Double){ return (DoubleWritable)writable; } return new DoubleWritable(writable.toDouble()); }
Example 10
Source File: MinMaxNormalizer.java From deeplearning4j with Apache License 2.0 | 5 votes |
@Override public Writable map(Writable writable) { double val = writable.toDouble(); if (Double.isNaN(val)) return new DoubleWritable(0); return new DoubleWritable(ratio * (val - min) + newMin); }
Example 11
Source File: SubtractMeanNormalizer.java From deeplearning4j with Apache License 2.0 | 4 votes |
@Override public Writable map(Writable writable) { return new DoubleWritable(writable.toDouble() - mean); }
Example 12
Source File: WritableToDoubleFunction.java From deeplearning4j with Apache License 2.0 | 4 votes |
@Override public double call(Writable writable) throws Exception { return writable.toDouble(); }
Example 13
Source File: TypeConversion.java From deeplearning4j with Apache License 2.0 | 4 votes |
public double convertDouble(Writable writable) { return writable.toDouble(); }
Example 14
Source File: Log2Normalizer.java From deeplearning4j with Apache License 2.0 | 4 votes |
public Writable map(Writable writable) { double val = writable.toDouble(); if (Double.isNaN(val)) return new DoubleWritable(0); return new DoubleWritable(normMean(val)); }
Example 15
Source File: StandardizeNormalizer.java From deeplearning4j with Apache License 2.0 | 4 votes |
@Override public Writable map(Writable writable) { double val = writable.toDouble(); return new DoubleWritable((val - mean) / stdev); }
Example 16
Source File: SubtractMeanNormalizer.java From DataVec with Apache License 2.0 | 4 votes |
@Override public Writable map(Writable writable) { return new DoubleWritable(writable.toDouble() - mean); }
Example 17
Source File: WritableToDoubleFunction.java From DataVec with Apache License 2.0 | 4 votes |
@Override public double call(Writable writable) throws Exception { return writable.toDouble(); }
Example 18
Source File: TypeConversion.java From DataVec with Apache License 2.0 | 4 votes |
public double convertDouble(Writable writable) { return writable.toDouble(); }
Example 19
Source File: Log2Normalizer.java From DataVec with Apache License 2.0 | 4 votes |
public Writable map(Writable writable) { double val = writable.toDouble(); if (Double.isNaN(val)) return new DoubleWritable(0); return new DoubleWritable(normMean(val)); }
Example 20
Source File: StandardizeNormalizer.java From DataVec with Apache License 2.0 | 4 votes |
@Override public Writable map(Writable writable) { double val = writable.toDouble(); return new DoubleWritable((val - mean) / stdev); }