Try loading features as

Val userfeatures = sc.objectFile(path1)
Val productFeatures = sc.objectFile(path2)

And then call the constructor of the MatrixFsgtorizationModel with those.



Sent with Good (www.good.com)


-----Original Message-----
From: wanbo [gewa...@163.com<mailto:gewa...@163.com>]
Sent: Wednesday, January 07, 2015 10:54 PM Eastern Standard Time
To: user@spark.apache.org
Subject: Re: MatrixFactorizationModel serialization


I save and reload model like this:

val bestModel = ALS.train(training, rank, numIter, lambda)
bestModel.get.userFeatures.saveAsObjectFile("hdfs://***:9000/spark/results/userfeatures")
bestModel.get.productFeatures.saveAsObjectFile("hdfs://***:9000/spark/results/productfeatures")

val bestModel = obj.asInstanceOf[MatrixFactorizationModel]
bestModel.userFeatures.sparkContext.objectFile("hdfs://***:9000/spark/results/userfeatures")
bestModel.productFeatures.sparkContext.objectFile("hdfs://***:9000/spark/results/productfeatures")

But, there has same exception:

Exception in thread "Driver" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at
org.apache.spark.deploy.yarn.ApplicationMaster$$anon$2.run(ApplicationMaster.scala:162)
Caused by: java.lang.NullPointerException
        at
com.ft.jobs.test.ModelDeserialization$.main(ModelDeserialization.scala:138)
        at 
com.ft.jobs.test.ModelDeserialization.main(ModelDeserialization.scala)
        ... 5 more


Have fixed this issue?



--
View this message in context: 
http://apache-spark-user-list.1001560.n3.nabble.com/MatrixFactorizationModel-serialization-tp18389p21024.html
Sent from the Apache Spark User List mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@spark.apache.org
For additional commands, e-mail: user-h...@spark.apache.org

________________________________________________________

The information contained in this e-mail is confidential and/or proprietary to 
Capital One and/or its affiliates. The information transmitted herewith is 
intended only for use by the individual or entity to which it is addressed.  If 
the reader of this message is not the intended recipient, you are hereby 
notified that any review, retransmission, dissemination, distribution, copying 
or other use of, or taking of any action in reliance upon this information is 
strictly prohibited. If you have received this communication in error, please 
contact the sender and delete the material from your computer.

Reply via email to