scala - How to infer the predicted class label from Spark MLlib computed raw score -


reading spark doc below

https://spark.apache.org/docs/latest/mllib-optimization.html

the sample code segment binary classification prediction below:

    val model = new logisticregressionmodel(     vectors.dense(weightswithintercept.toarray.slice(0,weightswithintercept.size - 1)),     weightswithintercept(weightswithintercept.size - 1))      // clear default threshold.     model.clearthreshold()     // compute raw scores on test set.    val scoreandlabels = test.map { point =>    val score = model.predict(point.features)    (score, point.label) 

as see model.prediction(point.features) return raw scores margin of distances hyperplane separations.

my question is:

(1) how can know if prediction class label 0 or 1 based upon above computed raw scores ?

or

(2) how infer predicted class label (0, or 1) in binary classification case above computed raw scores ?

by default, threshold value 0.5, when using binaryclassificationmetrics, give class label 0 if score < 0.5 , 1 if higher. can same infer class score.


Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -