kavinkrisher commited on
Commit
1b2c9eb
·
1 Parent(s): a12a898

LLM: provide exact correct code pattern in system prompt for stages 2-4

Browse files
Files changed (1) hide show
  1. gradio_app.py +17 -5
gradio_app.py CHANGED
@@ -1018,14 +1018,26 @@ Available actions:
1018
  {"action_type": "submit", "payload": {}}
1019
 
1020
  CRITICAL RULES:
1021
- - edit_script MUST replace the ENTIRE script
1022
  - After every edit_script, call run_script ONCE to verify
1023
  - If run_script output contains "Accuracy:" with NO error → call submit IMMEDIATELY
1024
  - DO NOT edit again after a clean run — just submit
1025
- - Stage 1: rename 'age_years' → 'age' AND add df.dropna() before any processing
1026
- - Stage 2: StandardScaler must be fit ONLY on X_train (after train_test_split)
1027
- - Stage 3: call scaler.fit_transform AFTER train_test_split
1028
- - Stage 4: add class_weight='balanced' to LogisticRegression; use stratify=y in split"""
 
 
 
 
 
 
 
 
 
 
 
 
1029
 
1030
  def _parse(raw):
1031
  s = raw.find('{')
 
1018
  {"action_type": "submit", "payload": {}}
1019
 
1020
  CRITICAL RULES:
1021
+ - edit_script MUST replace the ENTIRE script (all imports included)
1022
  - After every edit_script, call run_script ONCE to verify
1023
  - If run_script output contains "Accuracy:" with NO error → call submit IMMEDIATELY
1024
  - DO NOT edit again after a clean run — just submit
1025
+
1026
+ STAGE-SPECIFIC FIXES (use LogisticRegression max_iter=1000 unless told otherwise):
1027
+ - Stage 2: StandardScaler must be fit ONLY on X_train (AFTER train_test_split, not before)
1028
+ - Stage 3: move scaler.fit_transform to AFTER train_test_split; use ALL features with X=df.drop(columns=['target']); keep LogisticRegression
1029
+ - Stage 4: add class_weight='balanced' to LogisticRegression; use test_size=0.25, stratify=y
1030
+
1031
+ CORRECT PATTERN for Stages 2-4:
1032
+ X = df.drop(columns=['target'])
1033
+ y = df['target']
1034
+ X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
1035
+ scaler = StandardScaler()
1036
+ X_train = scaler.fit_transform(X_train)
1037
+ X_test = scaler.transform(X_test)
1038
+ clf = LogisticRegression(max_iter=1000, random_state=42)
1039
+ clf.fit(X_train, y_train)
1040
+ print('Accuracy:', clf.score(X_test, y_test))"""
1041
 
1042
  def _parse(raw):
1043
  s = raw.find('{')