[jvm-packages] change class to object in examples (#1703)
* change class to object in examples * fix compilation error
This commit is contained in:
parent
016ab89484
commit
f801c22710
@ -17,7 +17,6 @@
|
||||
package ml.dmlc.xgboost4j.scala.example
|
||||
|
||||
import java.io.File
|
||||
import java.util
|
||||
|
||||
import scala.collection.mutable
|
||||
|
||||
@ -25,9 +24,8 @@ import ml.dmlc.xgboost4j.java.{DMatrix => JDMatrix}
|
||||
import ml.dmlc.xgboost4j.java.example.util.DataLoader
|
||||
import ml.dmlc.xgboost4j.scala.{XGBoost, DMatrix}
|
||||
|
||||
class BasicWalkThrough {
|
||||
object BasicWalkThrough {
|
||||
def main(args: Array[String]): Unit = {
|
||||
import BasicWalkThrough._
|
||||
val trainMax = new DMatrix("../../demo/data/agaricus.txt.train")
|
||||
val testMax = new DMatrix("../../demo/data/agaricus.txt.test")
|
||||
|
||||
@ -82,9 +80,7 @@ class BasicWalkThrough {
|
||||
val predicts3 = booster3.predict(testMax2)
|
||||
println(checkPredicts(predicts, predicts3))
|
||||
}
|
||||
}
|
||||
|
||||
object BasicWalkThrough {
|
||||
def checkPredicts(fPredicts: Array[Array[Float]], sPredicts: Array[Array[Float]]): Boolean = {
|
||||
require(fPredicts.length == sPredicts.length, "the comparing predicts must be with the same " +
|
||||
"length")
|
||||
|
||||
@ -20,7 +20,7 @@ import scala.collection.mutable
|
||||
|
||||
import ml.dmlc.xgboost4j.scala.{XGBoost, DMatrix}
|
||||
|
||||
class BoostFromPrediction {
|
||||
object BoostFromPrediction {
|
||||
def main(args: Array[String]): Unit = {
|
||||
println("start running example to start from a initial prediction")
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ import scala.collection.mutable
|
||||
|
||||
import ml.dmlc.xgboost4j.scala.{XGBoost, DMatrix}
|
||||
|
||||
class CrossValidation {
|
||||
object CrossValidation {
|
||||
def main(args: Array[String]): Unit = {
|
||||
val trainMat: DMatrix = new DMatrix("../../demo/data/agaricus.txt.train")
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ import org.apache.commons.logging.{LogFactory, Log}
|
||||
* function
|
||||
*
|
||||
*/
|
||||
class CustomObjective {
|
||||
object CustomObjective {
|
||||
|
||||
/**
|
||||
* loglikelihoode loss obj function
|
||||
|
||||
@ -20,7 +20,7 @@ import scala.collection.mutable
|
||||
|
||||
import ml.dmlc.xgboost4j.scala.{XGBoost, DMatrix}
|
||||
|
||||
class ExternalMemory {
|
||||
object ExternalMemory {
|
||||
def main(args: Array[String]): Unit = {
|
||||
// this is the only difference, add a # followed by a cache prefix name
|
||||
// several cache file with the prefix will be generated
|
||||
|
||||
@ -25,7 +25,7 @@ import ml.dmlc.xgboost4j.scala.example.util.CustomEval
|
||||
* this is an example of fit generalized linear model in xgboost
|
||||
* basically, we are using linear model, instead of tree for our boosters
|
||||
*/
|
||||
class GeneralizedLinearModel {
|
||||
object GeneralizedLinearModel {
|
||||
def main(args: Array[String]): Unit = {
|
||||
val trainMat = new DMatrix("../../demo/data/agaricus.txt.train")
|
||||
val testMat = new DMatrix("../../demo/data/agaricus.txt.test")
|
||||
|
||||
@ -20,7 +20,7 @@ import scala.collection.mutable
|
||||
import ml.dmlc.xgboost4j.scala.example.util.CustomEval
|
||||
import ml.dmlc.xgboost4j.scala.{XGBoost, DMatrix}
|
||||
|
||||
class PredictFirstNTree {
|
||||
object PredictFirstNTree {
|
||||
|
||||
def main(args: Array[String]): Unit = {
|
||||
val trainMat = new DMatrix("../../demo/data/agaricus.txt.train")
|
||||
|
||||
@ -22,7 +22,7 @@ import scala.collection.mutable
|
||||
|
||||
import ml.dmlc.xgboost4j.scala.{XGBoost, DMatrix}
|
||||
|
||||
class PredictLeafIndices {
|
||||
object PredictLeafIndices {
|
||||
|
||||
def main(args: Array[String]): Unit = {
|
||||
val trainMat = new DMatrix("../../demo/data/agaricus.txt.train")
|
||||
|
||||
@ -35,7 +35,7 @@ case class Store(storeId: Int, storeType: String, assortment: String, competitio
|
||||
competitionOpenSinceMonth: Int, competitionOpenSinceYear: Int, promo2: Int,
|
||||
promo2SinceWeek: Int, promo2SinceYear: Int, promoInterval: String)
|
||||
|
||||
object Main {
|
||||
object SparkModelTuningTool {
|
||||
|
||||
private def parseStoreFile(storeFilePath: String): List[Store] = {
|
||||
var isHeader = true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user