dataesr/scientific-paragraphs-categorization huggingface dataset:
Implementation Our method is available in the R package adjclust, using an underlying implementation in C and available on CRAN 2. Additional features have been implemented to make the package easier to use and results easier to interpret. These include: • plots to display the similarity or dissimilarity together with the dendrogram and a clustering corresponding to a given level of the hierarchy as illustrated in Supplementary Figure  S6 ; • wrappers to use the method with SNP data or Hi-C data that take data from standard bed files or outputs of the packages snpStats and HiTC respectively; • a function to guide the user towards a relevant cut of the dendrogram (and thus a relevant clustering). In practice the underlying number of clusters is rarely known, and it is important to choose one based on the data.
Two methods are proposed in adjclust: the first is based on a broken stick model  [Bennett, 1996]  for the dispersion. Starting from the root of the dendrogram, the idea is to iteratively check whether the decrease in within-cluster variance corresponding to the next split can or cannot be explained by a broken stick model and to stop if it can. To the best of our knowledge this broken stick strategy is ad hoc in the sense that it does not have a statistical justification in terms of model selection, estimation of the signal, or consistency. The second method is based on the slope heuristic that is statistically justified in the case of segmentation problems  [Arlot et al. , 2016b, Garreau and Arlot, 2016] , for which HAC provides an approximate solution. This later approach is implemented using the capushe package  [Arlot et al.
, 2017]  based on their pairwise Linkage Disequilibrium (LD). In particular, a widely used measure of LD in the context of GWAS is the r 2 coefficient, which can be estimated directly from genotypes measured by genotyping array or sequencing data using standard methods  [Clayton, 2015]. The similarity S = (r 2 ij ) i,j induced by LD can be shown to be a kernel (see Section S1. 3 of Supplementary material). Identifying blocks of LD may also be useful to define tag SNPs for subsequent studies, or to characterize the recombination phenomena. Numerical experiments were performed on a SNP dataset coming from a GWA study on HIV  [Dalmasso et al. , 2008]  based on 317k Illumina genotyping microarrays. For the evaluation we used five data sets corresponding to five chromosomes that span the typical number of SNPs per chromosome observed on this array (p = 23, 304 for chromosome 1, p = 20, 811 for chromosome 6, p = 14, 644 for chromosome 11, p = 8, 965 for chromosome 16 and p = 5, 436 for chromosome 21).
For each dataset, we computed the LD using the function ld of snpStats, either for all SNP pairs (h = p) or with a reduced number of SNP pairs, corresponding to a bandwidth h ∈ {100, 200, 500, 1000, 2000, 5000, 10000, 20000}. The packages rioja  [Juggins, 2018]  (which requires the full matrix to be given as a dist object 3  ) and adjclust with sparse matrices of the class dgCMatrix (the default output class of ld) were then used to obtain hierarchical clusterings. All simulations were performed on a 64 bit Debian 4. 9 server, with 512G of RAM, 3GHz CPU (192 processing units) and concurrent access. The available RAM was enough to perform the clustering on the full dataset (h = p) with rioja although we had previously noticed that rioja implementation could not handle more than 8000 SNPs on a standard laptop because of memory issues.
Data and method Data used to illustrate the usefulness of constrained hierarchical clustering for Hi-C data came from  Dixon et al. [2012] ,  Shen et al. [2012]. Hi-C contact maps from experiments in mouse embryonic stem cells (mESC), human ESC (hESC), mouse cortex (mCortex) and human IMR90 Fibroblast (hIMR90) were downloaded from the authors' website at http://chromosome. sdsc. edu/mouse/hi-c/download. html (raw sequence data are published on the GEO website, accession number GSE35156. All chromosomes were processed similarly: • counts were log-transformed to reduce the distribution skewness; • constrained hierarchical clustering was computed on log-transformed data using either the whole matrix (h = p) or the sparse approach with a sparse band size equal to h = {0. 5p, 0. 1p}; • model selection was finally performed using both the broken stick heuristic and the slope heuristic.
Influence of the bandwidth parameter The effect of h (sparse band parameter) on computational time, dendrogram organization and clustering were assessed. Figure  5  gives the computational times versus the chromosome size for the three values of h together with the computational time obtained by the standard version of constrained hierarchical clustering as implemented in the R package rioja. As expected, the computational time is substantially reduced by the sparse version (even though not linearly with respect to h because of the preprocessing step that extracts the band around the diagonal), making the method suitable for dealing efficiently with a large number of chromosomes and/or a large number of Hi-C experiments. rioja, that cannot cope efficiently with the sparse band assumption, requires considerably more computational time (10 times the time needed by adjclust).
In addition, the memory required by the two approaches is very different: adjclust supports sparse matrix representation (as implemented in the R package Matrix), which fits the way Hi-C matrices are typically stored (usually these matrices are given as rows with bin number pairs and associated count). For instance, the sparse version (dsCMatrix class) of the largest chromosome (chromosome 1) in the hESC data is 23 Mb, as opposed to 231 Mb for the full version. The sparse version of the smallest chromosome (chromosome 22) is 1. 1 Mb, versus 5. 2 Mb for the full version. The sparse version of the h = 0. 1p band for these two chromosomes is, respectively, 13. 2M and 0. 4Mb respectively. However, this gain in time and space did not impact the results of the method: the indexes of the first difference were computed between the dendrograms obtained by the full version (h = p) and by the two sparse versions (h ∈ {0.
5p, 0. 1p}) for every chromosome. For most of the clusterings there was no difference in merge for h = 0. 5p (with the similarity computed as in Figure  3  always larger than 0. 9992, and equal to 1 in more than 3 clusterings out of 4). For h = 0. 1p, the similarity ranged from 0. 9811 to 0. 9983. Baker's Gamma index and Rand indices  [Hubert and Arabie, 1985]  for selected clusterings (both with broken stick and slope heuristic) confirmed this conclusion (results not shown). Figure  5 : Impact of sparsity on the computational time. Dots that correspond to the same datasets but different chromosomes are linked by a path.
Conclusion and prospects We have proposed an efficient approach to perform constrained hierarchical clustering based on kernel (or similarity) datasets with several illustrations of its usefulness for genomic applications. The method is implemented in a package that is shown to be fast and that currently includes wrappers for genotyping and Hi-C datasets. The package also provides two possible model selection procedures to choose a relevant clustering in the hierarchy. The output of the method is a dendrogram, which can be represented graphically, and provides a natural hierarchical model for the organization of the objects. The only tuning parameter in our algorithm is the bandwidth h. The numerical experiments reported in this paper suggest that at least for GWAS and Hi-C studies, there exists a range of values for h such that h p (which implies very fast clustering) and the result of the HAC is identical or extremely close to the clustering obtained for h = p.
S2 Algorithm In this section we provide a detailed description of the method presented in Section 2. 2. 2 of the article, which is implemented in the adjclust package. We also give illustrations of the first steps of this algorithm when applied to the RLGH data set provided in the package rioja, which data are relative abundances of 41 taxa in p = 20 stratigraphic samples. A detailed description of this data set is provided in the help of the RLGH data set. While the method in Section 2. 2. 2 is described in terms of clusters, Algorithm S2 is best expressed in terms of candidate fusions. The initialization step (lines 1 to 3) consists in building the heap of p -1 candidate fusions between the p adjacent items. At the end of this step, the root of the heap contains the best fusion among such fusions.
Acknowledgements The authors would like to warmly thank  Michel Koskas  for very interesting discussions, and for proposing a very elegant alternative implementation. The authors are grateful to the  GenoToul bioinformatics platform (INRA Toulouse , http: //bioinfo. genotoul. fr/)and its staff for providing computing facilities. P. N. and N. V. would like to thank  Shubham Chaturvedi  for his contribution to the package adjclust via the R project in google summer of code 2017.
This work proposes PatchNet, an automated tool based on hierarchical deep learning for classifying patches by extracting features from commit messages and code changes. PatchNet contains a deep hierarchical structure that mirrors the hierarchical and sequential structure of a code change, differentiating it from the existing deep learning models on source code. PatchNet provides several options allowing users to select parameters for the training process. The tool has been validated in the context of automatic identification of stable-relevant patches in the Linux kernel and is potentially applicable to automate other software engineering tasks that can be formulated as patch classification problems. A video demonstrating PatchNet is available at https://goo.
I. INTRODUCTION AND RELATED WORK Deep learning techniques have recently been used to automate some software engineering tasks such as code clone detection  [1] , software traceability link recovery  [2] , and bug localization  [3]. However, no existing work has investigated the problem of learning a semantic representation of code changes, i. e. , patches, for classifying them into predefined classes. Patches are composed of a short text describing a change, the lines removed by the change, and the lines added by the change, and all these pieces need to be considered in a holistic way to produce a good semantic representation. Patch classification is an important problem since many automated software engineering tasks, such as just-in-time defect prediction  [4] , tangled change prediction  [5] , code reviewer recommendation for a commit  [6] , etc.
This paper presents our tool PatchNet that performs learning on a set of patches. PatchNet performs deep patch classifica-tion in two phases. In the training phase, it takes as input a set of labeled patches to learn a deep learning model. This model is then used in the prediction phase on a set of unlabeled patches to produce scores that estimate how likely the given patches fit the class labels. Specifically, PatchNet aims to automatically learn two embedding vectors, representing a commit message and a set of code changes in a given patch, respectively. The two embedding vectors are then used to compute a prediction score from a given patch estimating how likely the patch is relevant to a particular class. PatchNet is implemented as a command line tool. In the training phase, the user provides a file of labeled patches and the name of a folder in which to put the trained Patch-Net model.
In the prediction phase, the command used to produce the prediction scores also takes two inputs: a file of unlabeled patches and the name of the folder containing the previously trained model. PatchNet also provides several supplementary options to allow users to select hyperparameters for the training process. PatchNet targets binary classification tasks, however, it can also be used for multi-label classification tasks by reducing the problem of multi-label classification to multiple binary classification problems  [9]. PatchNet currently only supports patches on C code. PatchNet has been applied to the task of stable patch identification in the Linux kernel. Specifically, the Linux kernel follows a two-tiered release model in which a mainline version accepts bug fixes and feature enhancements, and a series of stable versions accepts only bug fixes  [10].
While the mainline targets users who want to benefit from the latest features, the stable versions target users who value the stability of their kernel. The stable kernel development process requires that all patches be submitted to the mainline, and then propagated by maintainers from there to review for inclusion in stable kernels. The wide variation in rates at which patches are propagated by maintainers to stable kernels across the code base suggest that some bug-fixing patches may be being overlooked. There is thus the potential for an automated, learning-based approach to improve this process. Our evaluation on 82,403 recent Linux patches shows that PatchNet outperforms the state-of-the-art baseline (i. e. , LPU+SVM), achieving precision of 0. 839 and recall of 0. 907. By releasing our tool, we hope to enable others to apply PatchNet to other patch classification tasks.
The rest of this paper is organized as follows. Section II provides a bird's-eye view of the PatchNet architecture. Section III describes how PatchNet preprocesses the patch data arXiv:1903. 02063v2 [cs. SE] 26 Mar 2019 before initiating the learning process. Section IV illustrates how PatchNet can be used in various scenarios. Section V summarizes some experiments with PatchNet. Finally, we conclude in Section VI.
II. OVERALL DESIGN Figure  1  shows the overall design of PatchNet. PatchNet accepts as input a set of patches, each of which contains both a commit message and a code change. The output of PatchNet associates each patch with a prediction score reflecting how likely the patch satisfies the criteria of the classification. Our framework includes three main modules: the commit message module, the code change module, and the classification module. The commit message module and the code change module transform the commit message and the code change into embedding vectors e m and e c , respectively. The two embedding vectors are then passed to the classification module, which computes the prediction score. In the rest of this section, we give an overview of each of these modules. Commit message module: The architecture of the commit message module is the same as the one proposed by Kim  [11]  for sentence classification.
This module takes a commit message as input and outputs an embedding vector that represents the most salient features of the message. Specifically, we encode the commit message as a two-dimensional matrix by viewing the message as a sequence of vectors where each vector represents a word appearing in the message. We then apply a convolutional layer followed by a max-pooling operation to obtain the message's salient features. Code change module: Similar to a commit message, a code change can be viewed as a sequence of words. This view, however, overlooks the structure of code changes, as needed to distinguish between changes to different files, changes in different hunks (contiguous sequences of removed and added code), and different kinds of changes (removals or additions). To address this challenge, PatchNet contains a deep hierarchical structure that mirrors the hierarchical and sequential structure of patch code, making it distinctive from the existing deep learning models on source code  [12].
For the code changes in a given patch, PatchNet outputs an embedding vector that represents the most salient features of these changes. The code change module contains a file module that automatically builds an embedding vector representing the code changes made to a given file in the patch. Figure  2  shows the architecture of the file module. This module takes as input two matrices (denoted by "-" and "+" in Figure  2 ) representing the removed code and added code for the affected file in a patch, respectively. These two matrices are passed to the removed code module and the added code module, respectively, to construct the corresponding embedding vectors by taking into account the structure of the removed or added code. The input of the removed code module is a three dimensional matrix, indicating the removed code in the affected file of the given patch, denoted by B r ∈ R H×N ×L , where H, N , and L are the number of hunks, the number of removed code lines for each hunk, and the number of words of each removed code line in the affected file, respectively.
This module constructs an embedding vector (denoted by e r ) representing the removed code in the affected file. The added code module also takes as input a three dimensional matrix, indicating the added code in the affected file of the given patch. It follows the same architecture as the removed code module to construct an embedding vector (denoted by e a ) representing the added code in the affected file. These changes in the added and removed code are padded or truncated to have the same number of hunks (H), number of lines for each hunk (N ), and number of words in each line (L) for parallelization. Moreover, both modules also share the same vocabulary. The two embedding vectors are then concatenated to represent the code changes in each affected file, i. e. , e f = e r ⊕ e a. The embedding vectors of the code changes at the file level are then concatenated into a single vector representing all the code changes made by the patch.
Classification module: The classification module takes as input the commit message embedding vector (e m ) and the code change embedding vector (e c ) (see Figure  1 ). These two vectors are then concatenated to form a single vector representing the patch, i. e. , e = e m ⊕ e c. The concatenated vector e is passed to a fully-connected layer and an output layer, which computes a probability score for the patch. If an additional source of information is available, PatchNet can be easily extended by concatenating an additional information vector (denoted by e i ), collected from the data, to the commit message embedding vector and the code change embedding vector (i. e. , e = e m ⊕e c ⊕e i ) to form a new vector representing the given patch. Parameter learning: During the training process, PatchNet uses adaptive moment estimation (Adam)  [13]  to minimize the regularized loss function  [14].
III. DATA SELECTION AND PREPROCESSING The user is responsible for selecting commits for training and annotating them according to the chosen classification scheme. For each commit, preprocessing is then applied to the commit message and the code changes. For the commit message, PatchNet applies standard natural language preprocessing techniques, such as stemming and stop word elimination. For the code changes, PatchNet detects the changed lines using diff, and then expands these changes to include the complete innermost enclosing simple statement, if any, or the header of a conditional or loop, if the change occurs in such code. Lines within the changes are annotated as errorchecking code (an if test that checks for failure of a previous operation), error-handling code (code that performs cleanup in case of failure of a previous operation) or normal (for everything else), reflecting one aspect of the semantics of the code.
A. Preprocessing The preprocessing step is time consuming for large datasets, and is thus separated from the rest of the training and classification process. The main input to the preprocessing step is a file containing a list of commit identifiers and their labels. The preprocessing step also needs to know the pathname of the git tree containing the commits and a prefix used to construct the names of the various output files. The output is a pair of files, containing the patch data and a dictionary for interpreting the patch data. Only the former needs to be provided to the subsequent training and classification process. A typical command line is: PatchNet has been developed and tested on the Linux platform. However, we believe that PatchNet can be employed.
C. Scenario II -Tuning PatchNet's Hyperparameters Table  I  highlights the key hyperparameters that control how PatchNet trains its model. The --data_type flag allows the user to choose what information to include from the patches (i. e. , commit messages, code changes, or both). The user can also change other hyperparameters of the model such as the dimension of embedding vectors (i. e. , "--embedding_dim"), number of filter sizes (i. e. , "--filter_sizes"), number of filters (i. e. ,"--num_filters"), etc. The following example illustrates how to execute PatchNet with custom settings: python PatchNet. py --train --data data. out --model patchnet --embedding_dim 128 --filter_sizes "1,2" --num_filters 64.
V. STABLE PATCH IDENTIFICATION We have applied PatchNet to the problem of identifying Linux kernel bug-fixing patches that should be backported to previous stable versions. Based on a set of 42,408 stable patches and 39,995 non-stable patches drawn from Linux kernel versions from v3. 0 (July 2011) to v4. 12 (July 2017), we trained and tested the PatchNet model using its default hyperparameters following 5-fold cross-validation. Considered patches are limited to 100 lines of changed code, following the Linux kernel stable patch guidelines. Non-stable patches in the dataset are chosen to have the same size properties (number of files and number of changes lines) as the stable ones. Table  II  shows the performance (i. e. , accuracy, precision, recall, and F1) on this problem of LPU+SVM  [7]    VI.
CONCLUSION In this work, we present PatchNet, a tool that learns a semantic representation of patches for classification purposes. PatchNet contains a deep hierarchical structure that mirrors the hierarchical and sequential structure of commit code, making it distinctive from the existing deep learning models on source code. We have demonstrated the tool's applicability in identifying stable patches in Linux kernel. We encourage future researchers to benefit from PatchNet by applying it to other tasks that can be mapped to a patch classification problem. PatchNet is open-source and can be run from the command line with simple options.
Studies of Martian craters morphometry have already been conducted. Some provide scaling laws between depth and diameter for fresh craters (  [33]  and therein), while other focus on crater degradation with time  [32, 34, 35]. However, those studies often rely on a restricted number of craters or mainly focus on large craters. Robbins and Hynek  [27]  database provide crater depth for Martian craters with a diameter larger than 3 km. With the growth of high-resolution imagery, below 10 m/pixel, it becomes now possible to study the dynamics and degradation of small impact craters on Mars (smaller than 100 m). In this diameter range, target properties may affect the initial crater/depth ratio  [3, 14, 28]. This diameter range also covers many secondary craters which are generally shallower than primaries  [26, 36].
Here we present a semi-automatic algorithm for measuring crater depths on a DEM. Crater depths are measured as the difference between the high 60 th percentile value of elevations on the edge of the crater and the low 3 rd percentile value of elevations within the crater. We describe the algorithm and the used imagery, which allows to rapidly produce large datasets of crater depth. We calibrated the parameters of the method by comparing produced depths with measurements made at higher spatial resolution. This comparison also provides error estimates on our measured depth. Quantification of the error allows a more robust exploitation of crater statistics with the kernel density estimation, providing continuous depth or diameter distributions.