Sadjad Alikhani commited on
Commit
7fe40fc
·
verified ·
1 Parent(s): 8138582

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -14
app.py CHANGED
@@ -339,28 +339,16 @@ def plot_confusion_matrix(y_true, y_pred, title):
339
  return Image.open(f"{title}.png")
340
 
341
  def identical_train_test_split(output_emb, output_raw, labels, train_percentage):
342
- N = output_emb.shape[0] # Get the total number of samples
343
-
344
- # Generate the indices for shuffling and splitting
345
- indices = torch.randperm(N) # Randomly shuffle the indices
346
-
347
- # Calculate the split index for test (10% of the data)
348
  test_split_index = int(N * 0.20)
349
-
350
- # Test indices (first 10% of the data)
351
  test_indices = indices[:test_split_index]
352
-
353
- # Remaining indices for training
354
  remaining_indices = indices[test_split_index:]
355
-
356
- # Calculate the split index for training from the remaining 90%
357
  train_split_index = int(len(remaining_indices) * train_percentage / 100)
358
  print(f'Training Size: {train_split_index} out of remaining {len(remaining_indices)}')
359
 
360
- # Train indices (based on the provided percentage from the remaining 90%)
361
  train_indices = remaining_indices[:train_split_index]
362
 
363
- # Select the same indices from both output_emb and output_raw
364
  train_emb = output_emb[train_indices]
365
  test_emb = output_emb[test_indices]
366
 
 
339
  return Image.open(f"{title}.png")
340
 
341
  def identical_train_test_split(output_emb, output_raw, labels, train_percentage):
342
+ N = output_emb.shape[0]
343
+ indices = torch.randperm(N)
 
 
 
 
344
  test_split_index = int(N * 0.20)
 
 
345
  test_indices = indices[:test_split_index]
 
 
346
  remaining_indices = indices[test_split_index:]
 
 
347
  train_split_index = int(len(remaining_indices) * train_percentage / 100)
348
  print(f'Training Size: {train_split_index} out of remaining {len(remaining_indices)}')
349
 
 
350
  train_indices = remaining_indices[:train_split_index]
351
 
 
352
  train_emb = output_emb[train_indices]
353
  test_emb = output_emb[test_indices]
354