Email classification has been a user’s pain point since the early days of email systems. In the last decade, most attempts at automating this task have consisted in mimicking each individual user’s personal classification habits . This highly personalized approach exhibits two main weaknesses: it relies on small datasets as each individual inbox is analyzed independently, and it requires from users to have defined meaningful folders in the first place. We believe that relying on user-defined folders is the reason for which such methods were never widely adopted. It was shown in  that % of users do not create even a single folder. Furthermore, we have verified on a large dataset, generated from Yahoo mail,that only of users are “active classifiers”, the latter being defined as users who moved more than messages into folders over a period of months.
This fact has not remained unnoticed. A few of commercial Web services have changed their approach towards email classification by offering “classes” (implemented as labels, or categories for instance) that are common to all users. Thus, AOL mail, with its “Bulk Senders” category, or Gmail, with its inbox tabs111These tabs include “Promotions”, “Social”, “Updates” and “Forums”, see https://support.google.com/mail/answer/3055016?hl=en&p=inboxtabs&rd=1, offer a few “common” classes. On the other end of the range, Koren et al. in 
, have analyzed popular folders, in order to identify not just a few but several thousand possible common classes or “tags”. While the wide range of tags is attractive, one weakness of this approach is the high variance in their level of abstraction. Highly subjective tags such asmom co-exist with more objective ones like recipes, or sender-based tags such as amazon overlap with related ones like shopping. In addition, they achieve recall and precision rates of only for a coverage of . This work explores a middle ground direction, where we propose, like in , to derive high level-classes from mail data, and especially folders data provided by the minority of users who do define folders. However, similarly to AOL or Gmail, we give preference to fewer, consistent classes, for a more user-friendly experience, and offer these classes to all users, including those who did not define any folder.
First, we propose to exploit the fact that today’s commercial Web mail traffic is dominated by machine-generated messages, originating from mass senders, such as social networks, e-commerce sites, travel operators etc. In their experiments, Ailon et al. stated that machine-generated mail represent more than of Yahoo mail traffic, 
. We argue here that, given the difference in syntax and semantics between human- and machine-generated messages, one should first distinguish between machine and human-generated messages before attempting any finer classification. Once focusing on machine-generated messages, with huge numbers (millions in some cases) of users receiving the same type of machine-generated messages, data will be much less sparse, and classification techniques should become more precise. In order to validate our intuition, we estimated the actual volume of machine-generated messages on a very large Yahoo mail dataset. This dataset, built for the purpose of this work, covers 6 months of email traffic and more thanbillion messages. For privacy reasons, it includes messages belonging exclusively to users who voluntarily opted-in for such studies and message bodies were not inspected by humans. We conducted experiments on this dataset (as detailed later on) and verified that non-spam machine-generated messages actually represent of the entire dataset, which encouraged us to proceed.
In the same dataset, we considered the subset of folders data that include messages classified by users into folders as well as folders labels, generated by more than million users. Instead of a priori fixing high level classes, or deriving them from popular folders labels, as done by the previously mentioned efforts, we attempt here another approach. Namely, we propose to discover these categories by applying an LDA (Latent Dirichlet Allocation) approach , on the folder dataset. We explain how “latent” categories can be identified in Section 2. More specifically, we detail how one human and five machine-generated categories can be inferred directly from the data. We introduce in Section 3
our email classification model and its associated features, such as content, sender, behavioral, and temporal behavioral features. We also justify the different aggregation levels we considered, namely message-, sender- and domain-level aggregation. An additional challenge is to obtain a sufficiently large training set. Due to privacy issues, the cost of editorial work, and the skewness of the email data, we use various automated methods. For the machine latent categories, our main data source is the folder data. Using our LDA analysis we obtain for a large number of messages a clear linkage to our latent categories. For the human category, folder data is not effective, and we use instead various heuristics leveraging sender information and extrapolated data viaco-training inspired techniques. We detail how we generated the training data in Section 4. Section 5 describes our classification mechanism and Section 6 presents our results. In section 7 we provide some additional statistics to demonstrate the impact of our classification system. Note that we exclusively consider consumer Web mail as opposed to corporate email, whose traffic is drastically different in size and nature. Consequently, we did not compare our results to the Enron dataset. Related work is discussed as relevant throughout the paper.
The key contributions of our work are the following: (1) we provide new insights on the importance of distinguishing between human- and machine-generated email, (2) we give to the best of our knowledge, the first large scale data-driven validation of the intuition that a few consistent automatically discovered categories cover most of today’s Web email traffic, and (3) we describe an end-to-end Web mail categorization solution, including detailed models, learning mechanisms, evaluation methods, and results on real traffic.
2 Discovering Latent Categories
|read 0.06||job .022||shipping .016||travel .010||information .010||post .024|
|today 0.04||jobs .014||items .009||hotel .008||bank .009||comment .021|
|great 0.04||apply .009||deals .008||deals .006||card .009||messages .018|
|much 0.04||search .009||sale .007||per .005||payment .008||photo .018|
|want 0.04||career .008||order .007||book .005||service .007||invited .017|
|wish 0.04||exp .007||purchases .007||flights .005||credit .007||attention .017|
|make 0.03||national .006||shop .006||details .004||contact .006||twitter .012|
|just 0.03||capital .006||customer .006||travelzoo .004||customer .006||shared .011|
|think 0.03||recruitment .006||offer .006||stay .004||security .005||replied .010|
|very 0.03||manager .006||subject .006||hotels .004||chase .004||followers .010|
Following , we define email categorization as the task of “assigning a Boolean value to each pair , where is a domain of documents” (here mail messages) “and is a set of predefined categories.” Previous research work on personalized email classification used one set per user and populated it by reusing the user’s existing folders, see [15, 7, 2, 10]. The approach we advocate for here is to adopt one single for all users. Still can be defined in many different manners: categories can relate to message importance (see Gmail Priority Inbox222http://gmailblog.blogspot.co.il/2011/03/new-in-gmail-labs-smart-labels.html), number of recipients (see AOL Bulk Senders), senders (see popular folders such as Amazon, Facebook), or types (see Gmail Labs Smart Labels Social, Promotion, Updates, Forums, Travel, Finance) for instance. In addition, should be derived from data (rather than predefined) and should fulfill the following requirements.
The number of categories should be small so as not to overwhelm the user. Indeed, it has been shown that, with more than folders, folder-based discovery becomes less effective than search .
Categories must be easily interpretable and at the same level of abstraction.
Categories should cover a significant amount of email volume.
We then associated with each of these folders an artificial document obtained by concatenating across all relevant inboxes, all messages classified into this folder. We applied LDA 
, to these “document folders”. LDA is commonly used in natural language processing in order to discover a set of latent topics that generated a given set of documents. In our context, we hoped that latent topics would map into “latent categories” , which would then define our setfor further classification. To this effect, we trained an online LDA model . Recall that LDA receives as input a set of documents (folders), each associated with a bag of words (words of messages put in the folder), and a number of topics . It outputs for each topic the top words associated with it and the topic mixture of each document. We iterated over several values of number of topics, from to . To choose the right , we looked at coverage, in terms of portion of traffic covered by folders that were dominantly () associated with topics. For a value of and a specific topic, the coverage of the topic is defined as the amount of traffic covered by folders that are associated with said topic by at least by the LDA output. The total coverage associated with a value is the sum of coverages associated with the topics. Our objective was to find a value of that would ensure that each individual topic as well as the overall set of topics achieve significant coverage. We observed that larger values of produced topics that were narrow, e.g. Knitting, Cooking, Astrology with small coverage. The traffic coverage at was , and went down to at , to about at . At the coverages of the topics were sufficiently large (see Table 9), while at larger values of narrow topics emerged.
We further examined the topics obtained for
, as this value exposed a good balance between total and individual coverage, by inspecting their associated vector of words and weights. As evidenced in the five rightmost columns of Table1, the words associated with each of these fives topics clearly shared a common underlying concept, respectively career, shopping, travel, financial and social. One topic remained that was a bit puzzling at first, as it contained many highly frequent (stop) words and no key concept seemed to emerge from them. After some quick examination of the messages (simply looking at senders) associated with this topic, we discovered that most were human-generated, as opposed to the five other topics that are mostly machine generated. The word associated with this first topic are quite frequent in personal communications, consequently we named this last topic human.
Given these 6 labeled topics, we further verified their distribution over a sample of popular folders, as shown in Table 2. Some mappings between folders and latent topics were almost perfect, like the folder “financials” being associated with the latent topic financial with a weight, or “hotels” with the topics travel at , with still a flavor of financial at . More interestingly, a highly subjective folder like “mom and dad” had no clear winner. While it did reflect the human topic at , it also (and ironically so) had financial at ! Based on this analysis, we finalized our decision of choosing as human, career, shopping, travel, financial, as it meets our 3 requirements of small size, same abstraction level and coverage.
|folder name||topic distribution|
|mom and dad||financial, human, shopping|
|church||financial, human, shopping|
3 Modeling Email
One key challenge in any classification task is data modeling and fixing the level of granularity of data points i.e., the objects to classify. One option is to consider each individual message as a single data point, associated with various features extracted from the message header and body. A second approach consists in aggregating messages at higher levels, for instance at the SMTP address level, (referred to as “sender”), or at the mail domain level (easily extracted from the SMTP address by truncating its prefix up to the character “@”.) This latter approach not only helps with sparseness issues but more importantly allows for much more efficient processing, without requiring expensive body analysis and feature extraction. This is critical at the scale of Web mail, when huge numbers of messages need to be classified at delivery time. We explain how we use a combination of both approaches in Section 5. Feature extraction and different aggregation levels are described in the rest of this Section.
3.1 Extracting Features
We follow the general categorization framework where numerical features are extracted from each object (in our case, message, sender or domain) later to be fed to a learning mechanism that given labelled examples, e.g. messages with manually assigned categories, will be able to categorize unlabeled objects. In this section we describe the types of features and how they are obtained.
A data point consists of content features, address features, and behavioral features which include a special subcategory of temporal behavior features.
Content features include features derived from the message subject and body. We extract words from the subject line and message body, as well as the subject character length, body character length and the number of urls occurring in the body. To form sender features, we use the total counts of observed words across all messages from that sender, as well as the average, the minimum and the maximum subject and body lengths and url counts. In large databases, such as the one we are dealing with, the most frequent words can easily occur millions of times (e.g. “the”, “a”, “in”). We eliminate the top words found across most senders, as well as the usual stop words444http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/snowball/stopwords for several common languages. Finally, we filtered out the low frequency words that occur in less than different senders.
Address features include features extracted from the sender email address, including the subdomain, e.g. (.edu, .gov, etc.), subname (e.g. billing, noreply). To extract the subdomains we split the domain part of the address (after the “@” character) at the delimiter “.” location, and use the resulting words as features. We do the same for the subnames, but on the name portion of the email (before the “@” sign). We also extract “commercial” keyword from senders. To this effect, we use a list of more than keywords, typically used as bid words in ad targeting, such as itinerary, flight, ticket, order, confirmation, billing, payslip, payment, transaction, stocktrade, career, shopping, travel, etc., and look for a match in the email address. To counter the imbalance between rare and frequent words, we remove the most frequent sender substrings. This avoids poor generalization when using biased training data. For example, very common domain names, such as “yahoo.com”, or “gmail.com”, could get picked as the most informative features in a model trained to detects human senders. This rule clearly does not generalize well outside the training dataset. In addition to removing the most frequent substrings, we remove the substrings that appear in less than senders. We also map very rare or random strings into a canonical form, for instance email@example.com, is mapped into a single feature “random string”.
Behavioral features include features extracted from the sender’s and recipient’s actions over a given message. They can be split into outbound, inbound and action features. The outbound features for the -th sender cover the sender’s outgoing activity, such as weekly and monthly volumes of sent messages, histogram of the number of recipients in their messages, volumes of messages sent as a reply (indicated by “re:” in the subject line), volumes of messages sent as forward (with FW: in the subject line). The inbound features for the -th sender cover the sender’s incoming activity, such as volume of the messages received by the sender, as regular, reply or forward messages. The action features for the -th sender cover the activity of the sender’s email recipients, such as how many times the messages from the -th sender were read, deleted, replied to, forwarded, ended up in spam or any other folder. To create these features, raw counts are converted to percentages of total inbound volume (e.g., percentage of -th sender messages moved to trash). The names of the folders to which a given sender messages have been moved, are especially interesting: they can be seen as a human label of a specific sender. Therefore, for the -th sender, we also use the names of folders (with the counts of moves to that folder ) as folder features. We remove the folders that contain less than different senders, as well as the folders with the highest number of senders, including system folders (“trash”) and third-party services folders.
Temporal behavior features form a subcategory of the behavioral features. They reflect the frequency of specific actions over a given period of time. For instance, we record whether a sender sends more than messages in an hour. These features are represented as a histogram, where takes as values: , , , , . We refer to them as the burst features.
Many of the features described above are counts of actions or words. To handle large counts, we normalize the data at an instance level by using instead of the original -th feature value . Features that represent percentages of total traffic (e.g. moves to trash, spam, etc.) are left in the to range.
3.2 Email Aggregation Levels
We consider three levels of aggregation, by message, sender and domain. To choose the right level of aggregation for our system, we consider what we lose and what we gain by aggregating to the next level, starting from the level of the email message. We consider several dimensions: generalization loss, data size and classification scalability.
Generalization loss: Aggregating messages offers some risks, if by aggregating we put in the same class messages that should have been mapped to different categories. One typical mistake that occurs when aggregating by sender occurs when a given sender changes its behavior. It happens for instance when a sender (such as a recruiter, finance broker or a travel agent) sends machine generated messages to clients in of the cases, and personal messages otherwise. We refer to this issue as the machine-human mix. In some rare cases, we observed another type of loss we call the multiple businesses loss, where a sender is a company that has more than one type of business and sends all messages from the same address. Although many companies conduct multiple types of business, they typically use different addresses for each type, hence the multiple businesses loss is quite low. Domain-level aggregation, as the most aggressive type, suffers the most loss; in particular the multiple businesses loss is quite common there. Table 3 shows some examples of generalization loss due to aggregating at a domain level.
Data size: Data size is a key factor in deciding the right aggregation level as learning and categorizing at this scale is most challenging. Table 4 shows the number of data points in our dataset for the various aggregation levels. As expected sender-level aggregation drastically reduces the data size, going from more than one trillion messages to about million senders after aggressive filtering. Domain-level aggregation brings an additional decrease, bringing us to about million domains, a significant drop but not as drastic as the one brought by sender-level aggregation.
Classification scalability: The highest gain in scalability is between sender and message aggregation. Indeed, extracting features from each message and running a classifier upon delivery might be extremely costly. On the other hand, mapping each message into its sender presents huge performance advantages. The classification process can be conducted offline on all the previously seen senders, and an incoming message can be assigned the category associated with its sender via a simple (yet very large) table lookup.
Consequently, we propose here a two-stage approach. The majority of the email traffic should be classified by sender for performance optimization. However, whenever the classifier returns a low confidence score for a given message sender, the more costly message-based classification should be applied. This approach is detailed in Section 5.
4 Training Data
One key challenge in Web mail classification is to generate a labeled training dataset given the inherent size of the data as well as privacy issues. We consider here 3 types of labeling techniques: manual, heuristic-based and automatic, which we discuss below. We used as labels our 6 latent categories, as well as the human and machine labels to differentiate between human- and machine-generated messages.
4.1 Manual labeling
Manual labeling consists of having human editors assign labels to specific examples. This method has some clear weaknesses. Given the data sensitivity, even with users that agreed having their mail examined, only a limited number of responsible editors can be involved. Then it becomes more difficult to have multiple editors looking at the same data, which is a must given the nature of the task. Indeed, looking at a confusion matrix, we observed many inconsistencies among editors, for instance betweenShopping and Finance or Travel and Finance. We nevertheless generated such a dataset, denoted as , by giving to paid editors a pool of about messages originating from about senders. This pool contained multiple messages per sender, with some overlap between editors’ assignments. Close to inconsistent labels were generated, which were resolved via additional editor intervention.
|orders||bank statements||hotel reservations||groups||jobs||church|
|online orders||credit cards||train tickets||recruiters||soccer|
|receipts||credit||flights||facebook friends||job search||dating|
|shopping||financial||hotels - airlines||trabajo||match.com|
|internet recipes||banking||travel info||social networking||resumes||education|
|ebay||bank stuff||hotel||social network||job apps||jokes|
|shoes||bill confirmations||travel confirmations||social networks||job hunt||college|
|amazon||bills to be paid||air france||social sites||job hunting||surveys|
4.2 Heuristic labeling
Heuristic labeling consists of applying heuristic rules derived from world knowledge. Such labeling achieves high precision but is limited in coverage. We used this type of labeling mostly for differentiating between human and machine senders. One key challenge here lies in the fact that SMTP domain information is not sufficient. Indeed, large Web mail services are not only used by humans. Non-spam machine-generated messages can originate from domains such as gmail.com, hotmail.com, or yahoo.com, even for small distribution volumes. Conversely, domains such as amazon.com or ibm.com, intel.com or hp.com can be associated with both machine and personal communications of corporate employees. We focused on corporate domains as they represent the main source of errors between human and machine labels, with the following simple heuristics. In order to identify corporate machine senders, we spotted reserved words such as mailer-daemon or no-reply, or repeating occurrences of words such as unsubscribe in message headers. We also used signals such as spam votes. In order to identify human senders, we looked for patterns such as <first name>.<lastname> and other various regular expressions. We also applied a semi-supervised approach similar to co-training , in order to further increase our heuristic dataset, remove false positives, and most importantly obtain a less skewed sample. In a nutshell, the idea is to split the features into two independent sets, train a classifier on one set, then use the labels with high confidence to train a classifier on the second set, then possibly iterate on all features with all of the labels. Eventually, a heuristic dataset denoted was generated, which consists of human senders and machine senders. Most of the machine senders were further assigned machine latent categories as labels, using the techniques outlined below. The remaining ones were labeled as Other in the final dataset used for training of the production model.
4.3 Automatic labeling
For automatic labeling we apply two types of techniques, folder-based majority and LDA voting.
Folder-based majority voting (see Algorithm 1) leverages user-generated folders to obtain ground truth labels for senders. There are hundreds of folder names that relate to “shopping", “finance", or “travel", etc. Since there are much fewer folders than there are senders, we manually labeled close to folders that carry the meaning of our latent categories, and let the folders vote for senders label. A subset of the labeled folders is shown in Table 5. Note that we did not include the Human category since we hardy observed any folder that would be perfectly aligned with it. Even our previous example of mom and dad folder in Table 2 includes machine-generated messages as evidenced by its strong Finance topic. We also saw multiple examples of human folders, related to family and friends, that contained messages from known vendors or travel companies. The labeling procedure is detailed in Algorithm , with threshold parameters chosen via grid search.
For each sender, we identify the folders with labels that contain messages originating from this sender. Then, the folders vote for the labels. If there is enough confidence for the winning label, as per threshold, the sender is labeled accordingly. Several examples of the labeled senders with individual folder votes are given in Table 7. After applying this procedure to the entire dataset of senders, we end up with more than labeled senders that form . In the process of merging with and , there were approximately matches (same label assigned) and conflicts (different label assigned). Senders that were labeled as machine in and were assigned a machine latent category in or , were not counted as conflicts. The conflicts were resolved by human intervention. We denote the resulting merged dataset by .
|class||# labels||class||# labels|
Folder-based LDA voting is the second technique we used in order to scale-up the majority vote technique. It is needed mostly because the majority of folders cannot be labeled, either because the folder name is not descriptive enough or it contains a mix of messages. As one of the results of LDA training, we know the topic distributions of folders counting more than messages, as illustrated in Table 2. We used these topics for “soft voting”: instead of assigning vote, each folder assigns partial votes to the senders of the messages it contains, using topic weights. We then re-normalized the votes to sum up to 1 in order to create a labeled set from the senders with a topic score above . This process produced labeled senders that already existed in as well as additional new senders. The labels of senders that were already in mostly agreed with the existing ones, with only conflicts, not counting the machine labels that received a subcategory label. The final, merged dataset contains senders. Table 6 shows the counts of human and machine labels in .
|folders||shopping:55 online shopping:6 ebay:4 on-line shopping:4|
|amazon:2 finance:1 bills:1 cv:1 orders:1 paypal:1|
|internet shopping:1 car insurance:1 receipts:1 credit cards:1|
|folders||bank:69 banking:29 bills:13 banks:8 bank statements:5|
|finance:5 bank stuff:4 mom:3 purchases:2 receipts:2|
|girl scouts:2 financial:2 ebay:1 car insurance:1|
|online bills:1 online orders:1 credit:1 bill payments:1|
|folders||travel:336 voyages:120 hotel:107 hotels:97|
|compras:23 receipts:21 hotel reservations:9 flights:9 orders:8|
|cv:5 shopping:5 travel confirmations:5 air tickets:4 travel|
|reservations:3 jobs:2 bills:2 flight:2 airlines:2 travail:1 dad:1|
5 Classification Mechanism
The classification mechanism put in place has two major elements. The first is the online mechanism, designed in a cascading manner mainly to account for scalability. The online system leverages both message-level and sender-level classifiers in order to categorize incoming messages, while taking into consideration the strict requirements of a real time Web mail system. The system has three stages: (1) lightweight classification, (2) sender-based classification, and (3) heavy-weight message-based classification. The second component is the offline component where (1) we periodically classify the known email senders into the 6 categories and (2) train a multi-label message classifier. The online system diagram is given in Figure 1. We describe its components in detail below.
Online lightweight classification: The initial classification is at a message-level, consisting of hard-coded rules designed to quickly classify a significant portion of email traffic. Easy cases include messages from the top 100 senders that cover a significant percentage of the total traffic and are category consistent. Also, as a heuristic decision, we categorized all reply/forward messages as human. By taking precedence over sender-level, message-level classification helps avoid generalization errors due to mixed human-machine senders. As for performance, the process described requires very few resources and covers 32% of the email traffic.
Online sender-based classification: The second phase in our cascade classification process involves looking for the sender in a lookup table containing senders with known categories. This table is created in our offline component, described below. A sender that does not appear in said table is absent due to one of the two reasons; (1) it was either never, or hardly seen in the past meaning that the sender features are too sparse and noisy to be useful, or (2) the offline classification process did not have an answer with a sufficient confidence. The second type of missing senders are those with the most chance of being mixed, meaning that the messages originating from them should not all be assigned the same category. The amount of traffic that is not covered by this phase is roughly 8%.
Online Heavy-weight classification: Email messages whose sender did not appear in the classified sender table are sent to a heavy-weight message based classifier. As only 8% of the traffic end up in this last phase we can afford slightly heavier computations than we would have afforded had we employed the classifier on all incoming email. Here, we use all relevant feature, pertaining to the message body, subject line and sender name.
Offline creation of classified senders table: We use the training set described in Section 4
in order to train a logistic regression model. The details of the implementation for both training and classification are detailed in Section6. For each category we train a separate model in a one-vs-all manner, meaning that the senders assigned any different label are considered negative examples of equal weights. The classification process is run performed periodically to account for new senders, and modified behavior patterns (the features of the senders are refreshed at each run) of existing senders. We output for each sender a category and confidence score; if the confidence is sufficiently high then the sender enters the table. The process consists of the following: All 6 classifiers (one for each category) are run on all of the senders in our data base. To determine the category of a sender we choose, from the classifiers returning a positive answer, the one with the highest confidence, and set this score as the final confidence. If all of the classifiers returned a negative answer, the chosen category is ‘other’, meaning machine generated that does not fit our predefined categories; the category confidence is set as the lowest confidence score of the individual classifiers.
Offline training the message-level classifier: This task is not done periodically but is done once based on the labeled data described in Section 4. The training process is quite similar to the sender classification in the sense that a logistic regression model is trained for each category in a one-vs-all model. The major difference is the training set, which is of course different as it contains messages rather than senders. To obtain it, from each sender in we choose random email messages, and assign them the label of their sender. The features associated with the messages do not include any data on the sender. The other difference when compared to the sender-based classifier is that here we do not allow a non-decision, as this component is used in the final level of the online cascade classifier. Hence, there is no issue of having sufficiently large confidence. Due to space constraints, we do not elaborate on this process further but note that it is quite similar to the sender classification process and has relatively low impact (only 8% of the traffic is run through this process).
|category||all features||content only||address only||behavioral only||no burst||no body|
6 Experiments and Evaluation
For the production system we trained sender-based classifiers for machine latent categories: Shopping, Financial, Travel, Career and Social, and sender-based machine vs. human classifier. This section covers the main experimental results of our email categorization study, demonstrating how well the category classifiers generalize on a holdout dataset.
We start by discussing the data distribution required for testing. The most intuitive sampling is uniform sampling, in which each incoming message is assigned the same weight and the system is evaluated accordingly. In the machine-generated latent categories, our experiments did not consider this distribution as it would rate our system way too favorably: even an average system becomes indistinguishable from an excellent one due to the large volume of messages sent by top senders, as demonstrated in Figure 6.
Specifically, a small number of senders are responsible for the majority of the email traffic, hence a system that avoids classifying the low-weight senders might achieve a good score, but still incur a bad user experience. One example for this phenomenon is in the social category. Here, Facebook contains only a handful of (canonized) senders555We define a canonized sender as a regular expression over senders, such that all senders matching it are essentially the same. In the context of Facebook, an example would be firstname.lastname@example.org
For the human-vs-machine classifier the training was performed on the set ; however we used a different test set. The main reason is that unlike machine-labeled senders, human-labeled senders are not based on folder data but rather on features that we do use in our classification process. For this reason, testing on would provide unfair results. Instead, we sampled more than senders uniformly from the pool of senders, then from each sender we sampled email message thus creating a test set of more than l messages. The samples were made from the email repository after excluding easy-to-verify machine traffic such as senders whose outgoing traffic is larger than messages per month, or senders that were never replied to despite the fact that they sent over messages. This initial exclusion was necessary as human traffic is rather small compared to machine meaning that in order to get sufficiently many human examples without exclusion we would have required a large amount of manual labor. We verified that a negligible amount of these excluded messages were written by a human by manually observing that out of uniformly drawn excluded examples none were human generated.
For the machine sub-category we randomly split into a training set, used to train the models, and a test set, used to evaluate the models. Since a single domain may have multiple senders, they were all put in either the training or the test set. This way, we can test whether the model truly generalizes well outside of the domains it observed in training. The labeled dataset was split into for training and for testing purposes. The procedure was repeated times. The average numbers for the splits were reported.
In our experiments, as well as in the production system, we leveraged the MapReduce paradigm , implemented in the Hadoop666http://hadoop.apache.org/ open source platform. All of our data processing, including aggregation of messages per sender, feature extraction, training and scoring, were done under Hadoop. The models were trained in a single MapReduce job, where the mapper reads , and prints every data point times, once for each problem at hand, playing a role of either a positive or a negative example in the corresponding problems. The reducer trains a separate binary classification model:
for each problem Shopping, Financial, Travel, Career, Social, Human. We used a logistic regression model, where the feature vector is parameterized using a weight vector , with one weight per modeled feature. Specifically, we utilized the highly scalable Vowpal Wabbit 777https://github.com/JohnLangford/vowpal_wabbit implementation of logistic regression 
, which was found to work well in conjunction with MapReduce. In these experiments, the categorization was treated as a multi-class “one-vs.-all” problem. Therefore, an additional step of merging the predictions is required, where the final prediction is made based on the class with the highest probability.
In Figure 2, we show the averaged results achieved on the test set when classifiers were trained using all feature types except folders. The figure shows the Receiver Operating Characteristic (ROC) curve that trades-off True Positive Rate (TPR) and False Positive Rate (FPR) as well as the Precision Recall (PR) curve that trades-off Precision and Recall. It can be observed that the models achieved desirable performance, with Precision and Recall numbers both in the range in most cases. Overall, the performance suggests that even with a very low FPR threshold, e.g. , set for production purposes, large portions of true positives can be covered, i.e. , more than in most cases.
To evaluate the influence of the feature types, table 8 shows the Area Under the ROC curve (AUC) results for each class, when our model was trained on subsets of features: (1) content features (email body, subject, etc.), (2) address features (subname, subdomain, commercial keywords) and (3) behavioral features (number of messages, sent, received, etc.) without folders. It should be noted that temporal behavior features (burst features) were treated as behavioral features in this experiment. Even though there is an evident drop when compared to using all feature types, content and address feature subsets achieved competent AUC performance that around . As expected, behavioral features showed good performance in distinguishing between human and machine senders, but could not on their own discriminate between different machine categories.
The second portion of Table 8 shows the performance when some features were removed. Specifically, we were interested in the performance drop when burst features, and body words features were removed.
A clear difference in the distribution can be observed. Furthermore, Figures (b)b and (c)c show to what extent certain binary features are observed in the human examples versus the machine examples. It can be observed that when the word unsubscribe is present in the message body, it is much more likely to be associated with a machine sender. Also, when common first names, such as “michael”, “susan”, etc., are present in the email address, they are much more likely to be associated with a human sender. Finally, Figure (d)d shows the presence of “burst 100” feature, i.e. indicator of whether or not the sender sent more than messages per hour on some occasion. It can be observed that the feature is present in more than half machine senders and in very few human senders. Other interesting facts that were not depicted in the figures are that: 1) of machine senders send messages with average subject character count higher than , while only of human senders do the same; 2) of machine senders send messages with average body character count higher than , while only of human senders do the same; and 3) of machine senders send messages with more than urls in the body on average, while only of human senders do the same.
To get more insight into the latent category models, we generated feature clouds for Shopping, Financial, Travel, Career as illustrated in Figure 4. Features of higher “importance” are printed using larger fonts. In Logistic Regression, large positive feature weights are associated with a higher likelihood of user belonging to class . Therefore, to calculate the feature importance scores with respect to class we use the following procedure. First, we isolate only the features that have a positive weight in -th class model . Next, we calculate the score for each of those features as , where is the total number of examples, is the total number of class examples, is the number of examples that have feature and is the number of class examples that have feature . Finally, we generate a word cloud using the features with the highest score. By examining the figures we can conclude that the main concepts of each class are very well captured using indicative body and subject words, as well as the address substrings.
7 Significance of Results
In this section, we discuss the significance and potential impact of our mail categorization system. We estimated the coverage of latent categories in two different manners. First, we measured overall email traffic coverage by estimating the percentage of email messages that are mapped into one of our categories. Then, we measured how these categories cover mail search by manually categorizing a sample of mail search queries. The results are given in Table 9.
|category||email traffic (%)||search query (%)|
For email traffic coverage, we ran our classification system over real email traffic and counted the number of messages classified in each category. The percentages listed in the email traffic column in Table 9 represent the number of messages classified as topic X divided by the total number of messages. For the search query coverage, a team of professional editors manually labeled 2,500 common queries. To ensure privacy, we chose only queries that were used by several users, and in particular avoided queries that are unique to a single user. The percentages listed in the search query column in Table 9 represent the number of queries classified as topic X divided by the total number of queries. Table 10 gives a description of the typical queries for each category.
|human||person’s name, terms from a conversation|
|with another person|
|social||social network name such as twitter, pinterest, etc.|
|shopping||retailer name, product type or product name|
|travel||travel airline, hotel name, destination, travel|
|keywords (such as travel)|
|financial||company name (e.g., bank or insurance company),|
|keywords such as tax, loan or insurance|
|career||company name (e.g., careerbuilder, ziprecruiter, etc),|
|keywords such as job, contract, etc.|
Table 9 clearly illustrates the fact that coverage by email traffic and coverage by search query are very different in nature. One notable difference is the human category that attracts (somewhat unsurprisingly, given our previous comments on the dominance of machine-generated traffic) a disproportionate amount of searches as compared to its relatively small email volume. The finance category is similar although the ratio between the coverages is not as large as in the human category. An opposite example is that of social networks. Despite their huge coverage of the email traffic, the coverage in terms of search queries is much lower. Indeed when considering the type of messages sent by social sites, these are mostly updates and summaries of the recent events, hence are typically not messages that will be read more than once, thus will not be searched for. Overall, the coverage of the latent categories both in terms of email traffic and search queries is larger than 70%. These figures confirm the fact that latent categories could be used not only for browsing but probably even more for searching, and thus answer the needs of the two traditional discovery paradigms  since the early days of the Web.
8 Conclusions and future work
We presented here a Web-scale categorization approach that combines offline learning and online classification components. One of our key contributions is the identification of categories common to all users. We discovered latent categories by conducting a large-scale analysis of user folder data, which highligted the distinction between human and machine-generated email. Our categories cover more than 70% of both email traffic and email search queries. Our classification mechanism achieved precision and recall rates close to 90%. These results are achieved via an extremely scalable online system that assigns a category to incoming messages delivered to any user, including those who never defined a folder. We believe that this study shows a great deal of promises for this domain, as it demonstrates that email classification can be applied in production systems of the scale of Web mail.
Discussing how categories should be exposed to users, if at all, to users is out of the scope of this work but is clearly a critical challenge. Following the traditional Web discovery paradigms, they could be surfaced by explicit categories and search facets (for browsing) or behind the scenes, as an additional search signal. We hope this work will encourage other researchers to build upon these categories in order to explore new email discovery paradigms. On the backend side, which remains our focus, we plan to investigate whether sub-types within latent categories could be discovered, e.g., Travel promotions under Travel. We also intend to explore the “sender cold-start” issue, which occurs when a new sender appears, and its associated messages are too rare for us to conduct appropriate learning. As new senders keep appearing, we will need to devise appropriate methods to handle new senders in order to maintain quality.
We are grateful to Andrei Broder for inspiring this work. Yehuda Koren and Roman Sandler spent a huge number of hours manipulating thousands of folders. We owe a great deal to Edo Liberty, who discovered the power of machine-generated email, and Nemanja Djuric who conducted LDA experiments during his internship at Yahoo. Finally, this work would not be possible without the constant support of the Mail engineering and product teams at Yahoo.
-  Nir Ailon, Zohar S. Karnin, Edo Liberty, and Yoelle Maarek. Threading machine generated email. In Proceedings of WSDM’2013, pages 405–414, New York, NY, USA, 2013. ACM.
-  Inge Alberts and Dominic Forest. Email pragmatics and automatic classification: A study in the organizational context. JASIST, 63(5):904–922, 2012.
-  Olle Bälter. Keystroke level analysis of email message organization. In Proceedings of CHI’2000, pages 105–112. ACM, 2000.
-  David M Blei, Andrew Y Ng, and Michael I Jordan. Latent dirichlet allocation. JMLR, 3:993–1022, 2003.
-  Avrim Blum and Tom Mitchell. Combining labeled and unlabeled data with co-training. In Proceedings of COLT’1998, pages 92–100. ACM, 1998.
-  C. M. Bowman, P. B. Danzig, U. Manber, and M. F. Schwartz. Scalable internet: Resource discovery. Communications of the ACM, 37(8), August 1994.
-  Jake D Brutlag and Christopher Meek. Challenges of the email domain for text classification. In Proceedings of ICML’2000, pages 103–110, 2000.
-  Jeffrey Dean and Sanjay Ghemawat. Mapreduce: simplified data processing on large clusters. Communications of the ACM, 51(1):107–113, 2008.
-  Matthew Hoffman, Francis R Bach, and David M Blei. Online learning for Latent Dirichlet Allocation. In Advances in Neural Information Processing Systems, pages 856–864, 2010.
-  Svetlana Kiritchenko and Stan Matwin. Email classification with co-training. In Proceedings of the 2011 Conference of the Center for Advanced Studies on Collaborative Research, pages 301–312, 2011.
-  J. Klensin. Simple mail transfer protocol, rfc 2821, April 2001.
-  Bryan Klimt and Yiming Yang. The enron corpus: A new dataset for email classification research. In Proceedings of ECML’2004, pages 217–226. 2004.
-  Yehuda Koren, Edo Liberty, Yoelle Maarek, and Roman Sandler. Automatically tagging email by leveraging other users’ folders. In Proceedings of KDD’2011, pages 913–921. ACM, 2011.
-  John Langford, Lihong Li, and Tong Zhang. Sparse online learning via truncated gradient. JMLR, 10:777–801, 2009.
-  Jefferson Provost. Naıve-bayes vs. rule-learning in classification of email. University of Texas at Austin, 1999.
-  Fabrizio Sebastiani. Machine learning in automated text categorization. ACM Computing Surveys, 34(1), March 2002.