Skip to content

ANN Forecast


Warning

This library is under development, none of the presented solutions are available for download.

Use continuous forest inventory databases to predict forest growth and production. Utilize artificial neural networks for greater flexibility. With this module, you will be able to estimate volume, the number of stems, basal area, among other variables of interest.


Class Parameters

ANN Trainer

AnnTrainer(df, y, *train_columns, iterator=None)
Parameters Description
df The dataframe containing the continous processed forest inventory data.
y The target variable for training the ANN (Y), the variable on which the ANN will be trained to predict.
*train_columns (*args) Names of the columns that will be used to train the artificial neural network so that it can predict the values of Y. Must be numeric.
iterator (Optional) Name of the column that contains the iterator. An artificial neural network will be adjusted for each iterator.

Class Functions

functions and parameters
  AnnTrainer.fit_model(save_dir=None)

Parameters Description
.fit_model() Adjust the model using *train_columns to predict the variable Y.

Ann structures

6 different structures of artificial neural networks will be tested. Only the result from 1 model will be returned. The model returned will be selected by the ranking function.
For the 'ann' model, the module sklearn.neural_network.MLPRegressor is used.

MLPRegressor
Epochs: 3000
Activation: logistic
Solver Mode: lbfgs
Batch size: dynamic
Learning rate init: 0.1
Learning rate mode: adaptive
Model-0
Hidden layer sizes:(15, 25, 20, 30, 10)
Model-1
Hidden layer sizes:(35, 10, 25, 35, 15)
Model-2
Hidden layer sizes:(25, 15, 30, 20)
Model-3
Hidden layer sizes:(15, 35, 45)
Model-4
Hidden layer sizes:(35, 10, 25, 35, 15)
Model-5
Hidden layer sizes:(35, 10, 25, 35, 15, 20, 15, 30)
ANN Parameters

ANN Predictor

AnnPredictor(pkl_file)
Parameters Description
pkl_file Directory of the .pkl file that will be used for prediction.
Class Functions

functions and parameters
  AnnPredictor.predict(df, *args)

Example Usage

ann_forecast_example.py
from fptools.forecast import AnnTrainer, AnnPredictor
import pandas as pd

ann_forecast_example.py
df_train = pd.read_csv(r'C:\Your\path\continuous_inventory_data.csv')

df_predictions = pd.read_csv(r'C:\Your\path\new_inventory_data.csv')

columns_used_for_training = [
                            "age",
                            "shafts",
                            "basal-area",
                            "HMAX",
                            "DMAX",
                            "DG"
                            ]

ann_train = AnnTrainer(df_train, y="commercial-volume",
                       *columns_used_for_training,
                        iterator="Genetic Material")

ann_train_metrics = ann_train.fit_model(
                                        save_dir = r"C:\Your\path\output")

ann_predictor = AnnPredictor(r"C:\Your\path\output\comercial-volume_ann_predictor_GM-A.pkl")

predicted_commercial_volume = ann_predictor.predict(df_predictions, *columns_used_for_training)