AI Agent Program
Python Code
Core Nodes, Trait Zones, and Edges
pythonCopy codeimport plotly.graph_objects as go
import numpy as np
# Define scores from the provided JSON data
data = {
"Extraversion": {
"Active": 70.23, "Assertive": 74.45, "Cheerful": 65.34, "Energetic": 69.88,
"Friendly": 60.11, "Sociable": 58.00
},
"Openness": {
"Adventurous": 40.89, "Artistic": 20.00, "Emotionally Aware": 65.39,
"Imaginative": 72.56, "Intellectual": 80.42, "Liberal": 68.53
},
"Conscientiousness": {
"Ambitious": 85.00, "Cautious": 76.44, "Disciplined": 92.00,
"Dutiful": 89.33, "Organized": 94.21, "Self Assured": 88.56
},
"Neuroticism": {
"Aggressive": 12.00, "Anxiety Prone": 18.34, "Impulsive": 15.98,
"Melancholy": 14.56, "Self Conscious": 22.45, "Stress Prone": 19.85
},
"Agreeableness": {
"Cooperative": 80.32, "Empathetic": 82.54, "Genuine": 85.39,
"Generous": 76.21, "Humble": 77.58, "Trusting": 74.28
},
"Cognition": {
"Cognitive Processes": 75.22, "Insight": 79.99, "Differentiation": 74.22,
"Causation": 88.49, "Discrepancies": 67.88, "Comparisons": 70.34
},
"Social Dynamics": {
"Social Affiliation": 65.44, "Inward Focus": 35.77, "Outward Focus": 72.56,
"Authentic": 78.22, "Negations": 30.00, "Clout": 84.56
},
"Drives": {
"Risk Seeking": 25.76, "Risk Aversion": 72.44, "Achievement": 91.34,
"Power": 60.11, "Reward": 68.00
},
"Emotions": {
"Goodfeel": 65.22, "Badfeel": 15.00, "Emotionality": 70.11, "Non Emotion": 18.45,
"Ambifeel": 30.56, "Admiration": 74.22, "Amusement": 40.00, "Excitement": 65.78,
"Gratitude": 78.22, "Joy": 60.56, "Affection": 55.34, "Anger": 12.00,
"Boredom": 14.22, "Disgust": 10.00, "Fear": 18.34, "Sadness": 15.76,
"Calmness": 85.22, "Curiosity": 75.00, "Surprise": 50.00
},
"Learning Orientation": {
"Technical Skills Acquisition": 76.34, "Technical Learning Abilities": 80.11,
"Technical Adaptability": 79.56, "Technical Growth Mindset": 87.22,
"Technical Tools and Technologies": 74.44, "Technical Proficiency": 82.66,
"Technical Certifications": 75.22, "Domain Certification Level": 78.22
},
"Temporal Adaptability": {
"Focus Past": 40.00, "Focus Present": 75.00, "Focus Future": 80.23
},
"Values and Ideals": {
"Challenge": 82.34, "Closeness": 75.28, "Curiosity": 78.22, "Excitement": 70.56,
"Harmony": 85.44, "Ideal": 43.22, "Liberty": 68.22, "Love": 77.66,
"Practicality": 89.12, "Self Expression": 65.78, "Stability": 82.76, "Structure": 91.34
},
"Focus of Thinking": {
"Self Focus": 50.45, "External Focus": 71.56
}
}
# Assign 3D positions for Core Nodes and Trait Zones
positions = {}
edges = []
np.random.seed(42)
core_offset = 0
for core, traits in data.items():
core_position = np.array([core_offset, 0, 0]) # Position core nodes linearly along X-axis
positions[core] = core_position
core_offset += 20
for trait, score in traits.items():
trait_position = core_position + np.random.uniform(-10, 10, 3) # Position around the core node
positions[trait] = trait_position
edges.append((core, trait)) # Connect Core Node to Trait Zone
# Create 3D plot
fig = go.Figure()
# Add Core Nodes
for core, pos in positions.items():
if core in data.keys():
fig.add_trace(go.Scatter3d(
x=[pos[0]],
y=[pos[1]],
z=[pos[2]],
mode='markers+text',
marker=dict(size=20, color='blue', opacity=0.9),
text=[core],
textposition='top center',
name=f"Core Node: {core}"
))
# Add Trait Zones
for core, traits in data.items():
for trait, score in traits.items():
trait_pos = positions[trait]
fig.add_trace(go.Scatter3d(
x=[trait_pos[0]],
y=[trait_pos[1]],
z=[trait_pos[2]],
mode='markers+text',
marker=dict(size=10, color='orange', opacity=0.8),
text=[f"{trait}: {score:.1f}"],
textposition='top center',
name=f"Trait Zone: {trait}"
))
# Add Edges
for edge in edges:
start, end = edge
fig.add_trace(go.Scatter3d(
x=[positions[start][0], positions[end][0]],
y=[positions[start][1], positions[end][1]],
z=[positions[start][2], positions[end][2]],
mode='lines',
line=dict(color='gray', width=2),
opacity=0.5,
name=f"Edge: {start} ↔ {end}"
))
# Configure Layout
fig.update_layout(
title="3D Cognitive Signature Visualization",
scene=dict(
xaxis=dict(title="Importance Depth"),
yaxis=dict(title="Trait Distribution"),
zaxis=dict(title="Cognitive Hemisphere")
),
margin=dict(l=0, r=0, b=0, t=40),
legend=dict(title="Legend", x=1, y=1)
)
# Show the Plot
fig.show()Corrected Code AI Agent
pythonCopy codeimport plotly.graph_objects as go
import numpy as np
import json
def cognitive_signature_visualization(data, g_L, h_N):
"""
Creates a 3D visualization of the Cognitive Signature.
Parameters:
- data (dict): The input JSON data containing core nodes, trait zones, and their scores.
- g_L (float): Level of work multiplier.
- h_N (float): Nature of work multiplier.
"""
# Assign 3D positions for Core Nodes and Trait Zones
positions = {}
edges = []
np.random.seed(42) # For consistent positioning
# Core Nodes Placement
core_offset = 0
for core, traits in data.items():
core_position = np.array([core_offset, 0, 0]) # Position Core Nodes along X-axis
positions[core] = core_position
core_offset += 20 # Space cores evenly
# Ensure traits are lists and process accordingly
if isinstance(traits, list):
for trait_data in traits: # Each trait is a dictionary in a list
if isinstance(trait_data, dict) and 'key' in trait_data and 'rating' in trait_data:
trait = trait_data['key']
score = trait_data['rating']
trait_position = core_position + np.random.uniform(-10, 10, 3) # Randomized position around core
positions[trait] = trait_position
edges.append((core, trait)) # Connect Core Node to Trait Zone
# Create 3D plot
fig = go.Figure()
# Add Core Nodes
for core, pos in positions.items():
if core in data.keys():
fig.add_trace(go.Scatter3d(
x=[pos[0]],
y=[pos[1]],
z=[pos[2]],
mode='markers+text',
marker=dict(size=20, color='blue', opacity=0.9),
text=[core],
textposition='top center',
name=f"Core Node: {core}"
))
# Add Trait Zones
for core, traits in data.items():
if isinstance(traits, list):
for trait_data in traits:
if isinstance(trait_data, dict) and 'key' in trait_data and 'rating' in trait_data:
trait = trait_data['key']
score = trait_data['rating']
trait_pos = positions[trait]
fig.add_trace(go.Scatter3d(
x=[trait_pos[0]],
y=[trait_pos[1]],
z=[trait_pos[2]],
mode='markers+text',
marker=dict(size=10, color='orange', opacity=0.8),
text=[f"{trait}: {score:.1f}"],
textposition='top center',
name=f"Trait Zone: {trait}"
))
# Add Edges
for edge in edges:
start, end = edge
edge_strength = np.random.uniform(0.5, 1.0) * g_L * h_N # Random correlation for edge strength
fig.add_trace(go.Scatter3d(
x=[positions[start][0], positions[end][0]],
y=[positions[start][1], positions[end][1]],
z=[positions[start][2], positions[end][2]],
mode='lines',
line=dict(color='gray', width=edge_strength),
name=f"Edge: {start} ↔ {end}"
))
# Configure Layout
fig.update_layout(
title="3D Cognitive Signature Visualization",
scene=dict(
xaxis=dict(title="Importance Depth"),
yaxis=dict(title="Trait Distribution"),
zaxis=dict(title="Cognitive Hemisphere")
),
margin=dict(l=0, r=0, b=0, t=40),
legend=dict(title="Legend", x=1, y=1)
)
# Show the Plot
fig.show()
# User Input Section
def main():
print("Welcome to the Cognitive Signature Visualizer!")
# Input JSON
print("Please enter your JSON data for Core Nodes and Trait Zones (or paste it as a single line):")
raw_json = input()
try:
data = json.loads(raw_json)
except json.JSONDecodeError:
print("Invalid JSON input. Please try again.")
return
# Input g(L)
try:
g_L = float(input("Enter g(L) (Level of Work Multiplier): "))
except ValueError:
print("Invalid input for g(L). Please enter a numeric value.")
return
# Input h(N)
try:
h_N = float(input("Enter h(N) (Nature of Work Multiplier): "))
except ValueError:
print("Invalid input for h(N). Please enter a numeric value.")
return
# Call the visualization function
cognitive_signature_visualization(data, g_L, h_N)
# Run the program
if __name__ == "__main__":
main()Last updated