Generating Dot Product Tables for All Level Combinations with Python
import numpy as np
from itertools import product

# Define the levels
levels = ['fee', 'fie', 'foe', 'fum', 'quux']

# Initialize an empty list to store the results
results = []

# Iterate over all possible combinations of levels (Cartesian product)
for combination in product(levels, repeat=4):
    # Create a 1D array for this level combination
    combination_array = np.array(combination)

    # Calculate the dot product between the input and each level
    scores = np.dot(np.array(range(100)), combination_array.T)

    # Append the result to the list of results
    results.append(scores)

# Convert the list of results into a DataFrame
import pandas as pd
df = pd.DataFrame(results, columns=[f'level_{i}' for i in range(len(levels))])

print(df)

This code will create a table with one row per level combination and each column corresponding to a specific level. The values in each row represent the dot product between the input (in this case, 0-99) and each level.


Last modified on 2024-04-12