Agri-GNN: A Novel Genotypic-Topological Graph Neural Network Framework
  Built on GraphSAGE for Optimized Yield Prediction
Agriculture, as the cornerstone of human civilization, constantly seeks to
integrate technology for enhanced productivity and sustainability. This paper
introduces $\textit{Agri-GNN}$, a novel Genotypic-Topological Graph Neural
Network Framework tailored to capture the intricate spatial and genotypic
interactions of crops, paving the way for optimized predictions of harvest
yields. $\textit{Agri-GNN}$ constructs a Graph $\mathcal{G}$ that considers
farming plots as nodes, and then methodically constructs edges between nodes
based on spatial and genotypic similarity, allowing for the aggregation of node
information through a genotypic-topological filter. Graph Neural Networks
(GNN), by design, consider the relationships between data points, enabling them
to efficiently model the interconnected agricultural ecosystem. By harnessing
the power of GNNs, $\textit{Agri-GNN}$ encapsulates both local and global
information from plants, considering their inherent connections based on
spatial proximity and shared genotypes, allowing stronger predictions to be
made than traditional Machine Learning architectures. $\textit{Agri-GNN}$ is
built from the GraphSAGE architecture, because of its optimal calibration with
large graphs, like those of farming plots and breeding experiments.
$\textit{Agri-GNN}$ experiments, conducted on a comprehensive dataset of
vegetation indices, time, genotype information, and location data, demonstrate
that $\textit{Agri-GNN}$ achieves an $R^2 = .876$ in yield predictions for
farming fields in Iowa. The results show significant improvement over the
baselines and other work in the field. $\textit{Agri-GNN}$ represents a
blueprint for using advanced graph-based neural architectures to predict crop
yield, providing significant improvements over baselines in the field.
Aditya Gupta, Asheesh Singh
Agri-GNN: A Novel Genotypic-Topological Graph Neural Network Framework Built on GraphSAGE for Optimized Yield Prediction

###### Abstract

Agriculture, as the cornerstone of human civilization, constantly seeks to integrate technology for enhanced productivity and sustainability. This paper introduces _Agri-GNN_, a novel Genotypic-Topological Graph Neural Network Framework tailored to capture the intricate spatial and genotypic interactions of crops, paving the way for optimized predictions of harvest yields. _Agri-GNN_ constructs a Graph \(\mathcal{G}\) that considers farming plots as nodes, and then methodically constructs edges between nodes based on spatial and genotypic similarity, allowing for the aggregation of node information through a genotypic-topological filter. Graph Neural Networks (GNN), by design, consider the relationships between data points, enabling them to efficiently model the interconnected agricultural ecosystem. By harnessing the power of GNNs, _Agri-GNN_ encapsulates both local and global information from plants, considering their inherent connections based on spatial proximity and shared genotypes, allowing stronger predictions to be made than traditional Machine Learning architectures. _Agri-GNN_ is built from the GraphSAGE architecture, because of its optimal calibration with large graphs, like those of farming plots and breeding experiments. _Agri-GNN_ experiments, conducted on a comprehensive dataset of vegetation indices, time, genotype information, and location data, demonstrate that _Agri-GNN_ achieves an \(R^{2}=.876\) in yield predictions for farming fields in Iowa. The results show significant improvement over the baselines and other work in the field. _Agri-GNN_ represents a blueprint for using advanced graph-based neural architectures to predict crop yield, providing significant improvements over baselines in the field.

_The ultimate goal of farming is not the growing of the crops, but the cultivation and perfection of human beings. --Masanobu Fukuoka_

**Key Words:** Graph Neural Networks (GNNs), Agricultural Data Integration, Multimodal Data Fusion, Structured Data Modeling, Adaptive and Modular Design, Precision Agriculture Enhancement, Complex Interdependencies Modeling

## 1 Introduction

In an era characterized by escalating climate change, which is resulting in unpredictable weather patterns and increasing environmental stresses, the agricultural sector faces significant challenges (Anwar et al., 2013). Unforseen climatic events such as droughts, floods, and extreme temperatures are impacting crop yields, highlighting the imperative for advanced, precise, and resilient crop yield prediction models (Kuwayama et al., 2019). Amidst this backdrop of climatic uncertainties (Shrestha et al., 2012), the necessity for accurate and comprehensive crop yield predictions is more acute than ever. A robust system that can efficiently integrate diverse data types and provide a detailed and holistic understanding of the agricultural ecosystem is crucial for mitigating the impacts of climate change on agriculture.
The agricultural ecosystem is inherently complex and interconnected, with numerous factors playing a pivotal role in determining crop yields. Traditional Machine Learning models, while powerful, often fall short in effectively capturing these intricate relationships, as they generally treat data points as independent entities (Liu et al., 2020). The limited capacity of these models to handle relational data and their inability to seamlessly integrate diverse data types such as spatial, temporal, and genetic information, hamper their effectiveness in providing comprehensive and accurate crop yield predictions. Moreover, these models tend to be data-hungry, requiring substantial labeled data for training, which is often a significant challenge in the agricultural context (Majumdar et al., 2017). On the contrary, Graph Neural Networks (GNNs) stand out as a more apt choice for this scenario. GNNs, by design, consider the relationships between data points, enabling them to efficiently model the interconnected agricultural ecosystem. They can effectively synthesize diverse data types into a unified framework, offering a more holistic and nuanced understanding of the factors influencing crop yields (Zhou et al., 2020). The ability of GNNs to work with limited labeled data and their flexibility in handling various data modalities make them a superior choice for developing robust and resilient crop yield prediction models in the face of climate change.

In light of this, the present study introduces Agri-GNN, a pioneering approach employing GNNs to offer an inclusive representation of the agricultural ecosystem. _Agri-GNN_ considers farming plots as nodes, and then constructs edges between nodes based on spatial and genotypic similarity, allowing for the aggregation of node information from a refined selection of nodes. This allows for the model to refine the noise that exists in the dataset and focus yield prediction efforts for each node on the most similar nodes in terms of genotypic and spatial similarity. _Agri-GNN_ stands out with its capacity to amalgamate diverse data modalities into a cohesive framework, adeptly capturing the complex interaction among genetic, environmental, and spatial factors (Meng et al., 2018). This innovative model transcends traditional methodologies by conceptualizing the agricultural ecosystem as a connected network, where each crop, viewed as an active node, is influenced by its immediate environment and genetic context.

The employment of the GraphSAGE architecture (Hamilton et al., 2017), significantly bolsters the effectiveness of _Agri-GNN_. GraphSAGE is known for its inductive learning approach, where it leverages node attribute information to generate representations for data not seen during the training process. This approach is particularly beneficial for the extensive and heterogeneous datasets that are commonplace in the field of agriculture. Traditional machine learning models often struggle with such diverse and expansive data, leading to suboptimal predictions and insights. However, the GraphSAGE architecture, with its innovative inductive learning, excels in processing and learning from large datasets, thereby ensuring the robustness of _Agri-GNN_.

In agriculture, datasets encompass a wide range of information including weather conditions, soil types, and genetic information, the ability to effectively handle and learn from such data is crucial for accurate yield predictions. The GraphSAGE architecture equips _Agri-GNN_ with this capability, allowing it to seamlessly integrate and process diverse data types to generate detailed and reliable yield predictions. This level of granular insight is important for making informed decisions in agricultural planning and management, ultimately contributing to enhanced productivity and sustainability.

By using the GraphSAGE architecture, _Agri-GNN_ is not just limited to data seen during training. It can generalize and adapt to new data, ensuring that the model remains relevant and useful as more agricultural data becomes available. This adaptability is essential in the dynamic field of agriculture, where new data and insights continuously emerge. The advanced architecture thereby not only enhances _Agri-GNN_'s predictive accuracy but also bolsters its longevity and relevance in the agricultural sector, making it a valuable tool for tackling the challenges of modern agriculture. _Agri-GNN_'s modular and scalable design ensures its adaptability to the fast-paced evolution of the agricultural sector. This flexibility allows for the effortless integration of emerging data sources and insights, ensuring the model remains relevant and effective in a changing landscape (Gandhi and Armstrong, 2016).

_Agri-GNN_ embodies a transformative shift that is taking place in agricultural modeling, providing a novel perspective that comprehensively addresses the complexity and interconnectedness of farming systems. By offering a nuanced, data-driven lens, _Agri-GNN_ stands as a robust tool for navigating the multi-faceted challenges of modern agriculture, particularly in the context of a changing climate.
Literature Review

Plant breeding specialists are focused on discovering high-quality genetic variations that fulfill the needs of farmers, the wider agricultural sector, and end consumers. One of the key traits often scrutinized is seed yield, particularly in row crops (Singh et al., 2021c). Traditional ways of assessing seed yield involve the laborious and time-restricted activity of machine-harvesting numerous plots when the growing season concludes. This data then informs decisions about which genetic lines to either advance or discontinue in breeding programs. This approach is highly resource-intensive, requiring the harvesting of thousands of test plots each year, thus presenting operational challenges.

In response to these issues, advancements in technology are being harnessed to develop more efficient alternatives. An increasing number of scientists and plant breeders are adopting the use of remote sensing technology, integrated with machine learning methods. This enables more timely predictions of seed yield, substantially cutting down on labor and time requirements during the crucial harvest phase (Li et al., 2022; Yoosefzadeh-Najafabadi et al., 2021; Chiozza et al., 2021; Shook et al., 2021b; Riera et al., 2021; Guo et al., 2021; Singh et al., 2021a).

The newly introduced Cyber-Agricultural System (CAS) takes advantage of cutting-edge continual sensing technology, artificial intelligence, and smart actuators for enhancing both breeding and production in agriculture Sarkar et al. (2023). Integral to CAS is the concept of phenotyping, which employs sophisticated imaging and computational techniques to streamline the gathering and interpretation of data, thereby facilitating better yield forecasts Singh et al. (2021b). Numerous studies have honed in on high-throughput phenotyping through the use of drones, investigating yield predictions in crops such as cotton, maize, soybean, and wheat Herr et al. (2023). Beyond the 2D data collected by drones, research has demonstrated the value of canopy fingerprints, which offer unique insights into the 3D structure of soybean canopies via point cloud data Young et al. (2023). Despite these advances, there is still scope for refining models that amalgamate diverse datasets, including but not limited to soil features and hyperspectral reflectance, for a more holistic grasp of soybean yields. The soil's physical and chemical attributes play a crucial role in nutrient availability, thereby impacting plant health and growth. Incorporating these soil characteristics could potentially enhance the precision of yield prediction models.

In recent years, the application of neural networks in crop yield prediction has moved beyond traditional architectures to more complex models like Convolutional Neural Networks (CNNs) and Recurrent Neural Networks (RNNs) (Dahikar and Rode, 2014; Gandhi et al., 2016).

Much work in the field takes advantage of remote sensing data, such as satellite images or NDVI, for yield predictions (You et al., 2017; Nevavuori et al., 2019; Kim et al., 2019). While these methods have shown promise, they often struggle to capture the direct relationships between environmental factors and crop yields. Previous research has also focused on using environmental factors like temperature and rainfall directly as inputs for yield prediction models (Cakir et al., 2014; Khaki and Wang, 2019), but the same failure to capture direct relationships accurately has been seen.

Against this backdrop, Graph Neural Networks (GNNs) offer a significant advancement by incorporating spatial relationships or neighborhood information into the prediction models. By adding the spatial context through GNNs, recent models provide a more nuanced understanding of how localized factors can impact yield, enhancing prediction accuracy (Fan et al., 2022; Park and Park, 2019; Sajitha et al., 2023). Particularly, Fan et al. (2022) uses a GNN-RNN based approach that shows promising results, but fails to generalize on graphs of large size. The GraphSAGE model (Hamilton et al., 2017) stands out as a notable innovation in leveraging spatial and neighborhood information for more accurate crop yield predictions. The incorporation of GraphSAGE allows us to effectively capture localized contextual information, thereby refining our understanding of how specific factors in localized areas can influence crop yields. This results in an enhanced level of accuracy in our yield predictions.

Graph Neural Networks offer a promising avenue for enhancing the state-of-the-art in crop yield prediction. They facilitate the integration of various types of data and have the potential to significantly improve the accuracy of existing models. Future research should focus on leveraging these capabilities to build models that can generalize well across different conditions and scales.
Background

In this section, we provide background information on Graph Neural Networks and GraphSAGE. We also provide a background on the data features used in the creation of Agri-GNN. This background information is necessary for understanding Agri-GNN.

### Graph Neural Networks

Graphs are a robust and versatile means of capturing relationships among entities, known as nodes, and their interconnections, termed edges. Graph Neural Networks elevate this representational power by extending classical neural network architectures to operate directly on graph-structured data. These networks are particularly effective at generating meaningful node-level or graph-level embeddings, representations that can be subsequently used in various downstream tasks such as node classification, link prediction, and community detection. For an exhaustive review of the techniques and methods employed in GNNs, we direct the reader to seminal survey papers by Battaglia et al. (2018) and Chami et al. (2021).

A GNN can be represented as \(f(A,X;W)\to y\), where \(y\) denotes the set of predicted outcomes (e.g., plot yield predictions), \(A\) is an \(n\times n\) adjacency matrix encapsulating the graph structure, \(X\) is an \(n\times p\) feature matrix detailing node attributes, and \(W\) represents the trainable weight parameters of the network. In this function, \(A\) and \(X\) serve as inputs, and the network \(f\) is parameterized by \(W\).

One of the distinguishing characteristics of GNNs lies in their ability to accumulate and propagate information across nodes (Hamilton et al., 2017). A node's feature vector is updated iteratively based on the feature vectors of its neighboring nodes. The depth or number of layers, \(\ell\), in the GNN controls which neighbors are involved in these updates. Specifically, the final representation of a node only includes information from nodes that are at most \(\ell\)-hop distance away. This scope of nodes and edges involved in the computation of a node's representation is termed its computational graph, formally defined as \(G=(A,V)\). Here, \(A\) is the adjacency matrix for the subgraph, and \(X_{v}\) is the feature matrix for nodes within the \(\ell\)-hop neighborhood of the node \(v\).

### GraphSAGE

GraphSAGE (Graph Sample and Aggregation) is a pioneering extension to general Graph Neural Networks and was specifically designed to address challenges such as scalability and inductive learning on large graphs (Hamilton et al., 2017). Unlike traditional GNN architectures that require the entire graph to be loaded into memory for training, GraphSAGE leverages a sampling strategy to extract localized subgraphs, thereby allowing for mini-batch training on large-scale graphs. The key innovation in GraphSAGE is its novel aggregation mechanism, which uses parameterized functions to aggregate information from a node's neighbors. These functions can be as simple as taking an average or as complex as employing a neural network for the aggregation process.

GraphSAGE is expressed as \(f_{\text{SAGE}}(A,X;W)\to y\), where \(f_{\text{SAGE}}\) represents the GraphSAGE model, \(y\) is the output (such as node embeddings or graph-level predictions), \(A\) is the adjacency matrix, \(X\) is the feature matrix, and \(W\) are the trainable parameters. Like generic GNNs, GraphSAGE accumulates and combines information from a node's neighborhood to update its feature representation. However, GraphSAGE can generalize to unseen nodes during inference by leveraging learned aggregation functions, making it particularly valuable for evolving graphs where the node set can change over time. It has been employed effectively in diverse applications such as social network analysis, recommendation systems, and even in specialized fields like computational biology and agronomy, showcasing its adaptability and efficiency(Xiao et al., 2019).

In formal terms, the \(l\)-th layer of GraphSAGE is defined. The aggregated embedding from neighboring counties, denoted \(\mathbf{a}_{c,t}^{(l)}\), is calculated using the function \(g_{l}\) applied to the embeddings \(\mathbf{z}_{c^{\prime},t}^{(l-1)}\) for all neighboring counties \(c^{\prime}\) of county \(c\), represented as:

\[\mathbf{a}_{c,t}^{(l)}=g_{l}(\{\mathbf{z}_{c^{\prime},t}^{(l-1)},\forall c^{ \prime}\in\mathcal{N}(c)\})\]

Here, \(\mathcal{N}(c)=\{c^{\prime},\forall A_{c,c^{\prime}}=1\}\) denotes the set of neighboring counties for \(c\).
The embedding for the \(l\)-th layer, \(\mathbf{z}^{(l)}_{c,t}\), is then obtained by applying a non-linear function \(\sigma\) to the product of a weight matrix \(\mathbf{W}^{(l)}\) and the concatenation of the last layer's embedding \(\mathbf{z}^{(l-1)}_{c,t}\) and \(\mathbf{a}^{(l)}_{c,t}\):

\[\mathbf{z}^{(l)}_{c,t}=\sigma(\mathbf{W}^{(l)}\cdot(\mathbf{z}^{(l-1)}_{c,t}, \mathbf{a}^{(l)}_{c,t}))\]

Where \(\mathbf{z}^{(0)}_{c,t}=h_{c,t}\) as per a previous equation, and \(l\) belongs to the set \(\{0,1,...,L\}\).

The aggregation function for the \(l\)-th layer, \(g_{l}(\cdot)\), can be a mean, pooling, or graph convolution (GCN) function.

In this process, \(\mathbf{a}^{(l)}_{c,t}\) is first concatenated with \(\mathbf{z}^{(l-1)}_{c,t}\), and then transformed using the weight matrix \(\mathbf{W}^{(l)}\). The non-linear function \(\sigma(\cdot)\) is applied to this product to obtain the final embedding for the \(l\)-th layer.

### Vegetation Indices

Vegetation indices are essential metrics used in the field of remote sensing phenology to quantify vegetation cover, assess plant health, and (in our study) to estimate crop yields. These indices leverage the spectral data gathered by electromagnetic radiation, which measure various wavelengths of light absorbed and reflected by plants. A fundamental understanding of how these wavelengths interact with vegetation is crucial for interpreting these indices. Specifically, the pigments in plant leaves, such as chlorophyll, absorb wavelengths in the visible spectrum, particularly the red light. Conversely, leaves reflect a significant amount of near-infrared (NIR) light, which is not visible to the human eye. The indices used in the construction of Agri-GNN are available in Appendix A.

One of the most commonly used vegetation indices is the Normalized Difference Vegetation Index (NDVI). It is calculated using the formula \(\text{NDVI}=\frac{(NIR-RED)}{(NIR+RED)}\), where \(NIR\) represents the near-infrared reflectance and \(RED\) is the reflectance in the red part of the spectrum. The NDVI value ranges between -1 and 1, with higher values typically indicating healthier vegetation and lower values signifying sparse or stressed vegetation. This index is invaluable for various applications, ranging from environmental monitoring to precision agriculture. For Agri-GNN, vegetation indices like NDVI can serve as informative node attributes in agronomic graphs, enhancing the model's ability to make accurate and meaningful predictions in agricultural settings(Bannari et al., 1995).

## 4 Methods

Our proposed framework, _Agri-GNN_, aims to provide a comprehensive solution to crop yield prediction by leveraging the power of Graph Neural Networks (GNNs). The methods section goes over the various stages involved in the design, construction, and validation of _Agri-GNN_.

### Graph Construction

To effectively utilize GNNs for agricultural prediction, we first represent the agricultural data as a graph \(\mathcal{G}=(\mathcal{V},\mathcal{E})\), where \(\mathcal{V}\) denotes the set of nodes and \(\mathcal{E}\) denotes the set of edges.

#### 4.1.1 Node Representation

Each node \(v_{i}\in\mathcal{V}\) corresponds to a specific plot and is associated with a feature vector \(\mathbf{x}_{i}\). This feature vector encapsulates all given data information:

**Vegetation Indices (r\({}_{i}\))**: The variable \(r_{i}\) is derived from remote sensing imagery and encapsulates various spectral indices, including but not limited to reflectance values, that are crucial for assessing vegetation health and vitality. These spectral indices often make use of different reflectance bands, such as near-infrared and red bands, to capture detailed information about plant life. These indices serve as a valuable source of information, particularly when integrated with other types of data like genotypic and soil information. The computational procedure to obtain \(r_{i}\) often involves sophisticated algorithms that account for
atmospheric corrections and other sources of noise in the imagery. The specific formulas and methodologies used to determine \(r_{i}\) are detailed in Appendix A.

**Genotypic Data (g\({}_{i}\))**: The variable \(g_{i}\) encapsulates the genetic information associated with a specific crop or plant. This genotypic data serves as a foundational element in the realm of Cyber Agricultural Systems. Utilizing advanced imaging techniques like hyperspectral imaging, along with computational methods such as machine learning algorithms, the acquisition and analysis of \(g_{i}\) have been significantly streamlined. These advancements not only ease the process of data collection but also enable more accurate and comprehensive genetic profiling. Such in-depth genotypic information is invaluable for understanding plant characteristics, disease resistance, and yield potential, thereby playing a crucial role in the development of precision agriculture strategies and sustainable farming practices Singh et al. (2021).

**Weather Data (w\({}_{i}\))**: The variable \(w_{i}\) encompasses an array of meteorological factors related to a specific agricultural plot, capturing elements such as temperature, precipitation, humidity, wind speed, and solar radiation. These weather conditions are collected through a variety of methods, including on-site weather stations, remote sensors, and even satellite data. The comprehensive nature of \(w_{i}\) allows it to serve as a vital input for crop health monitoring systems and predictive yield models. For instance, high-resolution temporal data on factors like soil moisture and air temperature can be instrumental in predicting potential stress events for crops, such as drought or frost risks. Furthermore, when integrated with other data types like genotypic and vegetation indices, \(w_{i}\) contributes to creating a multifaceted, dynamic model of the agricultural environment(Mansfield et al. (2005)).

The final node feature vector is a concatenation of these features:

\[\mathbf{x}_{i}=[\mathbf{r}_{i},\mathbf{g}_{i},\mathbf{w}_{i}] \tag{1}\]

#### 4.1.2 Edge Representation in _Agri-GNN_

Edges play an indispensable role in graph-based neural network architectures, encoding vital relationships between nodes. Within the _Agri-GNN_ architecture, the edge set \(\mathcal{E}\) is meticulously constructed to encapsulate the intricate relationships between agricultural plots. This is achieved by harnessing both spatial and genotypic attributes.

There are two edge constructions that are undertaken. \(\mathcal{E}_{\text{spatial}}\) encompasses the edges that are created through spatial proximity. Given the geographical coordinates \(\mathbf{c}(v_{i})\) associated with a node \(v_{i}\), the pairwise distance to another node \(v_{j}\) having coordinates \(\mathbf{c}(v_{j})\) can be defined as:

\[d(v_{i},v_{j})=\|\mathbf{c}(v_{i})-\mathbf{c}(v_{j})\| \tag{2}\]

For every node \(v_{i}\), edges are constructed to nodes that fall within the bottom 3% of all pairwise distances, thereby ensuring that the model captures localized environmental intricacies and dependencies:

\[e_{ij}=\begin{cases}1&\text{if }d(v_{i},v_{j})\in\text{bottom 3\% of distances for }v_{i}\\ 0&\text{otherwise}\end{cases} \tag{3}\]

The second set of edges constructed is represented by \(\mathcal{E}_{\text{genotypic}}\). The genotypic data serves as a repository of the genetic characteristics of agricultural plots, offering a window into inherent traits and susceptibilities. Let \(g(v_{i})\) represent the genotypic data for node \(v_{i}\). An edge is formed between nodes \(v_{i}\) and \(v_{j}\) if their genotypic attributes resonate:

\[e_{ij}=\begin{cases}1&\text{if }g(v_{i})=g(v_{j})\\ 0&\text{otherwise}\end{cases} \tag{4}\]

The culmination of the edge formation process results in the edge set \(\mathcal{E}\), which is a fusion of edges derived from both spatial proximity and genotypic similarity:

\[\mathcal{E}=\mathcal{E}_{\text{spatial}}\cup\mathcal{E}_{\text{genotypic}} \tag{5}\]
By harmonizing spatial and genotypic data, _Agri-GNN_ crafts a robust and nuanced representation of the agricultural milieu, establishing itself as an efficacious tool for diverse applications in the realm of agriculture.

### Graph Neural Network Architecture

For our crop yield prediction task, we introduce the _Agri-GNN_ model, an adaptation of the GraphSAGE (Graph Sample and Aggregation) architecture discussed in section 3. The model operates on graph \(\mathcal{G}\), designed for efficient aggregation and propagation of information across the graph.

_AgriGNN_ has four GraphSAGE convolutional layers to process and refine node features, ensuring an effective representation for downstream tasks. The model architecture is explained in detail in this section.

In the initial layer of the Architecture, whose primary objective is transitioning the input node features to an intermediate representation using hidden channels. The transformation for node \(i\) in this layer is shown by equation (6).

\[\mathbf{h}_{i}^{(1)}=\sigma\left(\mathbf{W}_{\text{init}}\cdot\mathbf{x}_{i}+ \mathbf{b}_{\text{init}}\right) \tag{6}\]

In equation (6), \(\mathbf{x}_{i}\) stands for the initial input features of node \(i\), while \(\mathbf{W}_{\text{init}}\) and \(\mathbf{b}_{\text{init}}\) denote the weight matrix and bias vector of this layer, respectively. The function \(\sigma\) represents the activation function. The Rectified Linear Unit (ReLU) is used.

A salient feature of the _Agri-GNN_ is its intermediary layers, which not only collate features from neighboring nodes but also incorporate skip connections to preserve the essence of the original node's features. The aggregation of features from neighboring nodes in these layers is depicted in equation (7).

\[\mathbf{m}_{i}^{(I)}=\text{AGGREGATE}\left(\left\{\mathbf{h}_{j}^{(I-1)}\, \forall j\in\text{N}(i)\right\}\right) \tag{7}\]

Subsequent to this aggregation, the features undergo a transformation, as expressed in equation (8).

\[\mathbf{h}_{i}^{(I)}=\sigma\left(\mathbf{W}^{(I)}\cdot\text{CONCAT}(\mathbf{h} _{i}^{(I-1)},\mathbf{m}_{i}^{(I)})+\mathbf{b}^{(I)}\right) \tag{8}\]

Here, \(\text{N}(i)\) represents the neighboring nodes of node \(i\), and \(\mathbf{W}^{(I)}\) and \(\mathbf{b}^{(I)}\) signify the weight matrix and bias vector for layer \(I\), respectively.

The architecture culminates in the final layer, a pivotal component that produces the model's refined output. This layer mirrors the operations of the intermediary layers in aggregating neighboring node features, but distinguishes itself by excluding the addition of original node features. The aggregation of features in this layer is portrayed in equation (9).

\[\mathbf{m}_{i}^{(4)}=\text{AGGREGATE}\left(\left\{\mathbf{h}_{j}^{(3)}\, \forall j\in\text{N}(i)\right\}\right) \tag{9}\]

The subsequent transformation, harnessing the aggregated features to yield the final output, is described in equation (10).

\[\mathbf{h}_{i}^{(4)}=\sigma\left(\mathbf{W}^{(4)}\cdot\text{CONCAT}(\mathbf{h} _{i}^{(3)},\mathbf{m}_{i}^{(4)})+\mathbf{b}^{(4)}\right) \tag{10}\]

To ensure stability in convergence and enhance generalization, each hidden layer is succeeded by a batch normalization step. After normalization, dropout regularization with a rate of \(p=0.5\) is employed to combat overfitting, as described by equation (11):

\[\mathbf{h}_{i}^{(I)}=\text{Dropout}(\mathbf{h}_{i}^{(I)},p=0.5) \tag{11}\]

The final output of the model is a prediction of the yield of the given node(s).

The final _Agri-GNN_ model is designed to take in initial node features \(\mathbf{x}_{i}\) and produce an output \(\mathbf{o}_{i}\) for each node, representing the predicted yield. The model is summarized as:

\[\mathbf{o}_{i}=\text{{Agri-GNN}}(\mathbf{x}_{i};\mathcal{G},\Theta) \tag{12}\]

Here, \(\Theta\) stands for the set of all learnable parameters within the model.
The model's performance is evaluated using a Mean Squared Error (MSE) loss between the predicted crop yields \(\mathbf{o}_{i}\) and the actual yields. Optimization is carried out via the Adam optimizer, and hyperparameters such as learning rates are fine-tuned for optimal performance.

_Agri-GNN_'s architecture is summarized in Figure 1.

## 5 Applications and Experimental Results

The _Agri-GNN_ framework is now applied to plot fields in Ames, Iowa. _Agri-GNN_'s performance is compared to various baseline yield prediction models to accurately gauge its potential.

### Data Collection and Processing

Data on soil attributes, hyperspectral reflectance, seed yield, and weather were collected systematically over two consecutive years, 2020 and 2021. The data collection covered both Preliminary Yield Trials (PYT) and Advanced Yield Trials (AYT), and each year involved multiple trial locations.

#### 5.1.1 Trial Design

The Preliminary Yield Trials (PYT) were designed using a row-column configuration. In this layout, each plot had a width of 1.52m and a length of 2.13m. Plots within each row were interspaced by 0.91m. The Advanced Yield Trials (AYT) followed a similar row-column design, but with each plot measuring 1.52m in width and 5.18m in length. The interspacing between plots remained consistent at 0.91m for both trial types.

#### 5.1.2 Soil Data Collection

Digital soil mapping techniques were used to identify ten specific soil attributes, supplementing the collection of hyperspectral data. Soil cores were extracted down to a depth of 15 cm following a 25m grid sampling pattern, using specialized soil probes. Digital soil maps were then generated with 3mx3m pixel resolution using the Cubist regression machine learning algorithmKhaledian and Miller (2020).

For each plot, boundaries were outlined using polygon shape files, and the average value of each soil feature was calculated. To improve data reliability, a 3x3 moving mean was computed for each soil attribute within the plot, and this smoothed value was then used for more detailed analyses. The assessed soil features encompassed Calcium (Ca), Cation Exchange Capacity (CEC), Potassium (K), Magnesium (Mg), Organic Matter (OM), Phosphorus (P1), Percent Hydrogen (Ph), and proportions of Clay, Sand, and Silt.

Figure 1: Summary of Model Architecture
#### 5.1.3 Hyperspectral Reflectance Data

Hyperspectral reflectance data for each plot was captured using a Thorlabs CCS200 spectrometer, based in Newton, NJ. The methodology adheres to the system outlined in the study by Bai et al. (2016). Spectral data was collected annually at three distinct time points: T1, T2, and T3, captured sequentially, covering wavelengths from 200 nm to 1000 nm, as illustrated in Figure 2.

Particular emphasis is placed on the T3 timepoint, which has been identified as having superior feature importance values according to preliminary data assessments. As vegetation nears physiological maturity, the correlation between hyperspectral reflectance data and crop yield becomes more significant.

Fifty-two vegetation indices were calculated based on the collected hyperspectral reflectance values, following the methodology detailed in the study by Li et al. (2022). A comprehensive list of these indices is available in Appendix A. The distribution of the collected data across the four fields is summarized in Table 1.

It is interesting to note that many of the vegetation indices show a strong correlation with each other, especially when considering their underlying mathematical formulations. As depicted in Figure 3, certain pairs of indices exhibit notably high correlation values, suggesting that they might be capturing similar information about the vegetation. This redundancy could be attributed to the fact that many vegetation indices are derived from the same spectral bands, primarily the red and near-infrared (NIR) regions, which are known to be indicative of plant health and vigor. However, while two indices might be highly correlated, they might still provide unique insights to different vegetation properties, and thus, all of the vegetation indices were kept as features in the construction of the dataset.

\begin{table}
\begin{tabular}{c c} \hline \hline Field No. & Number of observations \\ \hline \hline
1 & 770 \\
2 & 912 \\
3 & 800 \\
4 & 679 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Number of datapoints in each of the four fields.

Figure 2: Reflectance plot showcasing wavelengths from 400 nm to 1000 nm. The depicted red, green, and blue bands are illustrative of the visible spectrum wavelengths.
#### 5.1.4 Yield Data

Seed yield data at the plot level was collected using an Almaco small plot combine, headquartered in Nevada, IA. For consistency, all yield data was normalized to a moisture content of 13% and then converted to kilograms per hectare (Kg/ha). The data collection process was organized in blocks, mirroring the layout established by the breeding program. This arrangement grouped the plots based on their genetic lineage and corresponding maturity groups.

Prior to the computation of vegetation indices, a rigorous data preprocessing phase was undertaken to omit anomalies and outliers. The steps encapsulated:

1. Omission of all observations for band values falling below 400 nm due to detected anomalies in these bands' readings.
2. Exclusion of datapoints with negative hyperspectral values within the 400 nm to 1000 nm band range.
3. Removal of datapoints showcasing negative seed yield values.

### Graph Construction

Once the dataset was pruned to retain only the relevant columns, we started the task of graph construction, as explained in detail in Section 4.1. The nodes of the graph represented individual data points from the dataset, while the edges encoded two primary relationships: spatial proximity and genotype similarity.

The geospatial coordinates ('Latitude' and 'Longitude') of each data point facilitated the computation of pairwise distances between them. By harnessing this distance matrix, we established a threshold--specifically the 3rd percentile of non-zero distances--and used it as a criterion to draw edges between nodes. In essence, if the spatial distance between two nodes was less than this threshold, an edge was drawn between them.

Beyond spatial relationships, our graph also recognized the significance of genetic similarities between data points. This was achieved by drawing edges between nodes that shared the same genotype, as denoted by the 'Population' column. By adopting this strategy, our graph was enriched with edges that encapsulated intrinsic genetic relationships, which has an influence on agricultural yield (Shook et al., 2021a)

Figure 3: Correlation of selected vegetation indices is shown.
To facilitate subsequent graph-based deep learning, we represented our graph using the _PyTorch Geometric_ framework. This involved a series of transformations. Firstly, the combined spatial and genotype edges were aggregated. Secondly, the dataset was processed to handle missing values, by imputing them with column-wise means, and categorical columns were one-hot encoded. The final graph representation incorporated node features (derived from the processed dataset), the aggregated edges, and the target label ('Yield').

The resulting graph, thus constructed, served as the foundation for our _Agri-GNN_ experiments.

### Neural Architecture

The model was developed using the _PyTorch_ framework (Paszke et al., 2017). For the specific needs of graph-based neural networks, we turned to the _PyTorch Geometric (PyG)_ library (Fey and Lenssen (2019)). This library is a comprehensive toolkit, providing a range of architectures and tools tailored for graph neural networks.

Our model, _Agri-GNN_, is an augmentation of the conventional GraphSAGE architecture Hamilton et al. (2017). It features four GraphSAGE convolutional layers. The initial layer transitions input features to hidden channels. The two intermediary layers, enhanced with skip connections, amplify the model's capacity to discern both rudimentary and advanced patterns in the data. The final layer is designed to yield the model's output. To ensure the stability and efficiency of training, batch normalization is applied following each convolutional layer. Furthermore, to mitigate the risk of overfitting, dropout regularization is integrated after each batch normalization, with a rate of 0.5.

The dimensionality of the input features was determined dynamically based on the dataset. The model was trained for 500 epochs, and was monitored to gauge the model's performance accurately and take measures against potential overfitting.

An \(80-20\) split was utilized, where 80% of the farm nodes were randomly chosen to be part of the training dataset,

### Hyperparameter Tuning

Hyperparameter tuning was critical to ensuring we have the optimal model. We conducted an exhaustive exploration of various hyperparameter combinations to pinpoint the most conducive setting for our model. The hyperparameters that we varied are summarized in Table 2.

The best hyperparameters can be seen in Table 3.

## 6 Model Performance and Results

We now show the results of _Agri-GNN_ on the described dataset. The results are compared with two baselines on the same dataset: a K-Nearest Neighbors Model and an Ensemble Machine Learning model (Chat

\begin{table}
\begin{tabular}{|c|c|} \hline
**Hyperparameter** & **Values Explored** \\ \hline Learning Rates & \(0.001,0.005,0.01,0.02\) \\ \hline Hidden Channels & \(32,64,128\) \\ \hline Dropout Rates & \(0.3,0.5,0.7\) \\ \hline \end{tabular}
\end{table}
Table 2: Hyperparameters and their explored values

\begin{table}
\begin{tabular}{|c|c|} \hline
**Hyperparameter** & **Best Value** \\ \hline Learning Rate & \(0.02\) \\ \hline Hidden Channels & \(32\) \\ \hline Dropout Rate & \(0.3\) \\ \hline \end{tabular}
\end{table}
Table 3: Optimal hyperparameters after tuning
topadhyay et al., 2023).

We first visualize the embeddings derived from our graph neural network model. To better understand the spatial distribution of these embeddings, we employed the t-Distributed Stochastic Neighbor Embedding (t-SNE) algorithm for dimensionality reduction (Hinton and Roweis (2002)). The embeddings, initially generated by the forward method of our model, were reduced to two dimensions using t-SNE. As shown in Figure 4, each point represents a node in the graph, and the spatial arrangement captures the similarity between node embeddings. Distinct clusters and patterns in the visualization indicate nodes with similar features within the graph. The embeddings can be seen in Figure 4.

From Figure 4, we see that multiple distinct graphs may possibly be formed from the data, particularly when subsets of the data are not related in any spatial or genotypic way. _Agri-GNN_ is designed to be able to learn the inherent patterns in each of these subgraphs, while further increasing the accuracy of the main base model.

The performance of _Agri-GNN_ was assessed using standard regression metrics, as presented in table 4:

_Agri-GNN_ achieves a Root Mean Squared Error (RMSE) of 4.565 on this dataset. The Mean Absolute Error (MAE) is 3.590. The model has an \(R^{2}\) value of 0.876. These results show significant improvement over the baselines used.

The K-Nearest Neighbor (K-NN) Algorithm is used as the first baseline model. The K-NN model predicts the yield of a node based on the average yield of its \(k\) nearest neighbors based on latitude and longitude. This model is optimized by performing a grid search to find the best value of \(k\) from a range of 1 to 20. The optimized K-NN model used \(k=18\) as the number of neighbors for making predictions.

\begin{table}
\begin{tabular}{|c|c|} \hline
**Metric** & _Agri-GNN_ **Value** \\ \hline Root Mean Squared Error (RMSE) & 4.565 \\ \hline Mean Absolute Error (MAE) & 3.590 \\ \hline Coefficient of Determination (\(R^{2}\)) & 0.876 \\ \hline \end{tabular}
\end{table}
Table 4: Performance metrics of the _Agri-GNN_ model

Figure 4: t-SNE visualization of graph node embeddings.
The performance metrics of the optimized K-NN model are presented in Table 5. The model achieved a Root Mean Squared Error (RMSE) of 12.93, a Mean Absolute Error (MAE) of 10.33, and a Coefficient of Determination (\(R^{2}\)) of 0.026. The _Agri-GNN_ model shows superior performance to the baseline. The metrics signify a substantial enhancement over the baseline K-NN model, demonstrating the effectiveness of _Agri-GNN_ in yield prediction.

_Agri-GNN_'s prediction error and \(R^{2}\) shows significant potential when compared to recent work on a similar dataset (Chattopadhyay et al., 2023), where the highest \(R^{2}\) value achieved was less than.8. Such an enhancement underscores the potential benefits of graph-based neural networks, especially when handling datasets with inherent relational structures.

In Figure 5, we present a comparison between the Actual and Predicted Yields. This graphical representation provides a comprehensive insight into the accuracy and precision of our model's predictions. An interesting observation from Figure 5 is the remarkable accuracy of the model's predictions for yields ranging between 50 and 90. The data points in this range cluster closely around the line of perfect agreement, suggesting that the model is particularly adept at predicting yields within this interval. This is noteworthy as it indicates that our model is not only reliable in general but also exhibits enhanced performance when predicting yields in this specific range.

Figure 5: The Actual vs. Predicted Yield of our predictions. The red line signifies a perfect model. The model achieves an \(R^{2}\) value of 0.876

\begin{table}
\begin{tabular}{|c|c|} \hline
**Metric** & _Baseline K-NN Value_ \\ \hline Root Mean Squared Error (RMSE) & 12.93 \\ \hline Mean Absolute Error (MAE) & 10.33 \\ \hline Coefficient of Determination (\(R^{2}\)) & 0.026 \\ \hline \end{tabular}
\end{table}
Table 5: Performance metrics of K-NN baseline model (\(k=18\)
### Scalability and Robustness

In the previous section, an application of _Agri-GNN_ is outlined, focusing on agricultural yield prediction in farms located in Ames, Iowa. The results demonstrate the model's capability to efficiently and accurately predict yields based on geographical coordinates. This section delves into the scalability and robustness of the _Agri-GNN_ framework, discussing its potential application on a broader scale, both nationally and internationally.

_Agri-GNN_ is designed with scalability in mind, allowing for seamless integration and deployment in diverse farming contexts across the world. The model's adaptability to various geographical and environmental conditions ensures consistent and reliable yield predictions irrespective of the location. The use of cloud computing resources and distributed computing frameworks enhances the scalability of _Agri-GNN_, enabling real-time processing and analysis of large datasets encompassing numerous farms across different geographical locations.

Robustness is at the core of the _Agri-GNN_ framework. The model employs advanced machine learning algorithms and techniques to ensure stability and reliability in yield predictions, even in the face of data variability and uncertainties. The robust nature of _Agri-GNN_ ensures uninterrupted and consistent performance, bolstering the confidence of farmers and stakeholders in the accuracy and reliability of the yield predictions provided by the model. Moreover, the continuous learning and adaptation capabilities of _Agri-GNN_ further enhance its robustness, ensuring it remains at the forefront of agricultural yield prediction technology. Unfortunately, _Agri-GNN_ is optimized to work best with large datasets where ample information from previous experiments is available. In many farming contexts, there is not enough information to be able to train \(Agri-GNN\) to have reliable performance (Wiseman et al., 2019). Further research should explore how _Agri-GNN_ can be optimized to perform well in instances where a lack of ample farming data may be a problem.

## 7 Conclusion

In an ever-evolving agricultural landscape marked by climatic uncertainties, the pressing need for accurate and holistic crop yield predictions has never been greater. This study introduced Agri-GNN, a pioneering approach that harnesses the power of Graph Neural Networks to provide a comprehensive representation of the agricultural ecosystem. Unlike traditional models that often operate in silos, Agri-GNN's strength lies in its ability to synthesize diverse data modalities into a unified framework, capturing the intricate interplay between genetic, environmental, and spatial factors.

Agri-GNN transcends conventional methodologies by viewing the agricultural ecosystem as an interconnected network, where crops aren't just passive entities but active nodes influenced by their immediate surroundings and broader contexts. This perspective, combined with GNN's superior data processing capabilities, enables Agri-GNN to deliver predictions that are both granular and holistic.

Furthermore, Agri-GNN's modular design ensures its relevance in a rapidly changing agricultural sector, allowing for seamless integration of new data sources and insights. Its precision agriculture approach not only aids in enhancing productivity but also paves the way for sustainable practices that respect both economic and environmental considerations.

Our applications of the Agri-GNN framework's capabilities to the plot fields of Ames, Iowa show promising results, even obtaining better performance than the results obtained in Chattopadhyay et al. (2023). Agri-GNN's performance metrics, including \(RMSE\), \(MAE\), and \(R^{2}\) highlighted its proficiency in yield prediction. Notably, the model showcased significant improvements over existing models, reaffirming the potential of graph-based neural networks in agricultural applications. The t-SNE visualizations further provided insights into the model's embeddings, reinforcing the cohesive and interconnected nature of the data.

In summary, Agri-GNN represents a paradigm shift in agricultural modeling. By capturing the complexity and interconnectedness of farming systems, it offers a fresh lens through which to view and address the multifaceted challenges of modern agriculture. As we stand at the crossroads of traditional practices and technological innovation, Agri-GNN serves as a beacon, guiding the way towards informed, sustainable, and resilient agricultural futures.
Acknowledgments

The authors thank Joseif Raigne, Dr. Baskar Ganapathysubramanian, and Dr. Soumik Sarkar for their invaluable feedback on the draft manuscript.

The authors thank Joseif Raigne for his help in the construction of spatial data for the field experiments.

The authors thank Shannon Denna and Christopher Grattoni for their support.

The authors thank staff and student members of SinghSoybean group at Iowa State University, particularly Brian Scott, Will Doepke, Jennifer Hicks, Ryan Dunn, and Sam Blair for their assistance with field experiments and phenotyping.

This work was supported by the Iowa Soybean Association, North Central Soybean Research Program, USDA CRIS project IOW04714, AI Institute for Resilient Agriculture (USDA-NIFA #2021-647021-35329), COALESCE: COntext Aware LEarning for Sustainable CyBr-Agricultural Systems (CPS Frontier #1954556), Smart Integrated Farm Network for Rural Agricultural Communities (SIRAC) (NSF S & CC #1952045), RF Baker Center for Plant Breeding, and Plant Sciences Institute.

## 9 Author Contributions

Aditya Gupta conceptualized and designed the proposed model, developed the methodology, conducted the data analysis, constructed and implemented the Agri-GNN, provided visualization of the results, and took primary responsibility for writing, revising, and finalizing this paper. All authors have read, reviewed, and agreed to the published version of the manuscript.

## 10 Conflict of Interest

The authors declare no conflict of interest.
