-
The following has been tested using a full Anaconda distribution, but Miniconda is probably sufficient and will take less time to install.
-
git clone https://github.com/g-simmons/dairyML.git
or download using the green "clone or download" button on the right
-
cd DairyML
conda env create -f environment_test_min.yml python=3.6
conda activate dmltest
(Note that this will only install the minimum requirements for testing the most recent model. The full development environment can be installed with
conda env create -f environment_full.yml
) -
First create the directory:
mkdir data
Then place the testing csv file in the new directory.
Make sure that the test data columns match the columns of
data/training_for_GS_122118.csv
-
Test script usage is: python test.py <model_path> <data_path>
For example, from the main directory:
python src/test.py models/xgb_combined.model data/<test_data_filename>.csv
Example output:
(dmltest) C:\Users\Gabriel\DairyML>python src\test.py models\xgb_combined.model data\training_for_GS_122118.csv Loading modules... Loading model at models\xgb_combined.model Loading data at data\training_for_GS_122118.csv Scaling input features... Testing the model... Results: r2: 1.0 SRC: 1.0 PCC: 1.0 MI: 4.0 MAE: 0.0 classifier_accuracy: 1.0 classifier_f1: 1.0 Results saved to reports/test_results_2019-02-21-20-26-24.csv Predictions saved to reports/test_predictions_2019-02-21-20-26-24.csv
This starter code has not been tested, but this is what using the model would look like. It is stored as a binary object using pickle, and can be loaded using pickle.load.
Ex code
import pickle as pkl
from xgboost import XGBRegressor, XGBClassifier
from dairyml import XGBCombined
model_path = <specify model path>
with open(model_path, "rb" ) as f:
model = pkl.load(f)
#do stuff with the model, e.g.
#X = features
#Y = target variable
predictions = model.predict(X_new)