AI / ChatGPT
AI Consultancy

Python Script to start visualizing a LLM for Translation between random languages

Posted on October 29, 2023 in Top Level Category by Stefaan Meeuws
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from mpl_toolkits.mplot3d.art3d import Line3DCollection

# Original data
data = [
    {"x": 1, "y": 2, "z": 3},
    {"x": 2, "y": 3, "z": 4},
    {"x": 3, "y": 4, "z": 5},
    # Add more dictionaries for more points
]

# Add 10 more dictionaries with random x, y, and z values
for _ in range(10):
    data.append({
        "x": np.random.uniform(0, 10),  # Random x value between 0 and 10
        "y": np.random.uniform(0, 10),  # Random y value between 0 and 10
        "z": np.random.uniform(0, 10)   # Random z value between 0 and 10
    })

# Extract coordinates from the data
x = [point["x"] for point in data]
y = [point["y"] for point in data]
z = [point["z"] for point in data]

# Create the 3D plot
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

# Plot the tiny circles
ax.scatter(x, y, z, s=10, c='b', marker='o')

# Create lines connecting the circles
segments = [((x[i], y[i], z[i]), (x[i + 1], y[i + 1], z[i + 1])) for i in range(len(x) - 1)]
lc = Line3DCollection(segments, color='r')
ax.add_collection3d(lc)

# Set axis labels
ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')

# Function for rotating the graph with mouse drag
def on_mouse_drag(event):
    if event.inaxes == ax:
        ax.view_init(elev=ax.elev + event.step[0], azim=ax.azim + event.step[1])
        fig.canvas.draw()

fig.canvas.mpl_connect('motion_notify_event', on_mouse_drag)

# Show the plot
plt.show()

Comments on 'Python Script to start visualizing a LLM for Translation between random languages' (0)

Leave a Reply

%d