API Documentation#
evaluate.py#
- class evaluate.RunWithTimeout(function, args)#
This class is used for running a function in a separate thread with predefined timeout.
- run(timeout)#
Runs the function with timeout. :param timeout: time in seconds :return: test
- evaluate.evaluate_json(prediction_json, true_json)#
Compares two jsons (or dictionaries) i.e. the json with ground truth and predictions :param prediction_json: json object where predictions are found :param true_json: json object where ground truth is :return: metric on how good you predicted :raises Exception: If a file is missing in either the prediction json or in ground truth json
- evaluate.evaluate_live(csv_files, true_results_json_file, model)#
A wrapper fo evaluate_json and generate_live_predictions :param csv_files: list of csv files :param true_results_json_file: json file with ground truth :param model: prediction model :returns: metric on how good you predicted
- evaluate.generate_live_predictions(files: List, model) dict #
Takes a list of csv files and prediction model, it generates the prediction json :param files: list of csv files :param model: prediction model :return: json with predictions for each csv file
- evaluate.get_from_csv(file)#
Reads from the specified csv file. :param file: test :return: test
- evaluate.run_live_prediction(file, model)#
Opens a csv file and makes predictions. :param file: A csv file :param model: Model which makes prediction :return: a dictionary with file name, end periods and leakages
leak_detection.py#
- class leak_detection.LeakDetection(dirname='.')#
For correct automatic evaluation please implement your prediction logic inside this class
- load_model(dirname)#
Loads your pretrained model to use it for prediction. Please use os.path.join(location_to_dir, model_file_name)
- Parameters
dirname – Path to directory where model is located
- Returns
your pretrained model, if no model is required return None
- Example:
import os import joblib load(os.path.join(self.dirname, ‘tree.joblib’))
- predict(features: List) bool #
Your implementation for prediction. If leak is detected it should return true.
- Parameters
features – A list of features
- Returns
should return true if leak is detected. Otherwise, it should return false.
- Example:
return self.model.predict(features) == 0