\subsection{Contrast Set Learning}
Much learning in life is done through observations of examples. If one considers 
various similar examples to be grouped into separate populations, much of what can be learned lies in what separates them.
Contrast set learning is a quality optimization technique that provides the ability to distinguish the differences 
between two populations. In the case of {\W} the sets to be contrasted are the similar 
cases which exemplify the best and worst examples for the class being optimized for. 
This is done by the examining the frequency at which each attribute appears in the two sets, 
with heavier weight on the appearances in best cases while still factoring out too much presence with the rest.

What should come of this is to be able to identify specific attributes which are correlated to membership of the best set.  
The desire to incorporate CSL decision making into case based reasoning quality optimization 
software was the motivation for {\W}'s initial development. In essence, {\W} was designed as a case based reasoner 
with the added ability of performing contrast set learning. {\W}'s case relevancy filtering was improved upon 
in {\W}2 by replacing the k-th nearest neighbor computations with a simple, linear time, overlap method.

\subsection{{\W}2 Algorithm}

To perform its function, {\W}2 requires two sets of data: a training dataset and a project 
description or test case known as the query. Once this information becomes available, {\W}2 randomly splits 
the dataset into 67\% training cases and 33\% testing cases. 

The training instance set is 
then put through relevancy filtering so as to retrieve only those cases with enough 
similarity to the query. As mentioned before this was originally done using k nearest neighbors, 
which runs in n squared time, and later changed in {\W}2 to a linear time overlap method. 
Cases are ranked and selected based on how well they were contained within the query space. For 
each attribute in a case, the case in question was compared to the project query. If the case's 
value matches the query, the case scores a point for that attribute. These scores are summed and 
ranked by how many attributes overlap with the query.

The resulting set of projects is sorted using some metric of 
utility and split into a best set and a rest set. In the case of a single class query the utility 
score will simply be the class value, if there is more than one class a combined score will be 
generated which takes all of them into account. This metric allows the learner to optimize 
for the highest combined values of any number of classes given. 

From the set of cases sorted by their utility metric the top k1 rows are placed in a set 
called best, while the remaining k2 values are placed in a set called rest. The numbers 
k1 and k2 are set on runtime with a defult value of 5 and 15. More on the effects of these 
numbers will be discussed later. 

{\W}2 then proceeds to generate a contrast set that it uses to find the specific attributes 
which most push the test project towards the cases found in the best set. 
The following equation is used to create this set, using attributes flagged as controllable:

\begin{equation}\label{eq:br}
like = \frac{freq(x\vert best)^2}{freq(x\vert best) + freq(x\vert rest)}
\end{equation}

Once the sorted contrast set is generated the learner tries sequential combinations of 
attributes from the beginning of the set, stopping when the data is over-fit or no 
improvement is made by using more attributes.
At this point {\W}2 takes the attribute recommendations 
from its previous step and estimates their success at improving the test instance. Upon 
exiting, {\W}2 outputs the attribute recommendations it thinks are most likely to lead the 
test project towards optimization.
