Clear Sky Science · en

Towards enhancing the performance of crop prediction system for precision agriculture using feature correlation square-based nearest neighbor classifier

· Back to index

Why smarter crop choices matter

For many farmers, especially smallholders in countries like India, choosing what to plant can feel like a gamble. Weather swings, changing rainfall, and shifting soil conditions all influence whether a crop will thrive or fail. This study explores how data and simple artificial intelligence tools can take some of the guesswork out of that decision, helping farmers match crops to local conditions more reliably and profitably.

Farming guided by data, not guesswork

Modern precision agriculture uses sensors, weather records, and soil tests to keep track of the growing environment in fine detail. Instead of relying only on experience or tradition, farmers can see numbers for soil nutrients, temperature, humidity, and rainfall. However, most current computer systems that turn these measurements into crop recommendations overlook how these factors work together. For example, the best crop may depend not just on how much rain or how much nitrogen there is, but on the particular combination of both. Ignoring those relationships can lead to weaker predictions and missed opportunities for better yields.

Figure 1
Figure 1.

Finding patterns in how field conditions interact

The authors propose a new way to capture how different field conditions move in step with one another. They begin by cleaning and scaling all the measurements in a crop dataset so that no single factor dominates just because it has larger numbers. Then they build what they call a “feature correlation square” – essentially a grid that shows, for every pair of measurements, whether they tend to rise and fall together or move in opposite directions. Strong positive ties in this grid mean two conditions often go hand in hand; negative ties mean they usually pull apart. This map of relationships becomes a compact summary of how a particular set of field conditions behaves.

Letting nearby cases vote on the best crop

Once these relationships are captured, the system uses a simple yet powerful idea: look for past situations that resemble the current one, and copy the crop choice that worked best there. This is done with a method called a nearest neighbor classifier. Each past record in the dataset has both its measured conditions and the crop that was actually grown. For a new farm situation, the system measures how “close” it is to every past case, based on the correlation-informed features, and selects a small group of the most similar ones. These closest neighbors then vote on which crop is most suitable. By carefully tuning how many neighbors are consulted, the authors balance stability against sensitivity to noise in the data.

Figure 2
Figure 2.

Testing on real crop recommendation data

To see how well their method works, the researchers tested it on a public crop recommendation dataset collected in India. The data include seven key features: nitrogen, phosphorus, and potassium needs; temperature; humidity; soil pH; and rainfall. The dataset covers twenty-two different crops, from staples like rice and maize to fruits like mango and papaya, as well as fiber and plantation crops such as cotton and coffee. Because the dataset is perfectly balanced, with the same number of examples for each crop, it provides a fair testbed for comparing different computer models.

Beating established prediction methods

The new approach, called FCSNN, was compared with several widely used machine learning methods, including decision trees, random forests, logistic regression, Naive Bayes, gradient boosting, and a standard nearest neighbor model. Across multiple measures of performance, FCSNN consistently came out ahead. It correctly identified the best crop nearly 98% of the time, and its error rate was the lowest among all methods tested. Interestingly, even the other models improved when they were fed features shaped by the correlation square, underscoring how important it is to respect the interplay between field conditions rather than treating each factor in isolation.

What this means for farmers

For non-specialists, the takeaway is straightforward: by paying attention to how soil and weather factors combine, not just to their individual values, computers can offer much more dependable advice about which crop to grow. The FCSNN system shows that even relatively simple artificial intelligence techniques, when carefully designed, can significantly sharpen crop predictions. In practice, such a tool could be linked to low-cost sensors on farms or regional data services, giving farmers timely, location-specific guidance. While this study uses historical data, future work could plug in live readings from fields, turning complex environmental patterns into clear, practical planting decisions.

Citation: Kindra, K., Bhuvaneswari Amma, N.G. & Nageswari Amma, N.G. Towards enhancing the performance of crop prediction system for precision agriculture using feature correlation square-based nearest neighbor classifier. Sci Rep 16, 8807 (2026). https://doi.org/10.1038/s41598-026-35212-2

Keywords: precision agriculture, crop recommendation, machine learning, soil and weather data, smallholder farming