zoo.automl.common package¶
Submodules¶
zoo.automl.common.metrics module¶
-
class
zoo.automl.common.metrics.Evaluator[source]¶ Bases:
objectEvaluate metrics for y_true and y_pred
-
metrics_func= {'accuracy': <function Accuracy>, 'mae': <function mean_absolute_error>, 'mape': <function MAPE>, 'mdape': <function MDAPE>, 'me': <function ME>, 'mpe': <function MPE>, 'mse': <function mean_squared_error>, 'msle': <function mean_squared_log_error>, 'mspe': <function MSPE>, 'r2': <function r2_score>, 'rmse': <function RMSE>, 'smape': <function sMAPE>, 'smdape': <function sMDAPE>}¶
-
-
zoo.automl.common.metrics.MAPE(y_true, y_pred, multioutput='raw_values')[source]¶ calculate mean absolute percentage error (MAPE). <math>mbox{M} =
rac{100%}{n}sum_{t=1}^n left| rac{A_t-F_t}{A_t} ight|, </math>
- param y_true
array-like of shape = (n_samples) or (n_samples, n_outputs) Ground truth (correct) target values.
- param y_pred
array-like of shape = (n_samples) or (n_samples, n_outputs) Estimated target values.
- param multioutput
string in [‘raw_values’, ‘uniform_average’]
- :return:float or ndarray of floats
A non-negative floating point value (the best value is 0.0), or an array of floating point values, one for each individual target.
-
zoo.automl.common.metrics.MDAPE(y_true, y_pred, multioutput='raw_values')[source]¶ calculate Median Absolute Percentage Error (MDAPE). :param y_true: array-like of shape = (n_samples) or (n_samples, n_outputs)
Ground truth (correct) target values.
- Parameters
y_pred – array-like of shape = (n_samples) or (n_samples, n_outputs) Estimated target values.
multioutput – string in [‘raw_values’, ‘uniform_average’]
- :return:float or ndarray of floats
A non-negative floating point value (the best value is 0.0), or an array of floating point values, one for each individual target.
-
zoo.automl.common.metrics.ME(y_true, y_pred, multioutput='raw_values')[source]¶ calculate Mean Error (ME). :param y_true: array-like of shape = (n_samples) or (n_samples, n_outputs)
Ground truth (correct) target values.
- Parameters
y_pred – array-like of shape = (n_samples) or (n_samples, n_outputs) Estimated target values.
multioutput – string in [‘raw_values’, ‘uniform_average’]
- :return:float or ndarray of floats
A non-negative floating point value (the best value is 0.0), or an array of floating point values, one for each individual target.
-
zoo.automl.common.metrics.MPE(y_true, y_pred, multioutput='raw_values')[source]¶ calculate mean percentage error (MPE). <math> ext{MPE} =
rac{100%}{n}sum_{t=1}^n rac{a_t-f_t}{a_t} </math>
- param y_true
array-like of shape = (n_samples) or (n_samples, n_outputs) Ground truth (correct) target values.
- param y_pred
array-like of shape = (n_samples) or (n_samples, n_outputs) Estimated target values.
- param multioutput
string in [‘raw_values’, ‘uniform_average’]
- :return:float or ndarray of floats
A non-negative floating point value (the best value is 0.0), or an array of floating point values, one for each individual target.
-
zoo.automl.common.metrics.MSPE(y_true, y_pred, multioutput='raw_values')[source]¶ calculate mean squared percentage error (MSPE). <math>operatorname{MSPE}(L)=operatorname{E} left[left( g(x_i)-widehat{g}(x_i)
ight)^2 ight].</math>
- param y_true
array-like of shape = (n_samples) or (n_samples, n_outputs) Ground truth (correct) target values.
- param y_pred
array-like of shape = (n_samples) or (n_samples, n_outputs) Estimated target values.
- param multioutput
string in [‘raw_values’, ‘uniform_average’]
- :return:float or ndarray of floats
A non-negative floating point value (the best value is 0.0), or an array of floating point values, one for each individual target.
-
zoo.automl.common.metrics.RMSE(y_true, y_pred, multioutput='raw_values')[source]¶ calculate square root of the mean squared error (RMSE). :param y_true: array-like of shape = (n_samples) or (n_samples, n_outputs)
Ground truth (correct) target values.
- Parameters
y_pred – array-like of shape = (n_samples) or (n_samples, n_outputs) Estimated target values.
multioutput – string in [‘raw_values’, ‘uniform_average’]
- :return:float or ndarray of floats
A non-negative floating point value (the best value is 0.0), or an array of floating point values, one for each individual target.
-
zoo.automl.common.metrics.sMAPE(y_true, y_pred, multioutput='raw_values')[source]¶ calculate Symmetric mean absolute percentage error (sMAPE). <math> ext{SMAPE} =
rac{100%}{n} sum_{t=1}^n rac{|F_t-A_t|}{|A_t|+|F_t|}</math>
- param y_true
array-like of shape = (n_samples) or (n_samples, n_outputs) Ground truth (correct) target values.
- param y_pred
array-like of shape = (n_samples) or (n_samples, n_outputs) Estimated target values.
- param multioutput
string in [‘raw_values’, ‘uniform_average’]
- :return:float or ndarray of floats
A non-negative floating point value (the best value is 0.0), or an array of floating point values, one for each individual target.
-
zoo.automl.common.metrics.sMDAPE(y_true, y_pred, multioutput='raw_values')[source]¶ calculate Symmetric Median Absolute Percentage Error (sMDAPE). :param y_true: array-like of shape = (n_samples) or (n_samples, n_outputs)
Ground truth (correct) target values.
- Parameters
y_pred – array-like of shape = (n_samples) or (n_samples, n_outputs) Estimated target values.
multioutput – string in [‘raw_values’, ‘uniform_average’]
- :return:float or ndarray of floats
A non-negative floating point value (the best value is 0.0), or an array of floating point values, one for each individual target.
zoo.automl.common.parameters module¶
zoo.automl.common.util module¶
-
class
zoo.automl.common.util.NumpyEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]¶ Bases:
json.encoder.JSONEncoderconvert numpy array to list for JSON serialize
-
default(obj)[source]¶ Implement this method in a subclass such that it returns a serializable object for
o, or calls the base implementation (to raise aTypeError).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return JSONEncoder.default(self, o)
-
-
zoo.automl.common.util.restore_hdfs(model_path, remote_dir, feature_transformers=None, model=None, config=None)[source]¶
-
zoo.automl.common.util.restore_zip(file, feature_transformers=None, model=None, config=None)[source]¶
-
zoo.automl.common.util.save_config(file_path, config, replace=False)[source]¶ - Parameters
file_path – the file path of config to be saved.
config – dict. The config to be saved
replace – whether to replace if the config file already existed.
- Returns
-
zoo.automl.common.util.train_val_test_split(df, val_ratio=0, test_ratio=0.1, look_back=0, horizon=1)[source]¶ split input dataframe into train_df, val_df and test_df according to split ratio. The dataframe is splitted in its originally order in timeline. e.g. |......... train_df(80%) ........ | ... val_df(10%) ...| …test_df(10%)…| :param df: dataframe to be splitted :param val_ratio: validation ratio :param test_ratio: test ratio :param look_back: the length to look back :param horizon: num of steps to look forward :return: