everydaytok commited on
Commit
024ad0c
·
verified ·
1 Parent(s): 220daab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -6,6 +6,7 @@ from fastapi.responses import HTMLResponse
6
  from sklearn.decomposition import PCA
7
  from sklearn.cluster import AgglomerativeClustering
8
  from sklearn.metrics.pairwise import euclidean_distances
 
9
 
10
  app = FastAPI()
11
 
@@ -33,7 +34,7 @@ class AdaptiveVectorSystem:
33
 
34
  # Base score starts at 10
35
  # We penalize for high variation (chaos) and raw distance
36
- penalty = (variation_coefficient * 5.0) + (mean_dist * 0.1)
37
 
38
  score = 10.0 - penalty
39
  return max(-1.0, min(10.0, score))
@@ -97,14 +98,15 @@ class AdaptiveVectorSystem:
97
  # --- VISUALIZATION LOGIC ---
98
  def generate_plot(mode='global', scenario='split'):
99
  # Generate 128-dimension vectors
100
- np.random.seed(42) # Consistent seed for demo
 
101
 
102
  if scenario == 'split':
103
  # Create two dense islands far apart
104
  # Island 1: centered at 0
105
- c1 = np.random.normal(0, 0.5, (20, 128))
106
  # Island 2: centered at 10 (In 128D, distance approx sqrt(128*100) = ~113 units away)
107
- c2 = np.random.normal(8, 0.5, (20, 128))
108
  # Noise: Random scatter
109
  noise = np.random.uniform(-5, 15, (10, 128))
110
  data = np.vstack([c1, c2, noise])
 
6
  from sklearn.decomposition import PCA
7
  from sklearn.cluster import AgglomerativeClustering
8
  from sklearn.metrics.pairwise import euclidean_distances
9
+ import time
10
 
11
  app = FastAPI()
12
 
 
34
 
35
  # Base score starts at 10
36
  # We penalize for high variation (chaos) and raw distance
37
+ penalty = (variation_coefficient * 6.0) + (mean_dist * 0.1)
38
 
39
  score = 10.0 - penalty
40
  return max(-1.0, min(10.0, score))
 
98
  # --- VISUALIZATION LOGIC ---
99
  def generate_plot(mode='global', scenario='split'):
100
  # Generate 128-dimension vectors
101
+ np.random.seed(int(time.time() * 1000)
102
+ ) # Consistent seed for demo
103
 
104
  if scenario == 'split':
105
  # Create two dense islands far apart
106
  # Island 1: centered at 0
107
+ c1 = np.random.normal(0, 0.5, (100, 128))
108
  # Island 2: centered at 10 (In 128D, distance approx sqrt(128*100) = ~113 units away)
109
+ c2 = np.random.normal(8, 0.5, (100, 128))
110
  # Noise: Random scatter
111
  noise = np.random.uniform(-5, 15, (10, 128))
112
  data = np.vstack([c1, c2, noise])