Trait

com.eharmony.aloha.feature

Sos2

Related Doc: package feature

Permalink

trait Sos2 extends AnyRef

Sos2 takes a value and breaks it apart into a linear combination of the two closest values as specified by the min, max, and delta. As long as the value being sos2 binned exists in the interval [min, max], then there exists an isomorphism between the value and the sos2 binned value.

//                 delta = 1
//         |<--------------------->|<--------------------->|
//         |     |     |     |     |     |     |     |     |
//         |     |     |     |     |     |     |     |     |
//         0    0.25  0.5   0.75   1    1.25  1.5   1.75   2

// Show the keys output ('=' followed by a value)
val v = 1.25
val s = sos2(v, 0, 2, 1)
assert(s == List(("=1", 0.75), ("=2", 0.25)))

// Show the existing isomorphism between v and sos2I(v, min, max, delta) (if min <= v <= max)
val vPrime = sos2I(v, 0, 2, 1).foldLeft(0.0){case(s, (k, v)) => s + k * v}
assert(v == vPrime)
Self Type
Sos2 with DefaultPossessor with BasicMath
Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Sos2
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  10. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  11. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  13. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  14. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  15. def sos2(value: Double, min: Long, max: Long, delta: Long): Iterable[(String, Double)]

    Permalink

    Like sos2U but no underflows are reported.

    Like sos2U but no underflows are reported. Instead the values are first clamped to be in range so in the event value < min, return a tuple representing the min.

    value

    number to be sos2 binned

    min

    minimum bin value

    max

    minimum bin value

    delta

    bin size

    returns

    sos2 binned value

    Annotations
    @inline()
  16. def sos2(value: Option[Double], min: Long, max: Long, delta: Long, underflowKey: String, unknownKey: String): Iterable[(String, Double)]

    Permalink

    See com.eharmony.aloha.feature.Sos2.

    value

    number to be sos2 binned

    min

    minimum bin value

    max

    minimum bin value

    delta

    bin size

    underflowKey

    When value < min, an underflow key-value pair is emitted. This controls the key that is emitted.

    unknownKey

    When value is missing, a separate key-value pair is emitted. This controls the key that is emitted.

    returns

    sos2 binned value

    Annotations
    @inline()
  17. def sos2(value: Option[Double], min: Long, max: Long, delta: Long): Iterable[(String, Double)]

    Permalink
    Annotations
    @inline()
  18. def sos2I(value: Double, min: Long, max: Long, delta: Long): Seq[(Int, Double)]

    Permalink

    This is the purest form of sos2 binning that clamps the values in the [min, max] interval and then bins.

    This is the purest form of sos2 binning that clamps the values in the [min, max] interval and then bins.

    scala>  (0 to 10).map(_ / 4.0 - 0.25).map(v => s"$v\t${sos2(v, 0, 2, 1)}").foreach(println)
    -0.25  List((0,1.0))
    0.0    List((0,1.0))
    0.25   List((0,0.75), (1,0.25))
    0.5    List((0,0.5), (1,0.5))
    0.75   List((0,0.25), (1,0.75))
    1.0    List((1,1.0))
    1.25   List((1,0.75), (2,0.25))
    1.5    List((1,0.5), (2,0.5))
    1.75   List((1,0.25), (2,0.75))
    2.0    List((2,1.0))
    2.25   List((2,1.0))
    value

    number to be sos2 binned

    min

    minimum bin value

    max

    minimum bin value

    delta

    bin size

    returns

    sos2 binned value

  19. def sos2U(value: Option[Double], min: Long, max: Long, delta: Long, underflowKey: Option[String], unknown: Option[Iterable[(String, Double)]]): Iterable[(String, Double)]

    Permalink

    value

    number to be sos2 binned

    min

    minimum bin value

    max

    minimum bin value

    delta

    bin size

    underflowKey

    When value < min, an underflow key-value pair is emitted. This controls the key that is emitted.

    unknown

    When value is missing (None), a separate key-value pair is emitted. This controls the pair(s) that is/are emitted.

  20. def sos2U(value: Double, min: Long, max: Long, delta: Long): Iterable[(String, Double)]

    Permalink

    scala>  (0 to 10).map(_ / 4.0 - 0.25).map(v => s"$v\t${sos2U(v, 0, 2, 1)}").foreach(println)
    -0.25  List((=UNDERFLOW,1.0))
    0.0    List((=0,1.0))
    0.25   List((=0,0.75), (=1,0.25))
    0.5    List((=0,0.5), (=1,0.5))
    0.75   List((=0,0.25), (=1,0.75))
    1.0    List((=1,1.0))
    1.25   List((=1,0.75), (=2,0.25))
    1.5    List((=1,0.5), (=2,0.5))
    1.75   List((=1,0.25), (=2,0.75))
    2.0    List((=2,1.0))
    2.25   List((=2,1.0))
    value

    number to be sos2 binned

    min

    minimum bin value

    max

    minimum bin value

    delta

    bin size

    returns

    sos2 binned value

    Annotations
    @inline()
  21. def sos2U(value: Option[Double], min: Long, max: Long, delta: Long): Iterable[(String, Double)]

    Permalink
    Annotations
    @inline()
  22. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  23. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  24. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped