def item_features(self): """ The item features. Underlying model parameters. """ return XArray.from_rdd(self.model.productFeatures(), list)
def user_features(self): """ The user features. Underlying model parameters. """ return XArray.from_rdd(self.model.userFeatures(), list)
def _base_predict(self, data): """ Call the model's predict function. Data can be a single item or a collection of items. """ features = self.make_features(data) if isinstance(features, DenseVector): return self.model.predict(features) if isinstance(features, XArray) and issubclass(features.dtype(), DenseVector): res = self.model.predict(features.to_spark_rdd()) return XArray.from_rdd(res, float) raise TypeError('must pass a DenseVector or XArray of DenseVector')