Weighed Domain-Invariant Representation Learning for Cross-domain Sentiment Analysis (2020)

Abstract: Cross-domain sentiment analysis is currently a hot topic in both the research and industrial areas. One of the most popular framework for the task is domain-invariant representation learning (DIRL), which aims to learn a distribution-invariant feature representation across domains. However, in this work, we find out that applying DIRL may degrade domain adaptation performance when the label distribution \textrm{P}(\textrm{Y}) changes across domains. To address this problem, we propose a modification to DIRL, obtaining a novel weighted domain-invariant representation learning (WDIRL) framework. We show that it is easy to transfer existing models of the DIRL framework to the WDIRL framework. Empirical studies on extensive cross-domain sentiment analysis tasks verified our statements and showed the effectiveness of our proposed solution.

## introduction sentiment analysis aims to predict sentiment polarity of user-generated data with emotional orientation like movie reviews. the exponentially increase of online reviews makes it an interesting topic in research and industrial areas. however, reviews can span so many different domains and the collection and preprocessing of large amounts of data for new domains is often time-consuming and expensive. therefore, cross-domain sentiment analysis is currently a hot topic, which aims to transfer knowledge from a labelrich source domain (s) to the label-few target domain (t). in recent years, one of the most popular frameworks for cross-domain sentiment analysis is domain invariant representation learning (dirl) @xcite @xcite . methods of the dirl framework follow the idea of extracting a domain-invariant feature representation, in which the data distributions of the source and target domains are similar. based on the resultant representations, they learn the supervised classifier using source rich labeled data. the main difference among these methods is the applied technique to force the feature representations to be domain-invariant. however, in this work, we discover that applying dirl may degrade the cross-domain performance in the situation that the label distribution p(y) shifts across domains. specifically, let x and y denote the input and label random variable, respectively, and g(x) denote the feature representation of x. we found out that when p(y) changes across domains while p(x|y) stays the same, forcing g(x) to be domain-invariant will make g(x) uninformative to y. this will, in turn, harm the generation of the supervised classifier to the target domain. in addition, for the more general condition that both p(y) and p(x|y) shift across domains, we deduced a conflict between the object of making the classification error small and that of making g(x) domain-invariant. we argue that the problem is worthy of studying since the shift of p(y) exists in many real-world cross-domain sentiment analysis tasks @xcite . for example, the marginal distribution of the sentiment of a product can be affected by the overall social environment and change in different time periods; and for different products, their marginal distributions of the sentiment are naturally considered different. moreover, there are many factors, such as the original data distribution, data collection time, and data clearing method, that can affect p(y) of the collected target domain unlabeled dataset. note that in the real-world cross-domain tasks, we do not know the labels of the collected target domain data. thus, we cannot previously align its label distribution p t (y) with that of source domain labeled data p s (y), as done in many previous works @xcite @xcite @xcite @xcite . to address the problem of dirl resulted from the shift of p(y), we propose a modification to dirl, obtaining a weighted domain-invariant representation learning (wdirl) framework. this framework additionally introduces a class weight w to weigh source domain examples by class, hoping to make p(y) of the weighted source domain close to that of the target domain. based on w, it resolves domain shift in two steps. in the first step, it forces the marginal distribution p(x) to be domain-invariant between the target domain and the weighted source domain instead of the original source, obtaining a supervised classifier p s (y|x; φ) and a class weight w. in the second step, it resolves the shift of p(y|x) by adjusting p s (y|x; φ) using w for label prediction in the target domain. we detail these two steps in §4. moreover, we will illustrate how to transfer existing dirl models to their wdirl counterparts, taking the representative metric-based cmd model @xcite and the adversarial-learning-based dann model @xcite as an example, respectively. the contribution of this work is three-folder: (1) we theoretically and empirically analyse the problem of dirl for domain adaptation when the marginal distribution p(y) shifts across domains. (2) we proposed a novel method to address the problem of dirl and show how to modify existing dirl models. ## problem of domain-invariant representation learning in this work, we found out that applying dirl may harm domain adaptation in the situation that p(y) shifts across domains. specifically, when p s (y) differs from p t (y), forcing the feature representations g(x) to be domain-invariant may increase the value of l s (h) in ineq. (1) and consequently increase the value of l t (h), which means the decrease of target domain performance. in the following, we start our analysis under the condition that p s (x|y) = p t (x|y). then, we consider the more general condition that p s (x|y) also differs from p t (x|y). first, when p s (x|y) = p t (x|y), we have the following theorem. lemma 2. given p s (x|y) = p t (x|y), if p s (@xmath0 proof. proofs appear in appendix a. remark. according to theorem 2, we know that when p s (x|y) = p t (x|y) and p s (@xmath1, forcing g(x) to be domain-invariant inclines to make data of class i mix with data of other classes in the space of g(x). this will make it difficult for the supervised classifier to distinguish inputs of class i from inputs of the other classes. think about such an extreme case that every instance x is mapped to a as a result, the supervised classifier will assign the label y * = arg max y p s (@xmath2. this is definitely unacceptable. to give a more intuitive illustration of the above analysis, we offer several empirical studies on theorem 2 in appendix b. in addition, when p s (y) = p t (y) and p s (x|y) = p t (x|y), we did not obtain such a strong conclusion as theorem 2. instead, we deduced a conflict between the object of achieving superior classification performance and that of making features domain-invariant. specifically, suppose that p s (@xmath3, i.e.,: in dirl, we hope that: consider the region @xmath4, where p(g(@xmath5. according to the above assumption, we know that p(g(@xmath6. therefore, applying dirl will force in region @xmath7. taking the integral of x over x i for both sides of the equation, we have p s (@xmath8. this deduction contradicts with the setting that p s (@xmath9. therefore, g(x) is impossible fully class-separable when it is domain-invariant. note that the object of the supervised learning is exactly to make g(x) class-separable. thus, this actually indicates a conflict between the supervised learning and the domain-invariant representation learning. based on the above analysis, we can conclude that it is impossible to obtain a feature representation g(x) that is class-separable and at the same time, domain-invariant using the dirl framework, when p(y) shifts across domains. however, the shift of p(y) can exist in many cross-domain sentiment analysis tasks. therefore, it is worthy of studying in order to deal with the problem of dirl. ## weighted domain invariant representation learning according to the above analysis, we proposed a weighted version of dirl to address the problem caused by the shift of p(y) to dirl. the key idea of this framework is to first align p(y) across domains before performing domain-invariant learning, and then take account the shift of p(y) in the label prediction procedure. specifically, it introduces a class weight w to weigh source domain examples by class. based on the weighted source domain, the domain shift problem is resolved in two steps. in the first step, it applies dirl on the target domain and the weighted source domain, aiming to alleviate the influence of the shift of p(y) during the alignment of p(x|y). in the second step, it uses w to reweigh the supervised classifier p s (y|x) obtained in the first step for target domain label prediction. we detail these two steps in §4.1 and §4.2, respectively. ## conclusion in this paper, we studied the problem of the popular domain-invariant representation learning (dirl) framework for domain adaptation, when p(y) changes across domains. to address the problem, we proposed a weighted version of dirl (wdirl). we showed that existing methods of the dirl framework can be easily transferred to our wdirl framework. extensive experimental studies on benchmark cross-domain sentiment analysis datasets verified our analysis and showed the effectiveness of our proposed solution. proof. let us first consider the binary classification situation. since g makes p s (g(x)) = p t (g(x)) and p s (x|y) = p t (x|y), we have: this proof can be easily extended to the multi-class classification problem by treating class i as one class and classes @xmath10, • • • , l, @xmath11, completing the proof.