# WiFi localization using machine learning

I am trying to determine which room a person is in based on WiFi measurements. I currently have WiFi measurements for 3 rooms. The measurement consists of 100 WiFi scans collected from different locations inside each room. Each scan shows the number of WiFi APs visible at at some location inside the room. The number of APs seen in each of the 100 scans is variable. Here is one such scan:

1.SSID: wireless, BSSID: 00:21:6c:63:cc:dd, ss: -54, frequency: 2437
2.SSID: visitor, BSSID: 00:24:6c:61:aa:bb, ss: -58, frequency: 2462
3.SSID: visitor, BSSID: 00:24:6e:6d:ab:ab, ss: -60, frequency: 2437


ss: signal strength

This is taken from a single scan out of the 100 scans collected for each room.

Each scan is like one feature set for the room. I need to somehow train my system using this data so that it is able to classify a scan (may have multiple APs) taken during testing, to a particular room. What supervised training algorithm can I use? I already tried SVMs but they don't allow variable feature set.

-
You might make headway by viewing each AP and its signal strength as providing an update of a prior multinomial probability distribution for presence in the rooms. (In fact, if your training coverage is reasonably complete, you could go further to generate a spatial probability distribution for the exact location.) Bayes' theorem provides the update mechanism. –  whuber Mar 27 '12 at 22:58

Could you simply take all APs that you saw in any reading to create a set $AP$ and fill in 0 strength for APs which do not appear in a particular scan? So a particular scan would be recorded as $S_i = {s_1, s_2, s_3, \dots, s_n}$ where each $s_i$ is the strength of $AP_i$.

That is if there were $n$ unique APs seen in all scans, each $S_i$ would be $n$ entries (ss's) long. That way, you do not have variable-length features.

-

Here is a sketch of a naive Bayes solution.

1. Define $X_i$ as the $4$-tuple $(SSID_i, BSSID_i, SS_i, FREQ_i)$.

2. Denote the indicator of room $j$ by $R_j$, for $j=1,2,3$.

3. Use the frequencies in your sample to especify $P(X_i\mid R_j)$ as the number of times the $4$-tuple $X_i$ was observed in room $R_j$ divided by the total number of $4$-tuples observed in room $R_j$.

4. Give prior probability $P(R_j)=1/3$ to each room.

5. Given a new observed $4$-tuple $Y$, use Bayes Theorem to compute $$P(R_j\mid Y) = \frac{P(Y\mid R_j)P(R_j)}{\sum_{k=1}^3 P(Y\mid R_k)P(R_k)} \, .$$

6. Make a decision: classify $Y$ as coming from the room with highest posterior probability.

Use this as a starting point and sophisticate it. An immediate possibility is to introduce some kind of smoothing: http://en.wikipedia.org/wiki/Additive_smoothing

-