1
$\begingroup$

I have data that includes a number of weather measurements and a dependent variable that represents whether the weather caused delivery delays for couriers in my company (represented by 0 or 1), grouped by zipcode. Every zipcode has a slightly different behaviour however; in one zipcode 1 inch of snow would cause a problem, while another zipcode might only have issues after 3 inches falls.

I want to be able to group together zipcodes based on similar behaviour. To express that another way, I don't want to cluster based on similar weather measurements, but on the interaction between the weather measurements and the dependent variable.

Can you suggest any way of doing this?

$\endgroup$
1
$\begingroup$

You will want to choose some way of normalizing the weather metrics for the given zip code context. For example, you might compute the additional feature "rain fall percentile within all rainfall for that zip code." Or "percent of annual rainfall for zip code"

Given this specific example, you may alternately assign geographic coordinates based on zip and then look to remove linear relations between month, longitude, latitude, and rainfall to produce an rainfall adjusted for location and season. This would work better on zip code with lass data since the results will be interpolated using nearby regions.

$\endgroup$
0
$\begingroup$

For each zip code, there is some functional relationship f between the input weather variables x and the delay d: d = f(x). If you can represent that function by a set of parameters, then you can put those parameters into a vector. That vector represents the function for the given ZIP code. Then cluster those vectors (one vector for each ZIP). That accomplishes your goal. So the trick is finding a vector that has a one-to-one mapping to the function.

For instance, this might be simpler to visualize if d was a real number representing the delay time, not just a binary indicator. Suppose that the functional relationship is linear, that is, d = f(x) = ax + b, where a and x are vectors of the same length. a is a vector of constants, b is a constant, and x is the vector of independent weather variables. Based on the x and d data for a given ZIP code, find a and b through, say, linear regression. Then, construct the vectors [a,b], one for each ZIP code, and cluster them. The vectors that cluster together mean they have a similar functional relationship for their associated ZIP, as requested.

For your case where d is binary, the general idea still holds. The equivalent function for defining similar behavior could be a function that defines a surface separating the two classes (the class where d = 0 and the class where d = 1). Suppose for a minute that the two classes are linearly separable. Then, for each ZIP code, there is a best separating hyperplane that could be found using, say, a SVM (Support Vector Machine). That hyperplane is defined by ax + b = 0, where again, a and x are vectors, and you are using known x and d to find a and b.

So, for each ZIP code, find the best separating hyperplane parameters a and b, using, say, SVM. Once again, construct the vectors [a,b], one for each ZIP code, and cluster them. The clusters are those that have a similar functional behavior for weather, as requested. If the classes are not linearly separable in a fundamental way (more than just having an outlier or two), you could pick some kernel function and use the kernel trick, but that probably won't be necessary, especially if d increases monotonically with each of the independent variables.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.