Skip to content

Commit

Permalink
added full codebase - links with gitlab release 1.0.0-external
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris35Wills committed Feb 15, 2024
1 parent f3cc036 commit 572767c
Show file tree
Hide file tree
Showing 17 changed files with 33,772 additions and 0 deletions.
165 changes: 165 additions & 0 deletions License.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.


This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.

0. Additional Definitions.

As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.

"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.

An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.

A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".

The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.

The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.

1. Exception to Section 3 of the GNU GPL.

You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.

2. Conveying Modified Versions.

If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:

a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or

b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.

3. Object Code Incorporating Material from Library Header Files.

The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:

a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.

b) Accompany the object code with a copy of the GNU GPL and this license
document.

4. Combined Works.

You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:

a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.

b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.

c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.

d) Do one of the following:

0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.

1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.

e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)

5. Combined Libraries.

You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:

a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.

b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.

6. Revised Versions of the GNU Lesser General Public License.

The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.

Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.

If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
98 changes: 98 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# geospatial-random-forest

> The `geospatial-rf` library provides a series of functions and wrappers to assist with random forest applications in a spatial context
> It was developed to assist in the classification of exposed rock features from multi-variate datasets, but has wider applications
> A full methodology for the code is being published and is currently under review
- Williams et al., 2023.
> The underlying codebase is being made publically available to support others undertaking or experimenting with simialr approaches
* **Name**: `geospatial-rf`
* **Source**: [geospatial-rf](https://kwvmxgit.ad.nerc.ac.uk/data-science/geospatial-random-forest/-/tree/method-paper-RELEASE)

## Overview

`geospatial-rf` is a python library that consists of functions that assist in the preparation of data and implementation of the random forest classifier in a geospatial context. It may be used to train, test and visualise the results of a Random Forest model. H2O is the underpinning modelling library that is used for model training. This impleemntation was initially designed to enable feature classification of rock presence/absence based on terrain derivatives.

To assist users of this library, a worked example implementation is provided that demonstrates how rock/presence absence can be predicted using geospatial (x,y) terrain derivative information, considering a training dataset that also denotes rock presence and absence. In addition to the example provided, scripts are provided for the full data pipeline from data processing to results visualisation. Note that due to the varying nature of geospatial datasets and the possible applications of this repository, some modification is required to run these scripts for differen applciations.

This code is provided to supplement the publication on the development and use of this code for the purposes of predicting geological rock exposure - please refer to Williams et al., 2023 :zap: hyperlink to be added to submission/publication :zap:

## License info

[LGPL-3.0 license](./license.md)

---

# Installation guidance

## Building your environment (Windows)

This installation uses Anaconda and installs some additional packages as used in the [example](./examples) workflows:

1. Install [Anaconda ](https://www.anaconda.com/)
2. Create an Anaconda environment - example as follows entered through the Anaconda prompt:

```shell
conda create -n py38_rf-classifier_windows_2 python=3.8
conda activate py38_rf-classifier_windows_2
conda install pandas numpy
conda install -c anaconda scikit-learn
conda install -c anaconda scikit-image
conda install seaborn
conda install ipython
conda install jupyter
conda install xarray
```

A [env.yml](env.yml) file has also been provided to support environment building directly:

```
conda env create -f env.yml
conda activate py38_rf-classifier_windows
```

3. Install h2o - the version is important as any models trained with a specific version of h2o, can only be read by the same version of h2o (see info below) - here we'll install v3.38.0.2 specifically:

```bash
pip uninstall h2o
pip install http://h2o-release.s3.amazonaws.com/h2o/rel-zygmund/2/Python/h2o-3.38.0.2-py2.py3-none-any.whl
```

Note that h2o has some specific pre-requistie requirements of it's own that are detailed [here](https://docs.h2o.ai/h2o/latest-stable/h2o-docs/welcome.html#requirements)

4. In addition to the above, you must also have Java locally available - details of the Java version used for development are as follows:

```
java version "1.8.0_361"
Java(TM) SE Runtime Environment (build 1.8.0_361-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.361-b09, mixed mode)
```

Some info below quoted from the H2O installation page on Java requirements - see [here](https://docs.h2o.ai/h2o/latest-stable/h2o-docs/welcome.html#java-requirements):

> H2O runs on Java. To build H2O or run H2O tests, the 64-bit JDK is required. To run the H2O binary using either the command line, R, or Python packages, only 64-bit JRE is required.
> H2O supports the following versions of Java:
>
> Java SE 17, 16, 15, 14, 13, 12, 11, 10, 9, 8
>
> Click [here](https://jdk.java.net/archive/) to download the latest supported version.
## Getting version-specific h2o installed

With h2o, models trained with a specific version can only be read by h2o implementations of the same version i.e. if you trained your model with v3.38.02, you can only read it into h2o, that is also v3.38.02.

Installing h2o directly from the h2o webpage will give you the most recent version of h2o. Past versions of h2o can be acquired from the h2o github page. The Changes.md (https://github.com/h2oai/h2o-3/blob/master/Changes.md) file links to where you can download every version. Just search for the version you want (e.g. "3.26.0.2") and you will see the URL there.

Info from stackoverflow on this here: https://stackoverflow.com/questions/57749892/how-to-install-specific-versions-of-h2o

From the Changes.md (https://github.com/h2oai/h2o-3/blob/master/Changes.md) file, each version is named (e.g. `Zygmund (3.38.0.2) - 10/27/2022`). You can then find download links for that version, which brings you ti a new page - now select the "Install in Python" tab which will show some code like this that you can copy/paste into your terminal: e.g. for v3.38.02:

```shell
# The following command removes the H2O module for Python.
pip uninstall h2o

# Next, use pip to install this version of the H2O Python module.
pip install http://h2o-release.s3.amazonaws.com/h2o/rel-zygmund/2/Python/h2o-3.38.0.2-py2.py3-none-any.whl
```

As you can see, the URL contains the version number - the key is to know which h2o version was used to train a given model.
Loading

0 comments on commit 572767c

Please sign in to comment.