<jupyter_start><jupyter_text>Note othronormal if A.T == inv(A) if orthonormal, np.dot(A.T, A) == np.dot(A, A.T)  Build Orthonormal matrix  Gram-Schmidt process<jupyter_code>vectors = np.array([[2,4,6], [5,8,3], [8,3,2]])
def buildOrthonormalMatrixBasedOn(*vectors):
    vectors = np.array(vectors[0])
    print("Shape ", vectors.shape)
    numberOfVector, targetDimension = vectors.shape
    assert numberOfVector >= targetDimension, "You need more vectors"
    
    baseVectors = []
    
    for vectorIndex in range(targetDimension):
        currentVector = vectors[vectorIndex]
        delta = np.zeros((targetDimension))
        for v in range(0, vectorIndex):
            baseVector = baseVectors[v]
            delta = delta - (np.dot(currentVector, baseVector) * baseVector)
        
        tempVector = currentVector + delta
        baseVectors.append(tempVector / nl.norm(tempVector))

    # Check if all vectors are orthogonal
    EPSILON = np.power(10.0, -15)
    for indexBaseV in range(len(baseVectors)):
        for nextBaseV in range(indexBaseV + 1, len(baseVectors)):
            dot =  np.dot(baseVectors[indexBaseV], baseVectors[nextBaseV])
            assert abs(dot) <= EPSILON, "Vectors are not othogonal but %s instead" % dot
            
    baseVectors = np.array(baseVectors)
    
    assert np.allclose(baseVectors.T, nl.inv(baseVectors), atol=EPSILON), "The matrix produce is not orthonormal!"
    return baseVectors
baseV = buildOrthonormalMatrixBasedOn(vectors)
baseV<jupyter_output>Shape  (3, 3)<jupyter_text>Projection of vector to normalized vector is np.dot(V, e)<jupyter_code>np.dot(baseV[0], baseV[1]) # The two base are orthogonal !
buildOrthonormalMatrixBasedOn(baseV)<jupyter_output>Shape  (3, 3)
{'fraction_non_alphanumeric': 0.11412103746397695, 'fraction_numerical': 0.013256484149855908, 'mean_word_length': 3.6792452830188678, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '47808', 'license': 'MIT', 'n_tokens_mistral': 602, 'n_tokens_neox': 588, 'n_words': 130, 'path': 'Certification 1/Week4.3 - Transpose Matrix And Orthonormal matrix.ipynb', 'repo_name': 'The-Brains/MathForMachineLearning', 'size': '1735'}