-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a new optional Op for unloading xgboost models as Predictor obj…
…ects
- Loading branch information
1 parent
a90585f
commit dc4447c
Showing
18 changed files
with
311 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 0 additions & 51 deletions
51
mleap-xgboost-runtime/src/main/scala/ml/combust/mleap/xgboost/runtime/MyMain.scala
This file was deleted.
Oops, something went wrong.
20 changes: 9 additions & 11 deletions
20
...ime/XGBoostPerformantClassification.scala → ...time/XGBoostPredictorClassification.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...-xgboost-runtime/src/main/scala/ml/combust/mleap/xgboost/runtime/struct/FVecFactory.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package ml.combust.mleap.xgboost.runtime.struct | ||
|
||
import biz.k11i.xgboost.util.FVec | ||
import ml.combust.mleap.tensor.Tensor | ||
import org.apache.spark.ml.linalg.{DenseVector, SparseVector} | ||
|
||
import scala.collection.JavaConversions.mapAsJavaMap | ||
|
||
|
||
object FVecFactory { | ||
|
||
private def fromScalaMap(map: Map[Int, Float]): FVec = { | ||
val javaMap = mapAsJavaMap(map).asInstanceOf[java.util.Map[java.lang.Integer, java.lang.Float]] | ||
|
||
FVec.Transformer.fromMap(javaMap) | ||
} | ||
|
||
def fromSparseVector(sparseVector: SparseVector): FVec = { | ||
// Casting to floats, because doubles result in compounding differences from the c++ implementation | ||
// https://github.com/komiya-atsushi/xgboost-predictor-java/issues/21 | ||
val scalaMap = (sparseVector.indices zip sparseVector.values.map(_.toFloat)).toMap | ||
|
||
FVecFactory.fromScalaMap(scalaMap) | ||
} | ||
|
||
def fromDenseVector(denseVector: DenseVector): FVec = { | ||
// Casting to floats, because doubles result in compounding differences from the c++ implementation | ||
// https://github.com/komiya-atsushi/xgboost-predictor-java/issues/21 | ||
FVec.Transformer.fromArray(denseVector.values.map(_.toFloat), false) | ||
} | ||
|
||
def fromTensor(tensor: Tensor[Double]): FVec = FVecTensorImpl(tensor) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.