validpy.SVM.src package

Submodules

validpy.SVM.src.experimentKcross module

validpy.SVM.src.experimentKcross.grid(conf, data_sets, output_length)

Runs the k-cross validation over all possible parameter combinations

Parameters:
  • conf (JSON) – configuration JSON
  • data_sets (list[list[tuple(list[float], list[float])]]) – examples as list of tuple (input, output)
Returns:

None

validpy.SVM.src.experimentKcross.k_cross_experiment(kernel, c, epsilon, degree, data_sets, out_folder, n_processes, output_length, csv=None)

Executes the k-cross validation

Parameters:
  • kernel (string) – Kernel function (possible values: linear, poly, rbf, sigmoid)
  • c (float) – penalty parameter C of the error term
  • epsilon (float) – Epsilon in the epsilon-SVR model, it specifies the epsilon-tube within which no penalty is associated in the training loss function with points predicted within a distance epsilon from the actual value
  • degree (int) – Degree of kernel function is significant only in poly, rbf, sigmoid
  • data_sets (list[list[tuple(list[float], list[float])]]) – List of the k data sets
  • out_folder (str) – Path to the output folder
  • output_length (int) – Output length
  • n_processes (int) – Number of parallel processes
  • csv (FileIO) – Output csv file
Returns:

Average error and average training time over the k experiments

Return type:

tuple(float, float)

validpy.SVM.src.experimentKcross.k_train(kernel, c, epsilon, degree, train, valid, folder, report, svr, q)

Runs the training and the model validation, this function have to been called via Process() https://docs.python.org/3/library/multiprocessing.html

Parameters:
  • kernel (string) – Kernel function (possible values: linear, poly, rbf, sigmoid)
  • c (float) – penalty parameter C of the error term
  • epsilon (float) – Epsilon in the epsilon-SVR model, it specifies the epsilon-tube within which no penalty is associated in the training loss function with points predicted within a distance epsilon from the actual value
  • degree (int) – Degree of kernel function is significant only in poly, rbf, sigmoid
  • train (list[tuple(list[float], list[float])]) – training set
  • valid (list[tuple(list[float], list[float])]) – validation set
  • folder (str) – path to the output experiment folder
  • report (str) – path to the output experiment report file (.txt)
  • svr (list[str]) – list of file name where to save models
  • q (Queue) – Queue
Returns:

training time and average validation error

Return type:

list[float]

validpy.SVM.src.experimentKcross.main(conf_file)

Reads configuration file and runs the k-cross validation experiments

Parameters:conf_file (str) – Path to the configuration file
Returns:None
validpy.SVM.src.experimentKcross.split_data_set_file(file_name, input_length, output_length, k, separator=', ')

Reads the data set from csv, split the input and the output, shuffle the example list and split it in to k subsets

Parameters:
  • file_name (str) – path to the csv file
  • input_length (int) – input length
  • output_length (int) – output length
  • k (int) – number of subsets
  • separator (Optional[str]) – csv file separators, default = ‘,’
Returns:

list of subsets

Return type:

list[list[tuple]]

validpy.SVM.src.experimentKcross.validate(clfs, validation_set)

Compute the average euclidean distance activating the model over a validation set

Parameters:
  • clfs (list[SVR]) – list of model
  • validation_set (list[tuple(list[float], list[float])]) – Validation set
Returns:

average euclidean distance

Return type:

float

Module contents