## 4 Experiments
### Implementation Details  
**Parameter Settings:** The experiments for UCDA were conducted on two Nvidia GeForce 3090 GPUs using the PyTorch 1.8 framework. The ResNet50 architecture was used as the backbone network, and all networks were initialized with pre-trained models from ImageNet. The datasets were augmented with random flips, cropping, and rotations. To evaluate the effectiveness of our UCDA method, we first performed basic training on the source domain to simulate the scenario where no source domain data are available for subsequent adaptation. Before inputting medical images into the network, preprocessing was applied, and all images were scaled to dimensions of 512 \(\times\) 512 pixels. During the training of UCDA, we employed the Adam optimizer with a learning rate of \(10^{-3}\) with weight decay \(10^{-4}\). The training process spanned a total of 100 epochs, with a batch size set to 32. The classifier consisted of multiple linear layers, and the balancing coefficients are set as \(\lambda_{1}=0.3\), \(\lambda_{2}=0.2\), and \(\lambda_{3}=0.5\), where the threshold parameter is \(m=0.85\).  
**Training Steps:** In model training, UCDA first utilized the uncertainty of the source domain model to select high-confidence samples from the network's predictions, combining them with the target domain model, and then the model was trained by optimizing the loss function in the target domain. In order to demonstrate the capability of our UCDA in medical image analysis, we incorporate labeled target images with varying ratios to fine tune the network. This process aims to enhance the semi-supervised performance of the source-free domain adaptation.  
**Data Division:** To perform transfer learning, we employ the NCT-CRC-HE-100K dataset as the source domain for pre-training a medical image classification model. This pre-trained model is then utilized for source-free domain adaptation on the other two histopathology datasets. For each target domain, we start by replacing the prediction layer with the corresponding class number specific to that dataset, to create the UCDA model. Moreover, sufficient validations are also conducted in the following discussion. Regarding the target domains, we incorporated the PCam dataset and LC25000 datasets for lung cancer diagnosis. Specifically, the PCam dataset was utilized to detect the presence of metastatic tissue, while 15,000 images from the LC25000 dataset were employed to identify lung pathology related to lung adenocarcinoma, lung squamous cell carcinoma, and benign lung tissue. Taking NCT-CRC-HE-100K as the target domain, we utilize the PCam dataset as a source to conduct the source-free domain adaptation, where the experimental setting is similar to that previously mentioned.  
**Evaluation:** The performance of the proposed UCDA method and the compared methods is evaluated using accuracy and macro F1-score on the testing set. Additionally, the Receiver Operating Characteristic (AUC) curve, t-Distributed Stochastic Neighbor Embedding (t-SNE), and loss curves visualization are utilized to demonstrate the classification capability of the UCDA model. Furthermore, ablation studies are conducted to assess the effectiveness of the major components of UCDA.