我使用spark mllib创建线性回归模型。然后我尝试将模型保存在ObjectOutputStream中,因此我可以将它放在s3上并稍后读取。以下是我的代码:
val algorithm = new LinearRegressionWithSGD()
val model = algorithm.run(trainingData)
val credentials = new BasicAWSCredentials("myKey", "mySecretKey");
val s3Client = new AmazonS3Client(credentials);
val oos = new ObjectOutputStream(new FileOutputStream("myModelFile"));
oos.writeObject(model);
oos.close();
s3Client.putObject("myBucket", "myPath", oos)
然后我在线上抱怨:
s3Client.putObject("myBucket", "myPath", oos)
我错过了什么以及如何修复它?非常感谢!