# Extending Partial Domain Adaptation Algorithms to the Open-Set Setting
## 4 Analysis  
We now provide theoretical support regarding the design of the proposed algorithm.  
**Proposition 1**.: _Let \(p_{1}\) and \(p_{2}\) be distributions over some bounded space \(\mathcal{X}\subseteq\mathbb{R}^{n}\) and let \(F:\mathcal{X}\rightarrow\mathbb{R}\) be some real-valued function. We define_  
\[\tilde{\mathcal{L}}[F,p_{1},p_{2}]=-E_{x\sim p_{1}}[\log(F(x))]-E_{x\sim p_{2}}[ \log(1-F(x))]\;. \tag{5}\]  
_Then,_  
\[F^{*}_{p_{1},p_{2}}(x)=\underset{F}{\arg\min}\ \tilde{\mathcal{L}}[F,p_{1},p_{2}]= \frac{p_{1}(x)}{p_{1}(x)+p_{2}(x)}\;. \tag{6}\]  
Proof.: We will use a variational calculus argument. We denote \(F^{\prime}=\
abla_{x}F=[\partial F/\partial x_{1},\ldots,\allowbreak\partial F/ \partial x_{n}]\), define the functional  
\[\hat{F}_{p_{1},p_{2}}[F(x),F^{\prime}(x),x]=-p_{1}(x)\log(F(x))-p_{2}(x)\log(1 -F(x)),\]  
and note that \(\tilde{\mathcal{L}}[F,p_{1},p_{2}]=\int_{\mathcal{X}}\ \hat{F}[F(x),F^{\prime}(x),x]\ dx\). We solve the Euler-Lagrange equations, yielding  
\[\frac{\partial\hat{F}}{\partial F}=0\Leftrightarrow\frac{p_{1}(x)}{F^{*}(x)} =\frac{p_{2}(x)}{1-F^{*}(x)}\Leftrightarrow F^{*}(x)=\frac{p_{1}(x)}{p_{2}(x) +p_{1}(x)}\]  
**Corollary 1**.: _Let \(p_{S},p_{T}\) have bounded support. Then,_  
\[\mathcal{W}^{*}(x)=\underset{\mathcal{W}}{\text{arg min}}\ \mathcal{L}_{W}= \frac{p_{S}(x)}{p_{S}(x)+p_{T}(x)} \tag{7}\]  
**Lemma 1**.: _Let \(p_{1},p_{2}\) have bounded support. Let \(w^{1},w^{2}\) be non-negative weight functions that satisfy \(E[w^{1}]=E[w^{2}]=1.\) Then, \(\tilde{\mathcal{L}}[F,w^{1}p_{1},w^{2}p_{2}]\) is well defined._  
Proof.: Let \(P^{1}(x)=w^{1}(x)p_{1}(x)\) and \(P^{2}(x)=w^{2}(x)p_{2}(x)\). Since \(\int_{\mathcal{X}}\ dP^{1}(x)=E[w^{1}]=\int_{\mathcal{X}}\ dP^{2}(x)=E[w^{2}]=1\) and \(w^{1},w^{2}\geq 0\), these are valid probability densities. Furthermore, for \(i=1,2\), the support of \(P^{i}\) is contained in the support of \(p_{i}\).  
**Corollary 2**.: _Let \(p_{S}\), \(p_{T}\) have bounded support. Let \(w^{S},w^{T}\) be as in (2) and let \(D^{*}\) be the minimizer of \(\mathcal{L}\) for a fixed \(M_{T}\). Then,_  
\[D^{*}(x)=\frac{w^{S}(x)p_{S}(x)}{w^{S}(x)p_{S}(x)+w^{T}(x)p_{T}(x)} \tag{8}\]  
**Proposition 2**.: \[-\underset{D}{\text{min}}\ \mathcal{L}\equiv-\mathcal{L}[D^{*}]=-\log(4)+ JSD(P^{w^{S}}||P^{w^{T}})\] (9)  
Proof.: We have  
\[-\underset{D}{\text{min}}\mathcal{L}=E_{p_{S}}[w^{S}(x)\log(D^{* })]+E_{p_{T}}[w^{T}(x)\log(1-D^{*})]\overset{(Corrolary1)}{=}\] \[E_{p^{w^{S}}}[\log(\frac{p^{w^{S}}}{pw^{T}+pw^{S}})]+E_{p^{w^{T} }}[\log(\frac{p^{w^{T}}}{pw^{T}+pw^{S}})]=\] \[-\log(4)+JDS(P^{w^{S}}||P^{w^{T}}) \tag{10}\]  
Essentially, we see that OSDA can be cast as an alternating optimization problem. Moreover, we see that a heuristic for identifying probable TRIs can define an algorithm for OSDA by simply normalizing its heuristic scores by using them as weights in \(\mathcal{L}\). Intuitively, we aim to down-weight the outliers in the source and target domains. We use an adapted heuristic similar to the one used in [8,11] for re-weighting. The idea behind it is that TRIs will lie near the decision boundary of a \"good\" domain discriminator, and outlier classes will be far from it; a good domain discriminator will easily distinguish that an outlier source (target) instance belongs to the source (target) domain. In particular, source instances \(x_{S}\) for which \(\mathcal{W}^{*}(x_{S})\approx 1\) are likely to be outliers, since \(\mathcal{W}^{*}\) can easily tell that they originate from the source domain. Thus, they should be down-weighted. Similarly, for target instances \(x_{T}\), \(\mathcal{W}^{*}(x_{T})\approx 0\).