Enrollments Open for Advanced Certification Courses on Data Science, ML & AI by E&ICT Academy IIT Roorkee

  Apply Now

Apache Spark - Problem Solving - Compute Average

INSTRUCTIONS
  • How to compute average?

    Approach 1:

    var rdd = sc.parallelize(Array(1.0,2,3, 4, 5 , 6, 7), 3);
    var avg = rdd.reduce(_ + _) / rdd.count();
    

    Approach 2:

    var rdd = sc.parallelize(Array(1.0,2,3, 4, 5 , 6, 7), 3);
    var rdd_count = rdd.map((_, 1))
    var (sum, count) = rdd_count.reduce((x, y) => (x._1 + y._1, x._2 + y._2))
    var avg = sum / count
    

No hints are availble for this assesment

Answer is not availble for this assesment

Loading comments...