Because drug‐induced interstitial pneumonia (DIP) is a serious adverse drug reaction, its quantitative risk with individual medications should be taken into due consideration when selecting a medicine. We developed an algorithm to detect DIP using medical record data accumulated in a hospital. Chest computed tomography (CT) is mainly used for the diagnosis of IP, and chest X‐ray reports, KL‐6, and SP‐D values are used to support the diagnosis. The presence of IP in the reports was assessed by a method using natural language‐processing, in which IP was estimated according to the product of the likelihood ratio of characteristic keywords in each report. The sensitivity and the specificity of the method for chest CT reports were 0.92 and 0.97, while those for chest X‐ray reports were 0.83 and 1, respectively. The occurrence of DIP was estimated by the patterns of presence of IP before, during, and after the administration of the target medicine. The occurrence rate of DIP in cases administered Gefitinib; Methotrexate (MTX); Tegafur, Gimeracil, and Oteracil potassium (TS‐1); and Tegafur and Uracil (UTF) was 6.0%, 2.3%, 1.4%, and 0.7%, respectively. The estimated DIP cases were checked by having the medical records independently reviewed by medical doctors. By chart review, the positive predictive values of DIP against Gefitinib, MTX, TS‐1, and UFT were 69.2%, 44.4%, 58.6%, and 77.8%, respectively. Although the cases extracted by this method included some that did not have DIP, this method can estimate the relative risk of DIP between medicines.