Difference between revisions of "Cholera MapReduce Application"

From CSE231 Wiki
Jump to: navigation, search
(Code To Implement)
(Code To Implement)
Line 39: Line 39:
 
In order to provide a more open-ended assignment, we have abstracted out different aspects of the studio.  Of particular note is <code>getValueRepresentation()</code> which allows you to specify whether high or low numbers are suspect.  That is: if you return <code>CholeraAppValueRepresentation.HIGH_NUMBERS_SUSPECT</code> you are indicating that a higher number is more likely to indicate that the water pump is the source of the cholera outbreak.  This will aid the [[#Visualization]] in presenting your findings.  We have anticipated two basic approaches to this problem (with a variation^2 on one of the approaches).  If you take a different approach than one we have anticipated, that is fine.  Get it checked out by an instructor.
 
In order to provide a more open-ended assignment, we have abstracted out different aspects of the studio.  Of particular note is <code>getValueRepresentation()</code> which allows you to specify whether high or low numbers are suspect.  That is: if you return <code>CholeraAppValueRepresentation.HIGH_NUMBERS_SUSPECT</code> you are indicating that a higher number is more likely to indicate that the water pump is the source of the cholera outbreak.  This will aid the [[#Visualization]] in presenting your findings.  We have anticipated two basic approaches to this problem (with a variation^2 on one of the approaches).  If you take a different approach than one we have anticipated, that is fine.  Get it checked out by an instructor.
  
{{CodeToImplement|CholeraApp|getValueRepresentation<br>createMapper<br>createCollector|mapreduce.apps.cholera.studio}}
+
{{CodeToImplement|CholeraApp|getValueRepresentation<br>getValueClass<br>createMapper<br>createCollector|mapreduce.apps.cholera.studio}}
  
 
==getValueRepresentation==
 
==getValueRepresentation==
Line 49: Line 49:
 
HIGH_NUMBERS_SUSPECT, LOW_NUMBERS_SUSPECT, LOW_NUMBERS_SUSPECT_SQUARED
 
HIGH_NUMBERS_SUSPECT, LOW_NUMBERS_SUSPECT, LOW_NUMBERS_SUSPECT_SQUARED
 
}</nowiki>
 
}</nowiki>
 +
 +
==getValueClass==
 +
{{Sequential|public static Class<? extends Number> getValueClass()}}
 +
 +
return <code>Integer.class</code> or <code>Double.class</class>, as appropriate.
  
 
==createMapper==
 
==createMapper==

Revision as of 11:04, 26 February 2020

John Snow memorial and pub.jpg

Motivation

Epidemiology is the important study of "why certain people are getting ill."

We get a chance to make sense of the data in a relatively open-ended studio.

Background

Imagine you are a physician in 1854 London in the midst of a cholera outbreak. Your theory that contaminated water is the cause meets resistance from the medical establishment which holds that it is spread via the air.

Imagine further that your friend Ada has left you access to computing.

Code To Use

We have made the data from this GIS Analysis available via methods:

class Location

double getDistanceTo( Location other )

class CholeraDeath

Location getLocation()

enum WaterPump

Location getLocation()

class SohoCholeraOutbreak1854

static CholeraDeath[] getDeaths()

Code To Implement

In order to provide a more open-ended assignment, we have abstracted out different aspects of the studio. Of particular note is getValueRepresentation() which allows you to specify whether high or low numbers are suspect. That is: if you return CholeraAppValueRepresentation.HIGH_NUMBERS_SUSPECT you are indicating that a higher number is more likely to indicate that the water pump is the source of the cholera outbreak. This will aid the #Visualization in presenting your findings. We have anticipated two basic approaches to this problem (with a variation^2 on one of the approaches). If you take a different approach than one we have anticipated, that is fine. Get it checked out by an instructor.

class: CholeraApp.java Java.png
methods: getValueRepresentation
getValueClass
createMapper
createCollector
package: mapreduce.apps.cholera.studio
source folder: src/main/java

getValueRepresentation

method: public static CholeraAppValueRepresentation getValueRepresentation() Sequential.svg (sequential implementation only)

return one of the three values to aid the visualization and testing:

public enum CholeraAppValueRepresentation {
	HIGH_NUMBERS_SUSPECT, LOW_NUMBERS_SUSPECT, LOW_NUMBERS_SUSPECT_SQUARED
}

getValueClass

method: public static Class<? extends Number> getValueClass() Sequential.svg (sequential implementation only)

return Integer.class or Double.class</class>, as appropriate.

createMapper

method: <code>public static Mapper<CholeraDeath, WaterPump, Number> createMapper()</code> Sequential.svg (sequential implementation only)

We have implemented WaterPump as an enum. You can access the enum constants of any enum via its values() method. For example:

for (WaterPump pump : WaterPump.values()) {
}

createCollector

Depending on your approach, you may be able to reuse one of your existing Collectors. Otherwise, implement one to go with your Mapper.

method: <code>public static Collector<? extends Number, ?, ? extends Number> createCollector()</code> Sequential.svg (sequential implementation only)

OPTIONAL getThresholdIfApplicable

We have noted that some students have been going with a threshold approach. In order to support this in the visualization and the test (and to minimize the chances of interfering with students who have already started) we have added a separate class file CholeraThreshold. You need not concern yourself with this file if you are going with a threshold-less strategy.

class: CholeraApp.java Java.png
methods: getThresholdIfApplicable
package: mapreduce.apps.cholera.studio
source folder: src/main/java

method: <code>public static double getThresholdIfApplicable()</code> Sequential.svg (sequential implementation only)

Return the threshold if you are using one in your Mapper. Otherwise return Double.NaN.

	public static double getThresholdIfApplicable() {
		final boolean IS_THRESHOLD_APPLICABLE = false;
		if (IS_THRESHOLD_APPLICABLE) {
			throw new NotYetImplementedException();
		} else {
			return Double.NaN;
		}
	}

Testing Your Solution

Visualization

Original Map Drawn By John Snow:

Snow-cholera-map-1.jpg

Our Visualization App:

class: CholeraOutbreakVisualizationApp.java VIZ
package: mapreduce.apps.cholera.viz
source folder: src/visualization/java

CholeraOutbreak.png

Correctness

If you have chosen to go a different route than the ones we anticipated, do not worry about passing the test suite. Demo your work to an instructor in class and we can discuss its fitness.

class: CholeraStudioTestSuite.java Junit.png
package: mapreduce
source folder: src/test/java