Volumetrics
Warning
This library is under development, none of the presented solutions are available for download.
Obtain tree volumes from forest inventory data and fit taper functions to capture tree shape and estimate diameters at different heights. Obtain reports on the total volume produced, as well as assortments generated by the forest.
Class Parameters
VolEstimation(df, tree_identifier, tree_height, tree_dbh, tree_bark, segment_height, segment_diameter)
Parameters | Description |
---|---|
df | The dataframe containing the cubage data. |
tree_identifier | The name of the column that contains the unique identifiers of the trees. |
tree_height | The name of the column that contains the total heights of the trees (meters). |
tree_dbh | The name of the column containing the diameter at breast height (DBH) values of the trees (centimeters). |
tree_bark | (Optional) The name of the column containing the bark thickness values of the trees (centimeters). If tree_bark == None return only volumes with bark on 'get_volumes()' method. |
segment_height | The name of the column containing the heights of the cubed segments of the trees (meters). |
segment_diameter | The name of the column containing the diameters of the cubed segments of the trees (centimeters). |
Class Functions
VolEstimation.get_volumes()
VolEstimation.fit_taper_functions(models,iterator) #(1)
VolEstimation.get_individual_diameter(hi,tree_height, tree_dbh) #(2)
- models = (Optional) List of models to be fitted! If
models == None
uses all available models.
iterator = (Optional) A column name string. Defines wich column will be used as a iterator. Could be a farm name, plot name, code or any unique identification tag. - hi = Fraction of height from which you want to obtain the diameter (meters).
tree_height = Total height of the tree (meters).
tree_dbh = Diameter at breast height (DBH) value of the tree (centimeters).
Parameters | Description |
---|---|
.get_volumes() | Returns the volume of each cubed segment and the total volume of each tree separated by tree_identifier . If tree_bark == None , it returns only the volume with bark; otherwise, it returns the volume with and without bark. |
.fit_taper_functions(models, iterator) | Fits the available taper function models. Saves a .json file with the coefficients for each fitted model and a .pkl file for the fitted ANN's. |
.get_individual_diameter(hi, tree_height, tree_dbh) | Returns a diameter at a hi height of the tree. |
Example Usage
taper_functions_example.py | |
---|---|
1 2 |
|
- Import
VolEstimation
class. - Import
pandas
for data manipulation.
Create a variable for the VolEstimation Class
taper_functions_example.py | |
---|---|
3 4 5 6 7 |
|
- Load your csv file.
- Create the variable
vol
containing theVolEstimation
class. - Calculate volumes for each tree and segments em save the results on
calculated_volumes_df
variable. - Fit the taper functions and save the performance metris in
metrics
variable. It will create a.json
file with the models coefficients and a.pkl
files for the fitted ann models. - Get the diameter at 1.3 meters of a tree with a total height of 25 meters and a diameter at breast height (DBH) of 30 centimeters.
Available models
Notation
- \( β_n \): Fitted parameters
- \( d_i \): Diameter (cm)
- \( \text{dbh} \): Diameter at breast height (cm)
- \( H \): Total height (m)
- \( h_i \): Segment height (m)
Artificial Neural Network
When selecting the 'ann' model, 5 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.
Ranking function
To select the best-performing models and rank them accordingly, the following metrics are obtained:
Métric name | Structure |
---|---|
Mean Absolute Error (MAE) | \( MAE = \frac{1}{n} \sum_{i=1}^{n} \|y_i - \hat{y}_i\| \) |
Mean Absolute Percentage Error (MAPE) | \( MAPE = \frac{100}{n} \sum_{i=1}^{n} \left\|\frac{y_i - \hat{y}_i}{y_i}\right\| \) |
Mean Squared Error (MSE) | \( MSE = \frac{1}{n} \sum_{i=1}^{n} (y_i - \hat{y}_i)^2 \) |
Root Mean Squared Error (RMSE) | \( RMSE = \sqrt{\frac{1}{n} \sum_{i=1}^{n} (y_i - \hat{y}_i)^2} \) |
R Squared (Coefficient of Determination) | \( R^2 = 1 - \frac{\sum_{i=1}^{n} (y_i - \hat{y}_i)^2}{\sum_{i=1}^{n} (y_i - \bar{y})^2} \) |
Explained Variance (EV) | \( EV = 1 - \frac{Var(y - \hat{y})}{Var(y)} \) |
Mean Error | \( Mean\ Error = \frac{1}{n} \sum_{i=1}^{n} (y_i - \hat{y}_i) \) |
After obtaining the metrics for each tested model, the best model receives a score of 10, while the others receive scores of 9, 8, and so on.