Package

com.eharmony.aloha

feature

Permalink

package feature

Visibility
  1. Public
  2. All

Type Members

  1. trait BasicMath extends AnyRef

    Permalink
  2. trait Comparisons extends AnyRef

    Permalink
  3. trait CustomSos2 extends AnyRef

    Permalink
  4. trait DefaultPossessor extends AnyRef

    Permalink
  5. trait Indicator extends AnyRef

    Permalink
  6. trait Intercept extends AnyRef

    Permalink
  7. trait MapImplicitRegressionConversion extends AnyRef

    Permalink

    This class is designed to convert Map[String, X] to Iterable[(String, Double)] if it's easy to convert X to Double.

  8. trait OptionLifting extends AnyRef

    Permalink

    These can be useful for models requiring implicit feature conversion a "primitive" type to an option of that type.

    These can be useful for models requiring implicit feature conversion a "primitive" type to an option of that type. This is most useful for when we need to be able to supply a default feature value without knowing anything about the type. If the type is in a context then the zero element for the context can be used without additional information about the inner type.

    This definition allows the feature author to be sloppy about types so there is no blanket method:

    implicit def liftToOption[A](a: A): Option[A] = Option(a)
  9. trait OptionMath extends AnyRef

    Permalink

    Provides basic inline unary and binary mathematical operators for options of primitive types including.

    Provides basic inline unary and binary mathematical operators for options of primitive types including.

    - Option[Byte] - Option[Short] - Option[Int] - Option[Long] - Option[Float] - Option[Double]

    Additionally, operations are provided that can take any scala.math.Numeric type as long as an implicit of that type is available at call time.

    This functionality assumes that the type arguments are the same as it relies on scala.math.Numeric. When the types are the same, everything works seamlessly.

    import com.eharmony.aloha.feature.OptionMath.Syntax._
    
    scala> Option(1) + None
    res0: Option[Int] = None
    
    scala> None + Option(1)
    res1: Option[Int] = None
    
    scala> Option(1) + Option(2)
    res3: Option[Int] = Some(3)
    
    scala> Some(1L.toInt) + Option(2)
    res4: Option[Int] = Some(3)
    
    scala> Option(1) < Option(2)
    res5: Option[Boolean] = Some(true)
    
    scala> Option(1) >= Option(2)
    res6: Option[Boolean] = Some(false)
    
    scala> Option(1) < None
    res7: Option[Boolean] = None

    When the types for the function arguments don't line up, we get a compile time error.

    scala> Some(1) + Some(1.5)
    <console>:12: error: type mismatch;
    found   : Double(1.5)
    required: Int
                 Some(1) + Some(1.5)
                                ^

    Because inline operations require the use of implicit classes, inline syntax will incur an object creation overhead that using OptMathOps will not.

    import com.eharmony.aloha.feature.OptionMath.Syntax._
    import com.eharmony.aloha.feature.OptionMath.OptMathOps
    
    val a = Option(1.5)
    val b = Option(0.5)
    
    val c = a / b                 // Additional object creation involved (slower, prettier)
    val d = OptMathOps.div(a, b)  // Less object creation involved (faster, uglier)
    
    assert(c == d)

    Notice that the usual order of operations in the same.

    import com.eharmony.aloha.feature.OptionMath.Syntax._
    
    scala> Option(10 % 4 / 2) == Option(10) % Option(4) / Option(2)
    res0: Boolean = true
  10. trait ParallelSkipGrams extends AnyRef

    Permalink
  11. trait SkipGrams extends AnyRef

    Permalink

  12. trait Sos2 extends AnyRef

    Permalink

    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.

    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)
  13. trait SparsityTransforms extends AnyRef

    Permalink

    Provides ways to transform items from between dense and sparse domains.

  14. trait TimeConstants extends AnyRef

    Permalink

    A bunch of constants taken from Joda-Time because we don't necessarily want to include Joda-Time but want access to the constants.

    A bunch of constants taken from Joda-Time because we don't necessarily want to include Joda-Time but want access to the constants. If using Joda-Time, just include those.

Ungrouped