polymon.estimator

Available Estimators

Available Estimators in polymon.estimator

Estimator Type

Class Name

Description

atom_contrib

AtomContribEstimator

Atom contribution estimator

Density

DensityEstimator

Density estimator

Density-IBM

DensityIBMEstimator

Density estimator (IBM)

Density-Fedors

DensityFedorsEstimator

Density estimator (Fedors)

LowFidelity

LowFidelityEstimator

Low fidelity estimator

ml

MLEstimator

Machine learning estimator

NxRg

NxRgEstimator

Rg estimator (NetworkX)

rg

RgEstimator

Rg estimator (DFS)

Atom Contribution Estimator

class polymon.estimator.atom_contrib.AtomContribEstimator(atom_contrib: ndarray)[source]

Bases: BaseEstimator

Atom contribution estimator. It is used to estimate the label of a polymer based on the atom composition.

Parameters:

atom_contrib (np.ndarray) – The atom contribution coefficients. It is a 1D array of shape (MAX_NUM_ELEMENTS,). The i-th element is the contribution of the i-th element to the label. The i-th element is the number of atoms of the i-th element in the polymer. The MAX_NUM_ELEMENTS is 100.

estimated_y(smiles: str) → float[source]

Estimate the label of a polymer based on the atom composition.

Parameters:

smiles (str) – The SMILES of the polymer.

Returns:

The estimated label of the polymer.

Return type:

float

classmethod from_fitting(df: DataFrame, smiles_col: str = 'SMILES', label_col: str = 'FFV') → AtomContribEstimator[source]

Fit the atom contribution estimator from a dataframe.

Parameters:
  • df (pd.DataFrame) – The dataframe containing the SMILES and label.

  • smiles_col (str) – The column name of the SMILES.

  • label_col (str) – The column name of the label.

Returns:

The fitted atom contribution estimator.

Return type:

AtomContribEstimator

classmethod from_npy(path: str) → AtomContribEstimator[source]

Load the atom contribution estimator from a npy file.

Parameters:

path (str) – The path to the npy file.

Returns:

The loaded atom contribution estimator.

Return type:

AtomContribEstimator

write(path: str) → None[source]

Write the atom contribution estimator to a npy file.

Parameters:

path (str) – The path to the npy file.

Density Estimator (van der Waals)

class polymon.estimator.density.DensityEstimator(packing_coeff: float = 0.8)[source]

Bases: BaseEstimator

Density estimator using the van der Waals method. This is a simple method that estimates the density of a polymer based on the van der Waals volume of the atoms in the molecule.

estimated_y(smiles: str) → float[source]

Estimate the density of a polymer based on the van der Waals method.

Parameters:

smiles (str) – The SMILES of the polymer.

Returns:

The estimated density of the polymer.

Return type:

float

Density Estimator (Fedors)

class polymon.estimator.density_Fedors.DensityFedorsEstimator[source]

Bases: BaseEstimator

Density estimator using the Fedors method. This is a group contribution method that assigns a contribution to each group of atoms in the molecule.

estimated_y(smiles: str) → float[source]

Estimate the density of a polymer based on the Fedors method.

Parameters:

smiles (str) – The SMILES of the polymer.

Returns:

The estimated density of the polymer.

Return type:

float

Density Estimator (IBM)

class polymon.estimator.density_ibm.DensityIBMEstimator[source]

Bases: BaseEstimator

Density estimator using the IBM method. This is a group contribution method that assigns a contribution to each group of atoms in the molecule. The original implementation is from https://github.com/IBM/polymer_property_prediction.

estimated_y(smiles: str) → float[source]

Low Fidelity Estimator

class polymon.estimator.low_fidelity.LowFidelityEstimator(model_info: Dict[str, Any])[source]

Bases: BaseEstimator

Low fidelity estimator. This is a simple estimator that uses a model to estimate the label of a polymer. The model is a trained model on a low fidelity dataset. The model should be an object of polymon.model.base.ModelWrapper.

estimated_y(smiles: str) → float[source]

Estimate the label of a polymer based on the low fidelity model.

Parameters:

smiles (str) – The SMILES of the polymer.

Returns:

The estimated label of the polymer.

Return type:

float

forward(data: Polymer, **kwargs) → Polymer[source]

Estimate the label of a polymer based on the low fidelity model.

Parameters:

data (Polymer) – The polymer data.

Returns:

The polymer data with the estimated label.

Return type:

Polymer

Machine Learning Estimator

class polymon.estimator.ml.MLEstimator(model, feature_names: List[str] = ['rdkit2d'])[source]

Bases: BaseEstimator

Machine learning estimator. This is a simple estimator that uses a model to estimate the label of a polymer. The model is a trained model on a dataset. The model should be an object of sklearn model.

estimated_y(smiles: str) → float[source]

Estimate the label of a polymer based on the machine learning model.

Parameters:

smiles (str) – The SMILES of the polymer.

Returns:

The estimated label of the polymer.

Return type:

float

classmethod from_pickle(path: str, feature_names: List[str] = None)[source]

Load the machine learning estimator from a pickle file.

Parameters:
  • path (str) – The path to the pickle file.

  • feature_names (List[str]) – The feature names.

Returns:

The loaded machine learning estimator.

Return type:

MLEstimator

write_pickle(path: str)[source]

Write the machine learning estimator to a pickle file.

Parameters:

path (str) – The path to the pickle file.

Rg Estimator (NetworkX)

class polymon.estimator.nx_rg.NxRgEstimator(N: int = 680, C_inf: float = 6.7, solvent: str = 'theta')[source]

Bases: BaseEstimator

Radius of gyration estimator using NetworkX. This is a simple estimator that uses NetworkX to estimate the radius of gyration of a polymer.

estimated_y(smiles: str) → float[source]

Estimate the radius of gyration of a polymer based on the NetworkX method.

Parameters:

smiles (str) – The SMILES of the polymer.

Returns:

The estimated radius of gyration of the polymer.

Return type:

float

kuhn_length(char_ratio=6.7, bond_length=0.154)[source]
longest_backbone_path_length(mol)[source]

Approximate the longest backbone path length using NetworkX. Finds the longest shortest path (diameter in weighted sense).

mol_to_nx(mol)[source]

Convert RDKit Mol to NetworkX weighted graph.

monomer_contour_length(smiles)[source]
radius_of_gyration(smiles)[source]

Estimate Rg from a monomer SMILES without using conformers. - N: degree of polymerization - C_inf: characteristic ratio (defaults ~6.7 for flexible chains) - solvent: ‘theta’ or ‘good’

Rg Estimator (DFS)

class polymon.estimator.rg.RgEstimator(N: int = 600, C_inf: float = 6.7, solvent: str = 'theta')[source]

Bases: BaseEstimator

Radius of gyration estimator using DFS. This is a simple estimator that uses DFS to estimate the radius of gyration of a polymer.

estimated_y(smiles: str) → float[source]

Estimate the radius of gyration of a polymer based on the DFS method.

Parameters:

smiles (str) – The SMILES of the polymer.

Returns:

The estimated radius of gyration of the polymer.

Return type:

float

kuhn_length(char_ratio=6.7, bond_length=0.154)[source]
longest_backbone_path_length(mol)[source]

Find the length of the longest simple path (approximate backbone).

monomer_contour_length(smiles)[source]
radius_of_gyration(smiles)[source]

Estimate Rg from a monomer SMILES without using conformers. - N: degree of polymerization - C_inf: characteristic ratio (defaults ~6.7 for flexible chains) - solvent: ‘theta’ or ‘good’