[ 
https://issues.apache.org/jira/browse/SPARK-18226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16093483#comment-16093483
 ] 

Kirti commented on SPARK-18226:
-------------------------------

Hi Felix,

After collecting output of predict in R, probability column shows value such as 
 <environment: 0x4e82148>. This value can not be used further. I couldn't find 
any function in R or SparkR which can turn this value in readable string.

I used predict() in all SparkR functions such as saprk.logit, spark.LinearSVM, 
spark.randomForest etc and for each I am getting some environment values 
instead of probabilities.

Here is the code I am using.
#-------------------------------------------------
data("mtcars")
mtcars
df <- createDataFrame(sc, mtcars)

# Fit a random forest classification model with spark.randomForest
model <- spark.randomForest(df, mpg ~ cyl + disp + hp + drat, "classification", 
numTrees = 10)
summary(model)
predictions <- predict(model, df)
predictions$probabilitystr <- cast(predictions$probability, "string")
collect(predictions)

Thanks,
Kirti

> SparkR displaying vector columns in incorrect way
> -------------------------------------------------
>
>                 Key: SPARK-18226
>                 URL: https://issues.apache.org/jira/browse/SPARK-18226
>             Project: Spark
>          Issue Type: Bug
>          Components: SparkR
>    Affects Versions: 2.0.0
>            Reporter: Grzegorz Chilkiewicz
>            Priority: Trivial
>
> I have encountered a problem with SparkR presenting Spark vectors from 
> org.apache.spark.mllib.linalg package
> * `head(df)` shows in vector column: "<environment: 0x2bd5d10>"
> * cast to string does not work as expected, it shows: 
> "[1,null,null,org.apache.spark.sql.catalyst.expressions.UnsafeArrayData@79f50a91]"
> * `showDF(df)` work correctly
> to reproduce, start SparkR and paste following code (example taken from 
> https://spark.apache.org/docs/latest/sparkr.html#naive-bayes-model)
> {code}
> # Fit a Bernoulli naive Bayes model with spark.naiveBayes
> titanic <- as.data.frame(Titanic)
> titanicDF <- createDataFrame(titanic[titanic$Freq > 0, -5])
> nbDF <- titanicDF
> nbTestDF <- titanicDF
> nbModel <- spark.naiveBayes(nbDF, Survived ~ Class + Sex + Age)
> # Model summary
> summary(nbModel)
> # Prediction
> nbPredictions <- predict(nbModel, nbTestDF)
> #########################################
> # My modification to expose the problem #
> nbPredictions$rawPrediction_str <- cast(nbPredictions$rawPrediction, "string")
> head(nbPredictions)
> showDF(nbPredictions)
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to