concept confidence level in category spark

appears as: confidence level, confidence level
Spark in Action, Second Edition

This is an excerpt from Manning's book Spark in Action, Second Edition.

In this dataset, the two last columns are the lower and upper confidence limits, respectively. These indicate the confidence level in the birth rate.

The way to do this is to use conditional functions such as when() and otherwise() . If the confidence is less than or equal to 40, the confidence level is low. Otherwise, the confidence level is null :

int low = 40;
       int high = 100;
...
            .withColumn(
                 "confidence_level" ,
 col( "confidence" ).$less$eq( low ), "low" ))

If the confidence is greater than 40 and less than 100, the confidence level is nominal. Otherwise, the confidence level remains at its current value (at this stage, the confidence level can be low or null ):

.withColumn(
                 "confidence_level" ,
                when(
                      col( "confidence" ).$greater( low )
                            .and(col( "confidence" ).$less( high )),
                       "nominal" )
                             .otherwise(col( "confidence_level" )))

If the confidence level is null , set it to high: