The biophysical drivers that affect coffee quality vary within and among farms. Quantifying their relative importance is crucial for making informed decisions concerning farm management, marketability and profit for coffee farmers. The present study was designed to quantify the relative importance of biophysical variables affecting coffee bean quality within and among coffee farms and to evaluate a near infrared spectroscopy-based model to predict coffee quality. Twelve coffee plants growing under low, intermediate and dense shade were studied in twelve coffee farms across an elevational gradient (1470-2325 m asl) in Ethiopia. We found large within farm variability, demonstrating that conditions varying at the coffee plant-level are of large importance for physical attributes and cupping scores of green coffee beans. Overall, elevation appeared to be the key biophysical variable influencing all the measured coffee bean quality attributes at the farm level while canopy cover appeared to be the most important biophysical variable driving the abovementioned coffee bean quality attributes at the coffee plant level. The biophysical variables driving coffee quality (total preliminary and specialty quality) were the same as those driving variations in the near-infrared spectroscopy data, which supports future use of this technology to assess green bean coffee quality. Most importantly, our findings show that random forest is computationally fast and robust to noise, besides having comparable prediction accuracy. Hence, it is a useful machine learning tool for regression studies and has potential for modeling linear and nonlinear