Key Points:• To show the connection between X-ray flare class and background level • To show the usefulness of the X-ray background and ratio in flare prediction • To build a framework for an X-ray flare forecast using the GOES satellite Abstract We present the discovery of a relationship between the maximum ratio of the flare flux (namely, 0.5-4 Å to the 1-8 Å flux) and nonflare background (namely, the 1-8 Å background flux), which clearly separates flares into classes by peak flux level. We established this relationship based on an analysis of the Geostationary Operational Environmental Satellites X-ray observations of ∼ 50,000 X, M, C, and flares derived from the NOAA/Space Weather Prediction Center flares catalog. Employing a combination of machine learning techniques (K-nearest neighbors and nearest centroid algorithms) we show a separation of the observed parameters for the different peak flaring energies. This analysis is validated by successfully predicting the flare classes for 100% of the X-class flares, 76% of the M-class flares, 80% of the C-class flares, and 81% of the B-class flares for solar cycle 24, based on the training of the parametric extracts for solar flares in cycles 22-23.