support different types of filesystems
This commit is contained in:
parent
00e7e4eef0
commit
6558ef3273
@ -129,7 +129,8 @@ object XGBoost extends Serializable {
|
||||
* @return The loaded model
|
||||
*/
|
||||
def loadModelFromHadoop(modelPath: String)(implicit sparkContext: SparkContext): XGBoostModel = {
|
||||
val dataInStream = FileSystem.get(sparkContext.hadoopConfiguration).open(new Path(modelPath))
|
||||
val path = new Path(modelPath)
|
||||
val dataInStream = path.getFileSystem(sparkContext.hadoopConfiguration).open(path)
|
||||
val xgBoostModel = new XGBoostModel(SXGBoost.loadModel(dataInStream))
|
||||
xgBoostModel
|
||||
}
|
||||
|
||||
@ -50,7 +50,8 @@ class XGBoostModel(booster: Booster)(implicit val sc: SparkContext) extends Seri
|
||||
* @param modelPath The model path as in Hadoop path.
|
||||
*/
|
||||
def saveModelToHadoop(modelPath: String): Unit = {
|
||||
val outputStream = FileSystem.get(sc.hadoopConfiguration).create(new Path(modelPath))
|
||||
val path = new Path(modelPath)
|
||||
val outputStream = path.getFileSystem(sc.hadoopConfiguration).create(path)
|
||||
booster.saveModel(outputStream)
|
||||
outputStream.close()
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user