APEXPRIT commited on
Commit
b3f3a88
·
verified ·
1 Parent(s): 1fcb4a0

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. retrain_on_server.py +12 -27
retrain_on_server.py CHANGED
@@ -1,38 +1,23 @@
1
  import os
2
- import argparse
3
- import pandas as pd
4
- import numpy as np
5
- from src.model.classifier import DeceptionClassifier
6
- from src.utils.config import get_default_config
7
 
8
  def main():
9
  print("🚀 STARTING ON-SERVER MODEL RETRAINING...")
10
 
11
- # 1. Generate local synthetic data (since we're on the server)
12
- from create_pretrained_model import generate_synthetic_data, train_classifier, train_subject_calibrator
13
-
14
- config = get_default_config()
15
  output_dir = "./models"
16
  os.makedirs(output_dir, exist_ok=True)
17
 
18
- print("1. Generating fresh synthetic training data...")
19
- df = generate_synthetic_data(num_samples=2000)
20
-
21
- print("2. Training classifier with local scikit-learn version...")
22
- # Use a slightly more "sensitive" training approach
23
- classifier = DeceptionClassifier(config.model)
24
- X = df.drop(['is_deceptive', 'subject_id'], axis=1)
25
- y = df['is_deceptive']
26
-
27
- classifier.train(X, y)
28
-
29
- print("3. Saving perfectly matched model...")
30
- classifier.save(os.path.join(output_dir, "deception_model.pkl"))
31
-
32
- # Save feature names for reference
33
- import json
34
- with open(os.path.join(output_dir, "feature_names.json"), 'w') as f:
35
- json.dump(classifier.feature_names, f)
36
 
37
  print("✅ RETRAINING COMPLETE! Model is now perfectly synced with server versions.")
38
 
 
1
  import os
2
+ import sys
3
+ from create_pretrained_model import create_pretrained_model
 
 
 
4
 
5
  def main():
6
  print("🚀 STARTING ON-SERVER MODEL RETRAINING...")
7
 
8
+ # Define output directory
 
 
 
9
  output_dir = "./models"
10
  os.makedirs(output_dir, exist_ok=True)
11
 
12
+ # Run the model creation process which:
13
+ # 1. Generates synthetic data
14
+ # 2. Trains the classifier
15
+ # 3. Saves it in the server's native format (fixing version mismatch)
16
+ create_pretrained_model(
17
+ output_dir=output_dir,
18
+ n_samples=2000,
19
+ random_state=42
20
+ )
 
 
 
 
 
 
 
 
 
21
 
22
  print("✅ RETRAINING COMPLETE! Model is now perfectly synced with server versions.")
23