\chapter{Co-located Users Contextual Social Networking and Recommendation}\label{chap:contextual-sn}
{

\begin{quote}
\textit{
In this chapter we propose methods to be used in contextual social networks for the recommendation of potential friends, local experts and targeted services. The recommendation is based on an hybrid approach which combines content-based techniques, collaborative filtering and social media analysis. We also introduce the concept of co-located social network, explain why and how it can improve user engagement and, finally, we present the results in a mobile web-based social network application available only in the check-in area of an airport. The friend prediction algorithm has been evaluated through a user study on the demo application to measure the effectiveness of the recommendation.
\footnote{Part of this chapter has been published as \dquote{PITAGORA: Recommending Users and Local Experts in an Airport Social Network} in \textit{Proceedings of the 23rd ACM international conference on Multimedia, pp.~755-756, 2015}~\cite{ferracani2015pitagora}.}
}
\end{quote}

\section{Motivations and Previous Work}

With regard to context-based applications, the concept of context can be referred to where a user is, who she/he is with and what resources are nearby~\cite{schilit1994context}.  Contextual social networks can be seen as a variant of social networks where information about context is incorporated into the social network services~\cite{woerndl2007utilizing}. Knowledge that can be extracted from online social network (e.g. Facebook and LinkedIn), along with information about the location, can be exploited in order to build a variety of contextual services, such as recommendation of people and activities.

In this paper we propose techniques of data analysis from social media to enhance friend and local experts recommendation for a social network only available in the subnet of a building, in the specific in the check-in area of an airport. The demo of the social network is a mobile web application we developed to collect data, test and validate the system. The proposed architecture, however, can be applied also in other domains and real locations where social networking applications could be used to offer contextual services. Contextual social networking techniques can be effective inside an airport, but also elsewhere, as better as the needs of visitors can be identified. In the check-in area of an airport people basically has to optimise their time and have the opportunity to get in touch with other people. Usually passengers are in airport for business trips or leisure and, in both cases, it has been demonstrated that they are more open to new experiences and social interactions than usual. In fact, some experiments~\cite{Rubin1975233} has been conducted that show how strangers in airport departure lounges have an higher degree of disposability to self disclosure. 

Recommendations systems for friend prediction are very popular on the web but they still lack a footprint that can link social network users, temporarily co-located in the same place, to the services and opportunities of the place itself. Also the so-called contextual social networks are somehow ephemeral, based on general data such as social relation, interaction data, individual preference or interpersonal influence~\cite{Jiang2012}. These networks foster meaningful interactions based on real relationships, shared interests, activities but can acquire a real value only taking into account the real intentions of users, especially in a situation where a lot of people is co-located .

In the case of an airport lounge, for example, the destination of a passenger, the type of trip (professional or not professional) or the shops present in the building are definitely essential infos from which friendship prediction or content recommendation based on user profiles can really benefit. A lot of works have been published in the last years addressing the problem of recommendations in Location-based Social Networks (LBSNs) using content based recommendation and collaborative filtering both for the suggestions of potential friends and the discovery of popular users (e.g. local experts, opinion leaders). At this regard content-based recommenders are costly, need maintenance, don't consider social opinion but are a valuable solution in particular to solve the cold start scenario. Collaborative filtering instead considers similar user preferences and uses a similarity model for score prediction. If it solves issues related to maintenance and availability of community opinion informations, suffers from possible issues due to data sparsity and system scalability~\cite{bao2014}. Friends recommendation can be achieved analysing online user profiles and social graph interactions~\cite{chen2009make}. In this respect common connections or users degree of separation can be a valuable information especially if users accessing the network are co-located in the real world. Other Standard recommendation approaches are based again on content based analysis and collaborative filtering but also considering the social graphs and social interactions.  A matrix factorization method which uses individual preference and interpersonal influence to improve the accuracy of social recommendation is proposed in~\cite{Jiang2012}. The work stresses the fact that social influence is a powerful force which governs the dynamics of a social network. Some works exploit user location histories for recommendation. A correlation between different places and cities visited by users is computed on the basis of the trajectories followed by several people in local areas in~\cite{Vansteenwegen20116540} considering location-location distance and sequential ordering of visiting patterns. Zheng et al.~\cite{Zheng2009} recommend local experts in a city analysing user location histories as GPS trajectories through a Hypertext Induced Topic Search inference model over a Tree-Based Hierarchical Graph. At this end user's geo-tagged social media content has also been exploited~\cite{Arase2010}.  

Recommendation approaches we propose are exploited and validated in a mobile contextual social network designed to be used by passengers inside of an airport structure: the network allows the user to obtain infos on his flight (e.g. status, time to gate close etc.), to interact with other passengers sharing his volatile or professional interests (e.g. to chat) and to receive personalised recommendations based on his/her preferences. The main goal is to improve the users travel experience bridging the gap between physical and virtual world exploiting traces and data available in Location Based Social Networks (LBSN) or collected through the application. Users can connect through Facebook and LinkedIn and their online data is used to build users' interests profiles and to recommend similar people and services. Destination information is exploited to suggest local destination experts present at the airport or on the same flight; retails semantics are used to suggest activities and places for dating through profile content analysis and matching between the users' mutual interests.

The remainder of this chapter is organised as follows: Section~\ref{sec:system} describes the overall system, focusing on the two main recommendation modules: friends prediction in Section~\ref{sec:user_recommendation} and local experts suggestion in Section~\ref{sec:local_experts}. Evaluation and experiments on the recommendation system are proposed in Section~\ref{sec:eval}.


\section{Contextual social network}\label{sec:system}
The end user interface has been developed as a mobile web application to be used in the context of a lounge of an airport. The goal of the application is to improve passengers experience providing a social network of co-located users able to recommend people and services contextual to the location and the user intentions. The application allows the user to search and display flight infos, to check the presence of other passengers on his same flight and to communicate with them through a real time chat. The main purpose of the application is to enhance the social interaction between users that are present in the airport at the same time. Recommendations are mainly constituted by suggestions of other users who share the same interests as well as of services within the airport (e.g. retails). The application also provides the passenger with a recommendation system of local experts, present at the airport, on the basis of his/her flight destination. The system uses an hybrid approach to the recommendation problem combining content-based filtering and collaborative filtering. Hybrid approaches have been proved to give better results than content-based filtering and collaborative filtering techniques solving issues related to the large amount and the sparsity of the data~\cite{robillard2014}.


\subsection{Users Recommendation and friends prediction}\label{sec:user_recommendation}
Users are profiled analysing data extracted by their Facebook and LinkedIn accounts and represented as a graph of users, interests and demographic infos modelled with hierarchical relationships. The different nature of this data is exploited in order to obtain recommendations concerning leisure (Facebook) and professional aspects (LinkedIn). When the user logs into the system using one of the two possible networks the following data are extracted: \begin{itemize}
\item demographic infos, level of education, job history (Facebook and LinkedIn);
\item photo albums (Facebook)
\item groups and companies followed (LinkedIn)
\end{itemize}.

Users' recommendation in the airport mobile contextual social network, is presented in two ways: as a list of possible friends and as a list of categories of interests extracted from Facebook that groups those friends (see Fig.~\ref{fig:friends_recom}). 

\begin{figure}[!htb]
\centering
\includegraphics[width=0.46\textwidth]{figs/friends_recommendation.png}
\caption{Recommendation of friends as proposed in the application, along with common items and interests.}
\label{fig:friends_recom}
\end{figure}

Friends recommendation is based only on Facebook profiles but the same approach could be used also for any other social network. Profiles are described as vectors of pages on which users have expressed a `like'. Although a standard collaborative filtering approach could have been used to estimate a neighbourhood of similar users, a main issue has to be addressed that is the sparsity of the dataset: in fact the number of Facebook pages is much bigger than the number of `likes' that a single user can express. In order to solve the sparsity problem, the user recommendation module uses the co-occurence matrix approach to estimate additional possible items of interests. Users' recommendation is then achieved with a standard user-based algorithm considering the distribution of user interests and computing a users' neighbourhood with the Euclidean distance. Sparsity reduction is performed offline, using an item-based algorithm. Initially, a vector of user's preferences $P$ is created. User's preference for each page is boolean: 0 if the user doesn't like the page, 1 otherwise. A matrix $M$ of co-occurrence of `likes' on pages is created for all the users in the system.

For example, given the following matrix $M$ of co-occurrence calculated for 7 items and a vector of preferences $P_u$ for a user $u$, the product rows to columns between $M$ and $P_u$ returns a vector $R_u$ containing the inferred preferences.
\[
\let\quad\thinspace 
\bordermatrix{\text{} & i_1 & i_2 & i_3 & i_4 & i_5 & i_6 & i_7\cr
i_1\, & 5 & 3 & 4 & 4 & 2 & 2 & 1\cr
i_2\, & 3 & 3 & 3 & 2 & 1 & 1 & 0\cr
i_3\, & 4 & 3 & 4 & 3 & 1 & 2 & 0\cr
i_4\, & 4 & 2 & 3 & 4 & 2 & 2 & 1\cr
i_5\, & 2 & 1 & 1 & 2 & 2 & 1 & 1\cr
i_6\, & 2 & 1 & 2 & 2 & 1 & 2 & 0\cr
i_7\, & 1 & 0 & 0 & 1 & 1 & 0 & 1} \ast \bordermatrix{\text{} & P_u\cr
\text{} & 1.0\cr
\text{} & 0.0\cr
\text{} & 0.0\cr
\text{} & 1.0\cr
\text{} & 1.0\cr
\text{} & 0.0\cr
\text{} & 1.0} = \bordermatrix{\text{} & R_u\cr
\text{} & 12.0\cr
\text{} & 6.0\cr
\text{} & 8.0\cr
\text{} & 11.0\cr
\text{} & 7.0\cr
\text{} & 5.0\cr
\text{} & 4.0}
\]\\

In this example, rating for items $i_2$, $i_3$ and $i_6$ are inferred using an item-based similarity, even if the user never explicitly added a preference. The final vector representing user $u$ is created starting from $R_u$ using an higher weight for the items that explicitly were preferred by the user (i.e. items that have value 1 in $P_u$) and a lower weight for the inferred items. 
To create an ordered list of suggestion for the user $u$ we use Euclidean distance on the preferences vector, finding the nearest-N users. An additional score is finally added for users that share the same demographic data or professional history. Performance of the users recommender is evaluated in Section~\ref{sec:eval}. 


\subsection{Local Experts Recommendation}\label{sec:local_experts}
The identification of local experts is obtained through the analysis of social media extracted from Facebook. In particular user travels and location history are computed analysing geo-tagged pictures and identifying photo albums, birthplaces and places of residence and exploited to produce destination-based recommendations.

The mobile app of the contextual social network provides a way for users to select his/her flight and destination. The goal of the local experts recommender is to suggest users that have an high level of travel experience about the flight city destination or region.

The proposed method for local expert computation is based on the approach proposed in \cite{Zheng2009}, where human location history is exploited in order to recommend cities Point-Of-Interests. Our approach complements this computation considering not only the user travel experience but also the correlation and the distance between cities. Given a set of users $U$ and a set of visited cities $C$, a matrix $V$ is defined where the item $v_{ij}$ of $V$ represents how many times the user $u_{i}$ has visited the city $c_{j}$, with $0 \leq i < |U|$ and $0 \leq j < |C|$. Visited cities are extracted from user activity in the social network application: we consider the selection for a flight destination on the mobile application as a visit.

The \emph{travel experience} vector $E$ of users is calculated iteratively on the basis of the number of travels in cities as it follows:
\begin{equation}
\label{eqn:experience}
E_{n} = E_{n-1} \cdot V \cdot V^{T}
\end{equation}

In \eqref{eqn:experience} $E_{n}$ indicates the vector E at the $n$ iteration that is initialised with $E_{0} = (1,1,\cdots,1)$. The vector $E$ is then normalised, dividing by its highest value.\\
The correlation $CORR(c_{i},c_{j})$ between two cities $c_{i}$ and $c_{j}$ is expressed as:
\begin{equation}
\label{eqn:correlation}
CORR(c_{i},c_{j}) = \sum_{u_{k} \in U'} \alpha * e_{k}
\end{equation}

\begin{figure}[htb!]
\centering
\includegraphics[width=0.46\textwidth]{figs/local_experts.jpg}
\caption{Local Experts Recommendation. Photos published in Facebook albums and used in the recommendation are shown. The expert will be on the same flight and users can chat.}
\label{fig:local_experts}
\end{figure}

where $U'$ represents the group of users who has visited both $c_{i}$ and $c_{j}$, $e_{k}$ is the component of $E$  relative to the user $u_{k}$. The weight factor $\alpha$, with $0 < \alpha \leq 1$ is defined taking into account the Euclidean distance between latitude and longitude of the two cities.

Finally, we need to compute user's level of experience of a user $u$ for a given city $c$. To this end, we define  $n_{k}$ as the number of visits of the user $u$ in the city $c_{k}$, based on previous activity on the network (i.e. previous flight destinations). We also extract from Facebook the number of geo-tagged photos $p_{k}$ that the user has published in $c_{k}$ .\\

From these data, a rating $exp_{u,c}$ can be assigned to user for a city as:
 \begin{equation}
 exp_{u,c} =  \sum_{k = 0}^{|C|}  (1 + p_{k}) * n_{k} * CORR(c, c_{k}) 
 \end{equation}
 
We also consider if a user lives (or has lived) in $c$ or if she had educational/professional history in the city, adding points to the rating  $exp_{u,c}$.
Local experts whose score is greater than a threshold are shown as a list of recommendation, in descending order, in a dedicated view of the mobile app as shown in Fig.~\ref{fig:local_experts}.


\section{Evaluation}\label{sec:eval}
The proposed friends recommendation system is based on the ranking of user similarities and can be therefore seen as an information retrieval system, considering a user as a query term. To evaluate the relevance of recommended potential friends we have exploited the normalized Cumulative Discounted Gain (nDCG)~\cite{jarvelin2002cumulated} measure. The intention of the evaluation is to compare the generated list of recommended people with the ideal list created from a relevance score given by the user. We collected a ground truth asking 150 users to express a relevance score (on a 0 to 3 scale) for the first $J$ people suggested by the system when they use the application. For example, for a suggested list of people ordered by the recommender as (P1, P2, P3, P4), the user provides as ground truth the relevance vector of scores (1, 3, 2, 0). For each list of recommended potential friends for these users, we can obtain a score list where the scores are provided by ground truth. Assuming each user $u$ expressed a relevance $r_{u_j}$ from being recommended an item $j$, the average Discounted Cumulative Gain (DCG) for a list of $J$ items and $N$ users is computed as

\begin{equation}
DGC = \frac{1}{N} \sum_{u=1}^{N} \sum_{j=1}^{J} \frac{r_{u_j}}{max(1, \log_{2}j)}  
\end{equation}

In this experiment, a logarithm with base 2 is used to ensure all positions are discounted. 
The nDCG is the normalized version of DCG given by
\begin{equation}
nDCG = \frac{DCG}{DCG^i} 
\end{equation}
where $DCG^i$ is the ideal DCG, computed on the model distribution of relevance depending on the number of items $J$ as shown in Table~\ref{tab:ndgc}.
We calculated nDCG for the top-J item, resulting in values of 0.767 with j=5 and 0.872 for j=10.

\begin{table}[h]
\caption{Ideal relevance and computed nDCG for top-J recommended items}
\begin{center}
\renewcommand\arraystretch{1.2}
\begin{tabular}{| p{0.8cm} | p{3.5cm} | p{2cm}|}
\hline
\textbf{J}  & \textbf{Ideal Relevance}     & \textbf{nDCG}  \\ \hline
5  & (3,3,2,1,0)         & 0.872 \\ \hline
10 & (3,3,2,2,2,1,1,0,0) & 0.767 \\ \hline
\end{tabular}

\end{center}
\label{tab:ndgc}

\end{table}

\section{Conclusions}
In this chapter we have described mechanisms of friends prediction and recommendation, and suggestion of local experts for a contextual social network designed to be used in real-time by passengers in the check-in area of an airport. We motivate the work with the need, for a social network that pretend to be contextual, to adapt itself to services and intentions of volatile and co-located groups of persons, such as a lounge of an airport. We propose a novel approach to the refinement of friends recommendation strategies which takes into account profiling techniques from social network analysis (e.g. Facebook and LinkedIn) and inferred ratings for users' neighbourhood detection and identification. A method for local experts recommendation is also proposed which improves from previous work exploiting social media analysis. Use cases are shown through a developed mobile web app by which users can search for flights, destinations and facilities infos and receive targeted services and recommendations. Finally we evaluate the recommendation and the effectiveness of the overall system with a user study based on the nDCG measure which shows good results.