PyART: Python API Recommendation in Real-Time

API recommendation in real-time is challenging for dynamic languages like Python. Many existing API recommendation techniques are highly effective, but they mainly support static languages. A few Python IDEs provide API recommendation functionalities based on type inference and training on a large c...

Full description

Saved in:
Bibliographic Details
Published inProceedings / International Conference on Software Engineering pp. 1634 - 1645
Main Authors He, Xincheng, Xu, Lei, Zhang, Xiangyu, Hao, Rui, Feng, Yang, Xu, Baowen
Format Conference Proceeding
LanguageEnglish
Published IEEE 01.05.2021
Subjects
Online AccessGet full text
ISBN1665402962
9781665402965
ISSN1558-1225
DOI10.1109/ICSE43902.2021.00145

Cover

Abstract API recommendation in real-time is challenging for dynamic languages like Python. Many existing API recommendation techniques are highly effective, but they mainly support static languages. A few Python IDEs provide API recommendation functionalities based on type inference and training on a large corpus of Python libraries and third-party libraries. As such, they may fail to recommend or make poor recommendations when type information is missing or target APIs are project-specific. In this paper, we propose a novel approach, PyART, to recommend APIs for Python programs in real-time. It features a light-weight analysis to derives so-called optimistic data-flow, which is neither sound nor complete, but simulates the local data-flow information humans can derive. It extracts three kinds of features: data-flow, token similarity, and token co-occurrence, in the context of the program point where a recommendation is solicited. A predictive model is trained on these features using the Random Forest algorithm. Evaluation on 8 popular Python projects demonstrates that PyART can provide effective API recommendations. When historic commits can be leveraged, which is the target scenario of a state-of-the-art tool ARIREC, our average top-1 accuracy is over 50% and average top-10 accuracy over 70%, outperforming APIREC and Intellicode (i.e., the recommendation component in Visual Studio) by 28.48%-39.05% for top-1 accuracy and 24.41%-30.49% for top-10 accuracy. In other applications such as when historic comments are not available and cross-project recommendation, PyART also shows better overall performance. The time to make a recommendation is less than a second on average, satisfying the real-time requirement.
AbstractList API recommendation in real-time is challenging for dynamic languages like Python. Many existing API recommendation techniques are highly effective, but they mainly support static languages. A few Python IDEs provide API recommendation functionalities based on type inference and training on a large corpus of Python libraries and third-party libraries. As such, they may fail to recommend or make poor recommendations when type information is missing or target APIs are project-specific. In this paper, we propose a novel approach, PyART, to recommend APIs for Python programs in real-time. It features a light-weight analysis to derives so-called optimistic data-flow, which is neither sound nor complete, but simulates the local data-flow information humans can derive. It extracts three kinds of features: data-flow, token similarity, and token co-occurrence, in the context of the program point where a recommendation is solicited. A predictive model is trained on these features using the Random Forest algorithm. Evaluation on 8 popular Python projects demonstrates that PyART can provide effective API recommendations. When historic commits can be leveraged, which is the target scenario of a state-of-the-art tool ARIREC, our average top-1 accuracy is over 50% and average top-10 accuracy over 70%, outperforming APIREC and Intellicode (i.e., the recommendation component in Visual Studio) by 28.48%-39.05% for top-1 accuracy and 24.41%-30.49% for top-10 accuracy. In other applications such as when historic comments are not available and cross-project recommendation, PyART also shows better overall performance. The time to make a recommendation is less than a second on average, satisfying the real-time requirement.
Author He, Xincheng
Xu, Lei
Hao, Rui
Xu, Baowen
Feng, Yang
Zhang, Xiangyu
Author_xml – sequence: 1
  givenname: Xincheng
  surname: He
  fullname: He, Xincheng
  email: xinchenghe2016@gmail.com
  organization: Nanjing University, China
– sequence: 2
  givenname: Lei
  surname: Xu
  fullname: Xu, Lei
  email: xlei@nju.edu.cn
  organization: Nanjing University, China
– sequence: 3
  givenname: Xiangyu
  surname: Zhang
  fullname: Zhang, Xiangyu
  email: xyzhang@cs.purdue.edu
  organization: Purdue University, USA
– sequence: 4
  givenname: Rui
  surname: Hao
  fullname: Hao, Rui
  email: rui.hao.gm@gmail.com
  organization: Nanjing University, China
– sequence: 5
  givenname: Yang
  surname: Feng
  fullname: Feng, Yang
  email: fengyang@nju.edu.cn
  organization: Nanjing University, China
– sequence: 6
  givenname: Baowen
  surname: Xu
  fullname: Xu, Baowen
  email: bwxu@nju.edu.cn
  organization: Nanjing University, China
BookMark eNotj9FKwzAUhgNOcJt7Ar3oC6SeJCdp410pcxYGllmvR5KeYmDtZO1N396CXn3w8fHDv2Gr4ToQY88CUiHAvlTl5x6VBZlKkCIFEKjv2EYYoxGkNXLF1kLrnAsp9QPbjWP0gJhZAQbXjNdzcWpek3qevq9DUtRVcqJw7XsaWjfFRcVhMe7Cm9jTI7vv3GWk3T-37Ott35Tv_PhxqMriyJ3M9cR9DpAjkQ9GWLKdFIGUReoy6BS01i9Za4XzIcPgvMkCOukRrDKo8s6pLXv6241EdP65xd7d5rNdDoFG9QtcMkQE
CODEN IEEPAD
ContentType Conference Proceeding
DBID 6IE
6IH
CBEJK
RIE
RIO
DOI 10.1109/ICSE43902.2021.00145
DatabaseName IEEE Electronic Library (IEL) Conference Proceedings
IEEE Proceedings Order Plan (POP) 1998-present by volume
IEEE Xplore All Conference Proceedings
IEEE Electronic Library (IEL)
IEEE Proceedings Order Plans (POP) 1998-present
DatabaseTitleList
Database_xml – sequence: 1
  dbid: RIE
  name: IEEE Xplore digital library
  url: https://proxy.k.utb.cz/login?url=https://ieeexplore.ieee.org/
  sourceTypes: Publisher
DeliveryMethod fulltext_linktorsrc
Discipline Computer Science
EndPage 1645
ExternalDocumentID 9402054
Genre orig-research
GrantInformation_xml – fundername: Nanjing University
  funderid: 10.13039/501100008048
GroupedDBID -~X
.4S
.DC
123
23M
29O
5VS
6IE
6IF
6IH
6IK
6IL
6IM
6IN
8US
AAJGR
AAWTH
ABLEC
ADZIZ
AFFNX
ALMA_UNASSIGNED_HOLDINGS
APO
ARCSS
AVWKF
BEFXN
BFFAM
BGNUA
BKEBE
BPEOZ
CBEJK
CHZPO
EDO
FEDTE
I-F
I07
IEGSK
IJVOP
IPLJI
M43
OCL
RIE
RIL
RIO
RNS
XOL
ID FETCH-LOGICAL-a285t-b80084eebc619e9f21ce394ef70f30d9ba28d91abc74cab67c4a2b40936438fa3
IEDL.DBID RIE
ISBN 1665402962
9781665402965
ISSN 1558-1225
IngestDate Wed Aug 27 02:21:08 EDT 2025
IsPeerReviewed false
IsScholarly true
Language English
LinkModel DirectLink
MergedId FETCHMERGED-LOGICAL-a285t-b80084eebc619e9f21ce394ef70f30d9ba28d91abc74cab67c4a2b40936438fa3
PageCount 12
ParticipantIDs ieee_primary_9402054
PublicationCentury 2000
PublicationDate 2021-May
PublicationDateYYYYMMDD 2021-05-01
PublicationDate_xml – month: 05
  year: 2021
  text: 2021-May
PublicationDecade 2020
PublicationTitle Proceedings / International Conference on Software Engineering
PublicationTitleAbbrev ICSE
PublicationYear 2021
Publisher IEEE
Publisher_xml – name: IEEE
SSID ssib044791064
ssj0006499
Score 2.39553
Snippet API recommendation in real-time is challenging for dynamic languages like Python. Many existing API recommendation techniques are highly effective, but they...
SourceID ieee
SourceType Publisher
StartPage 1634
SubjectTerms API recommendation
context analysis
data flow analysis
Feature extraction
Libraries
Python
real time recommendation
Real-time systems
Training
Visualization
Title PyART: Python API Recommendation in Real-Time
URI https://ieeexplore.ieee.org/document/9402054
hasFullText 1
inHoldings 1
isFullTextHit
isPrint
link http://utb.summon.serialssolutions.com/2.0.0/link/0/eLvHCXMwjV3PT4MwGG22nTxN3Yy_w8Gj3Sj0B_Vmli2biYZEl-y2tKUkRmXGwGH-9X4tMI3x4A0aAhQK3_fa772H0JVUUjCiCFZCAkDJcoIloxHmieaQziaE5b7K94HPl_RuxVYddL3jwlhrffGZHblNv5afbUzlpsrG0oEdRruoKxJec7XasUMpXCt0qX_zF-bUe0dCuASUBIPWkbqc024YSR41Wk_tPms4dSSU48XkcQpB2pO0IuIWKhzT6Yfzig88sz66b2-5rjd5GVWlHpnPX2qO_-3TPhp-U_yCdBe8DlDHFoeo33o8BM0nP0A43ULKexOkWycyENymi8Ah1jc4a-3GFDwX0KJesSOTDNFyNn2azHFjsYBVlLAS68QJ6lurDQApK_OIGBtLanMR5nGYSQ2HZZIobQQ1SnNhqIo0YMIYMpkkV_ER6hWbwh6jQDHhKtcsl15xhmuWQe4g4txksU4EPUED1_v1e62isW46fvp38xnac8-_Li08R73yo7IXEP5Lfenf-xcRkaSI
linkProvider IEEE
linkToHtml http://utb.summon.serialssolutions.com/2.0.0/link/0/eLvHCXMwjV3PT8IwFG4QD3pCBeNvd_DoYN36Y_VmCAQUCImQcCNt1yVGHcaMA_71vnYbGuPB29Ys25q97X3f-r73IXQjpOAUS-xLLoCgJCn2BSWhz2LFAM7GmKauynfCBnPysKCLGrrdamGMMa74zLTtplvLT1Z6bX-VdYQlO5TsoF1KCKGFWquKHkLgaoEF_-V3mBHnHgkJE3gShK2VdVmv3SAULCy7PVX7tFTV4UB0ht2nHqRpJ9MKsV2qsFqnH94rLvX0G2hc3XRRcfLSXueqrT9_9XP876wOUOtb5OdNt-nrENVMdoQalcuDV770TeRPNwB677zpxrYZ8O6nQ89y1jc4a-HH5D1nMCJffSsnaaF5vzfrDvzSZMGXYUxzX8W2pb4xSgOVMiINsTaRICblQRoFiVBwWCKwVJoTLRXjmshQASuMAMvEqYyOUT1bZeYEeZJyW7tmmHA9Z5iiCaAHHqU6iVTMySlq2tkv34s-Gsty4md_D1-jvcFsPFqOhpPHc7Rvn0VRaHiB6vnH2lwCGMjVlYuBL-tIp9U
openUrl ctx_ver=Z39.88-2004&ctx_enc=info%3Aofi%2Fenc%3AUTF-8&rfr_id=info%3Asid%2Fsummon.serialssolutions.com&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=proceeding&rft.title=Proceedings+%2F+International+Conference+on+Software+Engineering&rft.atitle=PyART%3A+Python+API+Recommendation+in+Real-Time&rft.au=He%2C+Xincheng&rft.au=Xu%2C+Lei&rft.au=Zhang%2C+Xiangyu&rft.au=Hao%2C+Rui&rft.date=2021-05-01&rft.pub=IEEE&rft.isbn=9781665402965&rft.issn=1558-1225&rft.spage=1634&rft.epage=1645&rft_id=info:doi/10.1109%2FICSE43902.2021.00145&rft.externalDocID=9402054
thumbnail_l http://covers-cdn.summon.serialssolutions.com/index.aspx?isbn=/lc.gif&issn=1558-1225&client=summon
thumbnail_m http://covers-cdn.summon.serialssolutions.com/index.aspx?isbn=/mc.gif&issn=1558-1225&client=summon
thumbnail_s http://covers-cdn.summon.serialssolutions.com/index.aspx?isbn=/sc.gif&issn=1558-1225&client=summon