Python API

Submodules

plip.Lasso module

This package contains the LASSO-LARS implementation for PLIP.

plip.Lasso.fit_model(alpha, XMAT_Train, Y_Train)

Fit the lasso lars model

Parameters:
  • alpha (float) – Regularization parameter

  • XMAT_Train (nd.array) – Training set of descriptors

  • Y_Train (nd.array) – Reference training forces

Returns:

Optimal coeffecients

Return type:

nd.array

plip.Lasso.getBinaryFiles(input_file, list_itype)

Get the list of binary files based on the input file and descriptor types

Parameters:
  • input_file (str) – Input structure file

  • list_itype (list) – List of descriptor types

Returns:

List of binary files

Return type:

list

plip.Lasso.getNatoms(input_file)

Counts number of atoms in a structure file

Parameters:

input_file (str) – Input structure file

Returns:

total number of atoms

Return type:

int

plip.Lasso.oldread_File(input_file, list_itype)
Parameters:
  • input_file (str) – input structure file

  • list_itype (list) – type of descriptor

Returns:

fingerprint matrix

Return type:

np.array

plip.Lasso.readBinaryFiles(list_bin)

Read and concatenate data from binary files

Parameters:

list_bin (list) – List of binary files

Returns:

Concatenated data from binary files

Return type:

np.array

plip.Lasso.readForces(input_file)

Read forces from a reference file

Parameters:

input_file (str) – Input force file

Returns:

forces per atom

Return type:

np.array

plip.Lasso.read_File(input_file, list_itype)

Read the input structure file and binary files

Parameters:
  • input_file (str) – Input structure file

  • list_itype (list) – List of descriptor types

Returns:

Fingerprint matrix np.array: Forces per atom

Return type:

np.array

plip.Lasso.runLasso(inputArgs, alpha=None, ref_dir='Refs')

Run lasso Lars

Parameters:
  • inputArgs (string) – Descriptor type

  • alpha (float, optional) – Regularization parameter. Defaults to “None”.

  • ref_dir (str, optional) – reference folder name. Defaults to “Refs”.

Returns:

A tuple containing the following elements:
  • scoreTrain (float): R-squared score on the training data.

  • scoreTest (float): R-squared score on the test data.

Return type:

tuple

plip.Lasso.setup_data(inputArgs, ref_dir)

Build fingerprint matrix and references :param inputArgs: Descriptor type :type inputArgs: string :param ref_dir: Folder with reference forces. Defaults to “Refs”. :type ref_dir: str, optional

Raises:

ValueError – When references are empty

plip.Lasso.split_data(XMAT, Yin, split_ratio=0.95)

Split the data set for testing and training

Parameters:
  • XMAT (nd.array) – Input descriptors

  • Yin (nd.array) – References

  • split_ratio (float, optional) – Test-Train split ratio. Defaults to 0.95.

Returns:

Test and Training data sets

Return type:

nd.array

plip.Lasso.write_coefficients(coeff, str_alpha, str_type)

Write coeffecients to a file

Parameters:
  • coeff (nd.array) – optimal coefficients

  • str_alpha (float) – regularization parameter

  • str_type (str) – Descriptor type

plip.Lasso.write_results(Y, Y_OUT, str_alpha, str_type, prefix)
Parameters:
  • Y (nd.array) – Reference values

  • Y_OUT (nd.array) – Predictted values

  • str_alpha (float) – regularization parameter

  • str_type (str) – Descriptor type

  • prefix (str) – Filename prefix

plip.main module

plip.main.compile()

Function to compile C++ modules

plip.main.genBin()

Function to generate bin files

plip.main.genPot()

Generate potential from Lasso coefficients

plip.main.train(args, alpha=None)

Train LassoLars model

Parameters:
  • args (str) – Type of descriptor

  • alpha (float, optional) – regularization parameter

plip.main.xmat_input(config)

Generate input.txt file from YAML for C++ code

Parameters:

config (dict) – Dictionary with input values for generating machine learning fingerprint

plip.main.yaml_reader(filename)

Read the YAML workflow

Parameters:

filename (str) – YAML workflow name

plip.utils module

plip.utils.compile_program(program_name, source_files, export_name)

Function to compile files

Parameters:
  • program_name (str) – Name of the executable

  • source_files (str) – List f source files

  • export_name (str) – Executable name

plip.utils.move_files(source_dir, destination_dir, *file_patterns)

Move files

Parameters:
  • source_dir (str) – Source destination

  • destination_dir (str) – End destination

plip.utils.run_program(program_name, program_args=[])

Run program

Parameters:
  • program_name (str) – Name of the executable

  • program_args (list, optional) – Extra flags for the executable.

Module contents