All Downloads are FREE. Search and download functionalities are using the official Maven repository.

au.csiro.variantspark.data.package.scala Maven / Gradle / Ivy

The newest version!
package au.csiro.variantspark
import org.apache.spark.rdd.RDD
import org.apache.spark.mllib.linalg.{Vectors, Vector}

package object data {

  implicit case object VectorDataBuilder extends DataBuilder[Vector] {
    def from(l: List[String]): Data = {
      VectorData(Vectors.dense(l.map(_.toDouble).toArray))
    }
    def from(v: Vector): Data = {
      VectorData(v)
    }
    def defaultVariableType: VariableType = ContinuousVariable
  }

  implicit case object ByteArrayDataBuilder
      extends DataBuilder[Array[Byte]] {
    def from(l: List[String]): Data = {
      ByteArrayData(l.map(_.toByte).toArray)
    }

    def from(v: Array[Byte]): Data = {
      ByteArrayData(v)
    }

    def defaultVariableType: VariableType = BoundedOrdinalVariable(3)
  }

  implicit case object IntArrayDataBuilder
      extends DataBuilder[Array[Int]] {
    def from(l: List[String]): Data = {
      IntArrayData(l.map(_.toInt).toArray)
    }

    def from(v: Array[Int]): Data = {
      IntArrayData(v)
    }

    def defaultVariableType: VariableType = OrdinalVariable
  }

  implicit def toFeatueConverter[V](v: RDD[V]): ToFeature[V] = new ToFeature[V](v)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy