dataesr/scientific-paragraphs-categorization huggingface dataset:
ML-CatchUp automatically detects the specified deprecated API usages and applies the inferred transformation operations, updating the deprecated API usages within the code. MLCatchUp also leverages type inference, allowing it to determine variable types and function return types. To the best of our knowledge, we are the first to create an automated API usage update tool without update examples for Python. We evaluated MLCatchUp using a test dataset of 267 realworld Python code files collected from Github public repositories. Each file contains one to five deprecated API usages, amounting to a total of 551 deprecated API usages. In this evaluation, MLCatchUp can detect 93. 7% of the deprecated API usages without type inference. The addition of type inference improves MLCatchUp's deprecated API usage detection rate to 100%.
A. MLCatchUp Architecture The architecture of MLCatchUp is shown in Fig. 1. ML-CatchUp has two main inputs: the input file to be updated (O-1) and the input API signatures for both a deprecated API and its replacement (O-2). The input file is parsed into an Abstract Syntax Tree (AST) using the built-in Python module. 1  Type inference is applied to the AST to determine the types of variables and method call return values. Then, MLCatchUp locates the deprecated API usages by comparing the fully qualified name of the method calls within the code to the deprecated API signature (S-1), resulting in the deprecated API usage locations (O-3). MLCatchUp uses the input API signatures in the transformation inference process (S-2). The inferred transformations are in the form of DSL commands (O-4) which contain a series of operations that will be performed sequentially for the update (e.
g. , rename a method, rename a parameter, etc. ). The DSL is then parsed into a list of operations to be executed by MLCatchUp. These operations are applied to the deprecated API usage locations (S-3), producing the updated AST (O-5). The updated AST is then compared with the input file AST to check for code differences between the two. Any found code differences are then applied to the input Python file (S-4) by making only the necessary changes to the API usages without any modification to the original code comments and spacing. This results in the updated input file (O-6). We next further describe the main components of MLCatchUp.
B. MLCatchUp Transformation Operations The transformation operations provided by MLCatchUp are based on an empirical study of 112 deprecated APIs and their replacements from the last two years of releases of Scikit-learn, PyTorch, and Tensorflow  [14]. The transformation operations that are supported by MLCatchUp are: (1) rename a method; (2) rename a parameter; (3) remove a parameter; (4) convert a positional to a keyword parameter; (5) add a parameter; (6) change a parameter type;  (7)  add a constraint to a parameter value; and (8) remove API. Further details about the transformation operations are found in our full research paper  [14]. 1 https://docs. python. org/3/library/ast. html.
C. MLCatchUp Transformation Inference MLCatchUp automatically infers the required transformations for API usage update based on the difference between the deprecated and updated API signatures. We define an API signature as the fully qualified name of the API (i. e. the API's module and function name) and the list of parameters available for the API, where each parameter consists of the parameter name and an optional default value. Given a pair of deprecated and updated API signatures, MLCatchUp performs a sequence of comparisons, including a comparison of the API names, and comparisons of their parameter names, positions, types, and default values. These comparisons will produce the required transformation operations for the API update.
E. Type Inference MLCatchUp uses type inference to determine variable types and the return types of method calls. This type information is used to replace the variable or the method name used in an API invocation to determine the API's fully qualified name. The type inference is implemented using PEP (Python Enhancement Proposal) 484, 2  that provides type hints and annotations for Python code. For this purpose, MLCatchUp use Mypy  [13] , a static type checker for Python that uses the PEP 484 type hints. Mypy's APIs are used to analyze MLCatchUp's input code, collecting variable and method types by searching for type annotations from the imported library. The collected types are used to replace the variables and method calls during the deprecated API usage detection. To further enhance MLCatchUp's type inference functionality for libraries that do not provide type annotations, we also use deep learning-based type inference  [12].
A neural model is trained using hierarchical neural network (HNN) with a dataset of 4,910 Python projects. From the Python source code files, type hints (i. e. , information helpful in predicting types) are extracted. These type hints consist of information taken from the function (function name, function arguments) and the code context (return statement, function argument usages). To enable the model to learn from the type hints, the Word2Vec  [15]  word embedding is used. After the neural model is trained, the Triplet Loss function is used to create type clusters, where each cluster represents a similar type. These type clusters are used for type prediction. Given a method signature as an input, the model will extract the type hints and create the feature embedding. Then, KNN (k-nearest neighbor) search is used to determine which type is the closest to the given embedding.
A. Dataset and Experiment Settings We evaluated MLCatchUp on a dataset of 267 files containing 551 deprecated ML API usages in Python from GitHub repositories. They are comprised of 68 different deprecated APIs from Scikit-learn, PyTorch, Tensorflow, Numpy, and Spacy. For each deprecated API, we randomly collected at most five files. We consider two metrics in this evaluation: (1) detection rate (i. e. , the number of detected deprecated API usages divided by the ground truth number of deprecated API usages) and (2) update accuracy (i. e. , the number of correct updates produced by MLCatchUp compared to the ground truth number of deprecated API usages). We use automated and manual analysis to determine the correctness of the updated code. In the automated analysis, we check the validity of the updated code syntax by compiling it using the Python built-in py compile module.
IV. USAGE EXAMPLE MLCatchUp can be used by both library users and developers via a command line interface (CLI). To update usages of a deprecated API, a user needs to provide the deprecated and updated API signatures, along with the code that needs to be updated. MLCatchUp's update process consists of two steps: The command instructs MLCatchUp to infer the required transformation for migrating a deprecated tensorflow. compat. v1. to_float() API usage. MLCatchUp detects that the two API signatures have different method names and an addition of API parameter in the updated API signature, thus a rename_method and an add_parameter operations are added. The added parameter value for the 3 We use the DSL file to instruct MLCatchUp to transform the code shown in Fig. 2 ; we use the following command: This command instructs MLCatchUp to apply the transformation specified in the DSL.
B. Scenario II -Context-dependent API Migration As MLCatchUp is unable to automatically infer the required transformation constraints for context-dependent deprecated API migration, the user needs to manually add this information into the inferred DSL script. Consider the migration of usages of the deprecated API sklearn. model_selection. K-Fold that needs to be updated with an add_parameter operation only if the value of random_state argument is not None. The input for the transformation inference process is as follows: V. RELATED WORK Several works have attempted to automate the update of deprecated API usages. Diff-CatchUp  [16]  is a classic work that automatically detects API changes in the library, infers possible replacements, and identifies possible examples on how to migrate the changed APIs from the library's code base.
Diff-CatchUp however does not produce a transformation script or come with a transformation engine that can automatically update occurrences of broken API usages in a client code base. Rather, developers need to manually perform the transformations based on the examples and information produced by Diff-CatchUp. A4  [8]  automatically assists Android API migrations by learning API migration patterns from code examples. AppEvolve  [9]  automates API-usage update for Android, creating patches from before-and after-update code examples. CocciEvolve  [10]  infers a readable transformation in the form of the semantic patch language (SmPL)  [17]  using only a single after-update code example. NEAT  [11]  generates transformation rules for deprecated Android API usage migrations without any update example.
REFAZER  [18]  synthesizes program transformations for Python code by inductive programming using input-output examples. T2R  [19]  performs automatic type migration for Java code to help fix API-breaking changes in evolving codebases. No work has been done on the automated migration of Python deprecated APIs. MLCatchUp offers automated migration of Python deprecated API usages without any update example. MLCatchUp does not require the source code of the APIs' library, as it only needs the deprecated and updated API signatures to infer the required update. MLCatchUp also addresses Python's unique features such as dynamic-typing through type-inference using a combination of static analysis and deep learning.
VI. CONCLUSION AND FUTURE WORK In this paper, we present MLCatchUp, a tool that automates the update of usages of deprecated APIs of popular Python ML libraries. MLCatchUp automatically infers the required transformation from the differences between the deprecated and updated API signatures, and presents the operations in the form of a DSL. MLCatchUp is built with type inference, allowing it to determine variables and function return types. We have evaluated the performance of MLCatchUp and demonstrated that it achieves 100% deprecated API usages detection rate with type inference. We have also evaluated the update accuracy of MLCatchUp, where it achieves an accuracy of 80. 6% without user-provided transformation constraints, and an accuracy of 90. 7% with the addition of such constraints.
g. ,  Haywood et al. 2014 ), which may be implemented with the george package  (Ambikasaran et al. 2015). In contrast to the george quasiperiodic kernel, the celerite quasiperiodic kernel is not mean-square differentiable  (Rasmussen & Williams 2006) , and its covariance decreases faster for a fixed decay timescale parameter (denoted L for the celerite kernel, and λ e for the george kernel). Our fitting process made use of the nested sampler PyMultinest  (Feroz & Hobson 2008; Feroz et al. 2009; Buchner et al. 2014; Feroz et al. 2019). The sampling parameters included 4000 live points (except for our GP and 2-Planets model, which used 6000 live points), a sampling efficiency of 0. 6, and an evidence tolerance of 0. 5. For each model, the sampler was run three times in order to obtain a median and standard deviation on the log-evidence  ln.
Integrated Spectrum over a Simulated Disk We simulated the stellar spectrum over time as the surface inhomogeneities reconstructed in the previous section rotated into and out of view for the time baseline of the TESS Sector 31 observations. This timeframe overlaps with 32 (of 164 total) spectra of ò Eri obtained with EXPRES between 2020 October and November. Our simulation is similar to the SOAP software  (Boisse et al. 2012) , which models perturbations to the spectral line profile induced by circular spots and plages, while accounting for limb darkening, stellar rotation, and stellar geometry. Additional physics, including an improved limb darkening and a model of convective blueshift suppression, were incorporated into SOAP2 by  Dumusque et al. (2014). In a similar vein, 2D simulations of stellar disks have been used in studies of exoplanet transits (Casasayas-Barris et al.
As a consistency check, we summed the white-light flux of the projected disk at 30 equally-spaced intervals during a single rotation and recovered the relative brightness variations in the TESS light curve. The effects of resolution were explored, and we found the results did not change appreciably when more pixels were used to model the disk. RVs were obtained from the integrated spectrum via cross-correlation with the original stellar template. Our LI surface model for the TESS Sector 31 data is shown in Figure  7  and compared to both the actual EXPRES data, the GP model described in Section 3, and an FF′ model  (Aigrain et al. 2012 ) discussed in the next section. The Keplerian component of the known planet has been subtracted, but this represents only a marginal RV trend of ∼18 cm s -1 over the ∼20 day timespan of the RVs considered.
The RVs from the LI model contain relative velocity variations that arise from perturbations to the spectral line profile caused by the simulated spot. The actual EXPRES RVs are also relative velocities; however, the relative velocity offset in the EXPRES data changes as new data are acquired and will only asymptotically approach a constant value after all of the signals ( i. e. , the known planet in a 7 yr orbit and the photospheric contributions) have been well sampled over all phases. The temporal baseline of the EXPRES RVs, which is slightly over 1 yr, is not sufficient to reach that constant offset, so we derived and removed the best-fit offset between the simulated and observed RVs. The subset of EXPRES RVs taken during the TESS Sector 31 observations has an rms scatter of 4. 72 m s -1.
If we adopt corrections from the GP model, this scatter is reduced to 0. 76 m s -1. However, the GP model, by definition, is conditioned on the data to which it is fit. Therefore, the residuals reflect the measurement uncertainties added in quadrature with the jitter term s k , added to account for intra-night scatter. Intra-night s k can arise from p-mode oscillations, granulation, or underestimation of formal uncertainties. This illustrates one of our primary concerns: even when the hyperparameters are conditioned on photometric observations, the GP's flexibility (which is based on its parameterization and likelihood) allows it to conform to the RV measurements very closely, typically within <1 m s -1 from individual measurements or the mean RV of a given night. The LI surface model, however, is completely independent of the EXPRES RVs.
(2021). A particular advantage of the LI surface model is its derivation from an independent, photometric data set, which eliminates the possibility of Keplerian signals being absorbed into the model. We previously showed that photometry-preconditioned GPs are prone to conform to low-amplitude variations from a planet if that   2 ). The orange curve depicts the RV variations obtained by rotating the LI-reconstructed stellar surface and integrating the stellar spectrum over a pixelated disk. For reference, snapshots of the disk model are shown for several selected timestamps of RV exposures. The features on the surface are responsible for the RV variations in the model, and a faint dashed line connects each snapshot to the corresponding point on the RV model curve. The gray curve represents an FF′ model  (Aigrain et al.
e. , adding five additional parameters to the model does not sufficiently improve its log-likelihood;  Cabot et al. 2021). This effect is especially true for sparse RV data sets. Another advantage is that the LI surface model has a direct, clearly interpretable correspondence to a physical characteristic of the star (i. e. , resolved surface features), while GPs typically do not. One may use specific, physically-motivated GP kernels (e. g. , quasiperiodic ones) and find a repeating structure that corresponds to long-lived surface features, but it is a degenerate problem to invert the GP model and resolve surface features or other specific qualities of the star. In our case, the GP clearly does not correspond to the effects of surface features at all times and deviates at a >2σ level from the LI surface model at most times (Figure  7 ).
GP models that fit multiple, contemporaneous time series at once (e. g. ,  Rajpaul et al. 2015; Gilbertson et al. 2020 ) in implementations such as pyaneti  (Barragán et al. 2022)  were not tested in this study, but may make for interesting future comparison against the LI model. Compared to the photometrypreconditioned GP used here, they may have reduced flexibility. At present, GPs remain a useful model for stellar activity, which can greatly assist with identifying and constraining Keplerian signals. However, accurately modeling RV variations with alternative and complementary data sets is an important goal, both for robustness against inadvertently removing Keplerian signals and for the interpretability of the activity model.
Although the method is being utilized for searching for hot Jupiters orbiting young stars  (Heitzmann et al. 2021 ), Doppler imaging is not an appropriate imaging method for mainsequence stars, like ò Eri, because the stars' slow rotation does not provide sufficient spatial resolution. To date, interferometric aperture synthesis imaging, which unambiguously provides latitude information, has not been performed on main-sequence stars. However, our models of two data sets from the CHARA Array with the MIRC-X beam combiner indicate that detailed images of bright, spatially large main-sequence stars are possible with sufficient uv plane coverage and prominent spots. Between the two interferometric observations, ò Eri rotated in approximately a quarter rotation with the starspot present on both nights of the interferometric data being in the same spot.
Our models potentially constrain stellar orientation. The interferometric data suggests that the star's rotation axis is oriented along the position angle ∼335°east of north. This was determined by rotating the LI reconstruction such that the MIRC-X observations would have the same longitude (see Section 4. 3 and Appendix B). As we have only a small number of interferometric observations, confirmation of this position angle requires further observations. The starspot was observed approximately 20°of latitude away from the starspot in the LI reconstructions. This is in line with the expectation that surfaces reconstructed with LI will not necessarily place the starspots at the appropriate stellar latitudes. LI favors smaller spots, which the regularizer identifies as "smoother"; in combination with only one bandpass with limited limb-darkening constraints, LI will reconstruct the surface with starspots at the sub-Earth latitude.
The method developed here will work best when the imaging and RV observations are obtained contemporaneously to ensure that the same stellar surface evolution is being observed. As seen for ò Eri in Figure  3 , the surface structures of main-sequence stars can change on timescales shorter than the stellar rotation. While each high-cadence data set investigating the stellar activity and potential for planetary companions is valuable, combining the data sets as we describe here allows for the strengths of EPRV and stellar surface imaging to be harnessed in a way otherwise only accessible for the Sun. The unique value of solar studies is prior detailed knowledge of surface features coupled with EPRV measurements. We are working toward extending this to other stars by using high-cadence photometry to reconstruct the stellar surface and verify that current interferometric capabilities can detect starspots on a main-sequence star.
Support for the design and construction of EXPRES is provided by the  National Science Foundation (NSF )  MRI-1429365  and  ATI-1509436  and  Yale University. We gratefully acknowledge support to carry out this research from  NSF   2009528 ,  NSF   1616086 ,  NASA 17-XRP17 2-0064 , the  Heising-Simons Foundation , and an anonymous donor in the  Yale alumni community. The  CHARA Array  is supported by the  NSF  under grant Nos. AST-1636624  and  AST-1715788. Institutional support has been provided by the  GSU College of Arts and Sciences  and the  GSU Office of the Vice President for Research and Economic Development. MIRC-X  received funding from the  European Research Council (ERC)  under the European Unionʼs  Horizon 2020 research and innovation program  (grant No. 639889 ). This research has made use of the  Jean-Marie Mariotti Center Aspro service.
our method to capture and control the full reflectance field of the person in the image. Most editing approaches rely on supervised learning using training data captured with setups such as light and camera stages. Such datasets are expensive to acquire, not readily available and do not capture all the rich variations of in-the-wild portrait images. In addition, most supervised approaches only focus on relighting, and do not allow camera viewpoint editing. Thus, they only capture and control a subset of the reflectance field. Recently, portrait editing has been demonstrated by operating in the generative model space of StyleGAN. While such approaches do not require direct supervision, there is a significant loss of quality when compared to the supervised approaches. In this paper, we present a method which learns from limited supervised training data.
They also do not edit the full portrait image, just the inner face region, missing out important portrait components such as hair and eyes. Recently, several deep learning-based methods have been proposed for appearance editing. These methods use large light-stage datasets which consist of a limited number of people illuminated by different light sources and captured from different camera viewpoints. A neural network is trained on such datasets which enables inference from a single image. Some methods  [Lattas et al. 2020; Yamaguchi et al. 2018]  regress the reflectance of the face from a monocular image in the form of diffuse and specular components. Neural representations for face reflectance fields have also been explored recently  [B R et al. 2020]. While these methods can work with a single image, they still only model the inner face region, missing out on important details such as hair and eyes.
In contrast to the previous methods, several approaches only capture and edit a subset of the reflectance field. These approaches only allow for the editing of either scene illumination or camera pose. Most relighting methods directly learn a mapping from the input image to its relit version using a light-stage training dataset  [Nestmeyer et al. 2020; Sun et al. 2019 Sun et al. , 2020]]. The controlled setting and limited variety of such datasets limits performance while generalising to in-the-wild images. Zhou et al. [2019]  attempted to break out from the complexity of capturing light-stage datasets and from their limited variations. Instead, they proposed to use a synthetic dataset of in-the-wild images, synthesised with different illuminations. Illumination is modeled using spherical harmonics.
Our method combines the best of generative modeling and supervised learning approaches, and creates results of much higher quality compared to previous methods. We learn to transform the StyleGAN latent code of the input image into the latent code of the output. We perform this learning in a supervised manner by leveraging a light-stage dataset, containing multiple identities shot from different viewpoints and under several illumination conditions. Learning in the StyleGAN space allows us to synthesise photorealistic results for general person identities seen under in-the-wild conditions. Our method can handle properties such as shadows and other complex appearance, and can synthesise full portrait images including hair, upper body and background. We inherit the high photorealism and diversity of the StyleGAN portrait manifold in our solution, which allows us to outperform methods that only use light-stage training data  [Sun et al.