liveBook · Manning

Feature vector

As explained in Build AI Drug Discovery Pipelines

A feature vector is an ordered collection of numerical or categorical features representing one input instance.

A feature vector is an ordered collection of features that represents one input instance. Its dimensionality is the number of features it contains. For a toxicity classifier, each molecule can have a vector describing properties such as molecular weight and counts of atoms or bond types; its label says whether it is toxic. section 1.2.2

In a molecular graph, features can describe individual atoms or bonds, as well as the whole graph. These attributes give a graph neural network information it can use to make predictions. section 11.2 section 11.2.2

An atom as a vector

An atom can be represented by a 78-dimensional vector combining its element, degree, hydrogen count, implicit valence, and aromaticity. The element is one-hot encoded: a vocabulary assigns a position to each element, and the atom’s element activates its corresponding position. RDKit extracts these properties when converting a SMILES string into a molecular graph. section 11.2.2

Listing 11.2 Generate 78-dimensional Feature Vector for a Single Atom
def atom_features(atom):
    features = []
    features += one_of_k_encoding_unk(
        atom.GetSymbol(), ATOM_SYMBOLS
    )
    features += one_of_k_encoding_unk(
        atom.GetDegree(), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    )
    features += one_of_k_encoding_unk(
        atom.GetTotalNumHs(), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    )
    features += one_of_k_encoding_unk(
        atom.GetImplicitValence(), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    )
    features += [int(atom.GetIsAromatic())]
 
    return np.array(features, dtype=np.float32)

Inspect how the atom properties are encoded and combined into a NumPy array. section 11.2.2

A protein residue as a vector

A protein graph can represent each amino acid residue with 54 features: 21 for amino acid identity, 21 from a position-specific scoring matrix, and 12 biochemical properties. The scoring matrix provides evolutionary context from aligned sequences. In this implementation it contains position probabilities rather than traditional log-odds scores. section 11.3.2

Listing 11.6 Generate 54-dimensional Feature Matrix for Protein
def compute_target_feature(aln_file: str, pro_seq: str) -> np.ndarray:
    pssm = PSSM_calculation(aln_file, pro_seq)
    pssm_transposed = np.transpose(pssm, (1, 0))
    other_feature = seq_feature(pro_seq)
    return np.concatenate(
        (pssm_transposed, other_feature), axis=1
    )    #A

See how the position-specific matrix and other residue features are concatenated into a protein feature matrix. section 11.3.2

More features can provide useful information, but high-dimensional inputs can overfit when the training dataset is too small. section 11.3.2

How Build AI Drug Discovery Pipelines covers it

How deep it goes
Defines dimensionality and implements atom and residue representations using encoded and concatenated properties.
Examples
Uses toxicity classification, a 78-dimensional atom vector, and a 54-dimensional protein residue vector.
What you can do after
Apply it via RDKit to extract atom properties and construct molecular graph features.
How it connects
Connects feature engineering with classification, molecular graphs, one-hot encoding, and position-specific scoring matrices.

Also explained in

Compare how 5 books explain feature vector →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build AI Drug Discovery Pipelines. The section links point to the parts of the book it draws on.