Application of Coding and AI in Mining and Exploration Geology1
Application of Coding and AI in Mining and Exploration Geology1
The purpose of this report is to look at a few of the ways in which Python has been used to
interrogate data in both mining and exploration and related mining functions. These are data use
manipulations that I have personally put into practice in the course of my work. The codes are re-
usable, needing to be written as a once-off. The rest of the time the codes are just called and will run
the new data.
REPORT OUTLINE
The report looks at several Python codes as they have been used in interrogating data from various
sources for various reports. No detail has been given on the dependencies and libraries that were
employed. Some of the data used is dummy data while some has been altered and reconfigured to
protect the confidentiality of data sources. Some data has been used with consent of the owners.
The scope of the code itself is beyond the scope of this report. The report looks at the applications of
Python codes in:
i. Data capture
ii. Importing and reading data
iii. Data manipulation and cleaning
iv. Statistical analyses
v. Scatter plot
vi. Mining reconciliation
vii. Mine to Mill Reconciliation
viii. Ore feed vs Production analysis
ix. Model validation
x. Resource reporting
CONCLUSIONS
There is no limit to the value that correctly captured and handled data gives to humanity. Humanity
needs to be wary of increasing availability of data and data sources, and have tools available to be
able to handle and decipher this data. In the mining and exploration space, more informed decisions
can be made with such data. The value of projects can be correctly ascertained, saving the industry a
lot of money and time. The future of the industry hinges on the ability to transform itself and
embrace Artificial Intelligence as the current trend rather than something for the future.
1. Data Capture
Correct capture of data is crucial in any data-based function. One of the best ways of
ensuring correct data capture is to provide a data capture platform. The following code has
been designed to do just that. The code has in-built error control functions. Pop-up error
messages can be built in the code. Data that is dependant on other data can also be dealt
with. Some data capture fields can be disabled to eliminate the chances of double capture.
Lengths of characters, start and end dates, invalid characters can also be controlled through
the code. Data captured this way has fewer errors and may not require a lot of time to clean.
The code is designed to automatically save the captured data as a .csv file ready to be imported into
a PANDAS DATAFRAME. Widgets like dropdowns, buttons, pop-up calendars can be used.
The .csv or excel file is imported into a Pandas Dataframe and stored as a variable. It is at this point
that only the data that is required to perform a function is imported. This saves on memory and
speeds up data manipulation. Only selected columns and rows can be called into a Dataframe.
The Dataframe provides limitless options for data manipulation. Data view styles can be changed and
data slicing can be done. Pandas provides wide-ranging techniques for data manipulation. Rows and
columns can be added or removed. Mathematical operations can be performed on rows and
columns using yet another of the Python dependencies, Numpy. Relationships between columns or
rows in a dataset can be explored.
3. Data Manipulation
Pandas also provides a functionality for statistical description of all numerical data in the Dataframe.
The data from the Dataframe above can be described by calling the “describe” method as below:
4. Data Cleaning
In a production or exploration environment, it is critical that data be checked for outliers. Plotting
boxplots shows the data distribution in quartiles. The plotting is done using the Plotly library. This
function is demonstrated in the section below:
The result is an interactive dashboard in which the boxplots can be displayed for a particular value
set or a particular area in the case of multiple sources of data. The advantage of a Plotly plot is the
interactivity function in the resultant plots. It allows the user to view data as they wish, and be able
to choose only the part of data that they wish to report on.
In the event of outliers, these can be dealt with in the Pandas Dataframe in several ways. The data
can be excluded in statistical evaluations or it can be capped.
It is also possible with a few lines of code to separate data from a large dataset and create specific
data types for specific functions. A case in point is when exploration data for several areas is stored in
one database. It may be necessary to separate the data according to areas and create the requisite
.csv files for geological database creation. The code below highlights how this is possible:
Using the above code, I was able to create the collar, survey and assay files for ten separate areas
from a large combined database.
5. Univariate analysis
As part of EDA, it is crucial to understand the dataset that one is dealing with. I have plotted
histograms for exploration data. Unlimited numbers of histograms can be drawn with a few lines of
code. In the example below, I produced a dashboard where histograms for twenty-eight assayed
parameters could be displayed for ten separate areas. The area and parameter to display are chosen
from a dropdown list. The histograms are combined with the boxplots for outlier analyses.
The resultant dashboard is shown below. The great thing about it is the interactivity. The user gets to
choose what they want to view. With this code, it is possible to make geological inferences like
multiple populations and domain from an exploration dataset. In the code below, histograms for all
assayed populations in an exploration program that was conducted in ten separate areas are
displayed. The user can use the dropdown buttons to display what data to view, and for which area.
6. Bivariate analysis
There is sometime a need to compare values, for example results for the same samples from
different labs, duplicates or a repeat of an exercise. One needs to look at the correlation between the
results in order to certify the results as acceptable. A scatter plot would be best to show such
correlation. It is also critical to look at relationships in a multi-element deposit, such as gold and
copper. This relationship is important in determining the expected behaviour of one element with
changing values of the other. I have used it in exploration. I have written a code for that as well:
7. Mining Reconciliation
My most interesting code is the one that deals with mining reconciliation. This code addresses one of
the most challenging issues in the production environment. In the reconciliation code I address the
relationships between the various models in the mining value chain. The way the code is structured
gives a seamless possibilities and permutations. The interactive nature of the reconciliation
dashboard also makes it possible to view the reconciliation parameters for different mining areas on
the same graph.
Intermediate factors can also be generated to incorporate other models such as Grade Control
Model. Dropdown widgets make this process effortless.
The resultant dashboard is shown below. The reader has unlimited permutations of the parameters
they can view, and for the area they choose. Dropdown widgets make it possible to select the model
to use as the numerator, and the one for the denominator. Updated reports can be generated at any
time in the reporting cycle. It just takes running the code, which in turn imports the latest version of
the .csv file for processing.
A time slider can be added to make it possible to zoom in to a specific period of interest. One big
advantage of this code is that it moves the reconciliation from an F-Factor to an R-Factor
reconciliation. It becomes possible to use the resource model as the reference, where every other
model is referenced to the resource model. It becomes clearer to track modifying factors along the
chain.
I have also introduced Spatial Reconciliation to the reconciliation matrix. Spatial reconciliation looks
at the differences in spatial distribution of ore and waste different models. One model is
superimposed on another and ore can be classified into three categories:
i. Equivalent ore. This is ore that occurs in the same place in both models.
ii. Excluded ore. This is ore that occurs in the earlier model but is not present in the
later model.
iii. Additional ore. This is ore that is present in the later model but had not been picked
in the earlier model.
The comparisons in the above classes of ore says a lot about the model conversion and can
be used to target areas where resources need to be channelled to improve the models.
It is crucial to be able to track the movement of material from the resource model to final product
through a material tracking system. Any change in value from model to model can be graphically
shown, making it possible to track ore loss and any significant changes in value along the mining
value chain. Below is the code for the tracking system:
9. Ore feed split/ Production vs Feed analysis
I designed the code below to analyse the impact of ore feed split on production. I split the ore fed
into a plant by source pit, by weathering zone and by grade. If data is available, a split can also be
done based on classification of material being fed into the plant. The idea is to use graphical
visualization to pick out any trends that may point out to problem areas and remedy. The approach is
to do stacked graphs and superimpose production on the same graph. Below is the code for that:
10. Model validation
I wrote a code that can be used as a simple model validation tool, useful as a field tool say after a
grade control exercise. The code basically uses the X-Y coordinates to geographically place data
values. Instead of the Z value, assay values are used. The result is a choropleth map that can be
printed and used by spotters as a check mechanism during ore mark-ups and ore spotting exercises. I
am still looking at ways to improve on this code.
11. Resource Reporting
I have another code for Resource/ Reserve reporting. A few lines of code will produce a waterfall
graph to track the adjustment done to the Resource report. The code tracks resource related
adjustments throughout the year.