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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
# **Agentic Machine Learning Engineer (Traditional ML Engineering) - Qwen3-Coder-30B-A3B-Instruct**

#### Note 1: Do not upload confidential, regulated, proprietary, customer, or personally identifiable production data into a public Hugging Face Space

#### Note 2: This project is an automated traditional machine learning engineering experiment focused on supervised classification and regression workflows

#### Note 3: This project uses a bounded single-agent function-calling / tool-use loop rather than an unlimited autonomous agent
---
### (this) Bounded Tool-Calling Agent vs Open-Ended Autonomous Agent

**Bounded Tool-Calling Agent (my agent)**

> β€œReason about the task, call the available ML tools when needed, and stop within a controlled number of steps.”

**Open-Ended Autonomous Agent**

> β€œContinue deciding and acting until the broader goal is achieved.”

|                           | Bounded Tool-Calling Agent                          | Open-Ended Autonomous Agent                 |
| ------------------------- | --------------------------------------------------- | ------------------------------------------- |
| **Consistency**           | higher because tools and loop limits are controlled | can vary more between runs                  |
| **Traceability**          | tool calls and observations are exposed             | can become harder to trace across long runs |
| **Resource control**      | hard max agent-step limit                       | may require additional stopping logic       |
| **Decision-making**       | dynamic tool selection within a constrained toolset | can make broader autonomous decisions       |
| **Flexibility**           | controlled                                          | higher                                      |
| **Risk of runaway loops** | reduced through `MAX_AGENT_STEPS` param                   | higher without explicit limits              |

bounded agent **decides which ML operation to perform inside a controlled tool loop**, while a fully open-ended autonomous agent may continue planning and acting without the same fixed execution boundary.

---

### Agent Goals:

* agentic machine learning engineering app for profiling datasets, automated supervised-learning modeling, preprocessing data, training baseline models, comparing algorithms, evaluating real model performance, and generating reusable scikit-learn pipelines

* agent loads a real-world dataset, creates the modeling context, gives a Qwen3-Coder agent access to machine-learning tools, and allows the model to decide which tools to call before producing a final ML assessment and reusable pipeline code

* reduce repetitive setup work when starting supervised machine learning experiments

* ground model-performance claims in actual scikit-learn execution

* expose tool calls and observations for auditability

* demonstrate how an LLM can orchestrate traditional machine learning workflows without performing the numerical fitting itself

---

### Machine Learning Agent - Tasks

Machine Learning Agent can analyze datasets and execute supervised-learning workflows by first understanding the dataset, target, feature types, and modeling objective.

#### Dataset inspection

`inspect_dataset` tool can analyze:

* **Shape**: number of rows and columns
* **Columns**: available feature / target candidates
* **Types**: pandas data types
* **Numeric features**: identified numerical columns
* **Categorical features**: identified categorical columns
* **Nulls**: missing-value information
* **Cardinality**: number of unique values per column
* **Examples**: representative values from each column
* **Targets**: possible prediction-target columns

#### Modeling tasks

the ML workflow can:

* inspect the dataset
* identify a prediction target
* infer classification vs regression
* separate numeric and categorical features
* construct preprocessing transformations
* train baseline estimators
* calculate holdout metrics
* compare compatible algorithms
* inspect feature importance / coefficients where supported
* generate reusable scikit-learn pipeline code
* export fitted pipelines as Joblib artifacts

findings can then be converted into:

```text
 Dataset assessment
        ↓
Recommended modeling setup
        ↓
Preprocessing pipeline
        ↓
 Model training
        ↓
Holdout evaluation
        ↓
Algorithm comparison
        ↓
Reusable scikit-learn pipeline
```

## **What, Why, and General Objectives**

### What

Tool-using Machine Learning Engineering AI agent that profiles datasets, determines supervised-learning setup, trains real scikit-learn models, compares algorithms, evaluates model performance, and generates reusable ML pipelines.

### Why

Machine learning engineers repeatedly perform the same early-stage workflow when starting supervised learning related tasks/projects:

```text
load dataset
     ↓
inspect features + target
     ↓
determine problem type
     ↓
build preprocessing
     ↓
select algorithm
     ↓
train model
     ↓
evaluate performance
     ↓
compare alternatives
     ↓
generate reusable pipeline
```

automating this workflow reduces repetitive machine learning setup, baseline experimentation, preprocessing, evaluation, and pipeline-generation work

### General Objectives

* automate traditional ML modeling

* make model evaluation traceable through tool outputs

* provide a consistent preprocessing and model-training workflow

* compare baseline algorithms quickly

* calculate metrics from real fitted models rather than LLM estimates

* generate reusable scikit-learn pipeline code

* expose tool calls and observations for auditability

* demonstrate how an LLM agent can orchestrate traditional machine learning tools

* keep local ML execution lightweight enough for Hugging Face Spaces

## **LLM / Agent Stack**

* **Agent LLM:** [**Qwen/Qwen3-Coder-30B-A3B-Instruct**](https://huggingface.co/Qwen/Qwen3-Coder-30B-A3B-Instruct)

* **Inference:** `huggingface_hub.InferenceClient`

* **Provider routing:** Hugging Face Inference Providers using `provider="auto"` by default

* **Agent pattern:** bounded single-agent function-calling / tool-use loop

* **Tool routing:** `tool_choice="auto"`

* **Maximum agent steps:** `4` by default

  * **Prevent Infinite Loops:** keeps the agent from repeatedly calling the same tool or getting stuck in an unsuccessful reasoning loop

  * **Control Costs:** limits unnecessary inference-provider requests and token usage

  * **Manage Context Windows:** prevents tool observations from growing indefinitely inside the conversation context

  * **Reduce Latency:** prevents unnecessarily long tool-calling runs

  * **Improve Debuggability:** provides a predictable execution boundary when analyzing the tool trace

* **Local ML execution:** scikit-learn

* **Dataset processing:** pandas

* **Model artifact export:** Joblib

* **Parquet support:** PyArrow

* **Excel support:** OpenPyXL

* **HF sample dataset:** `scikit-learn/adult-census-income`


## **Goal:**

machine learning engineering is not only model generation

a usable supervised ML workflow requires:

* understanding the dataset

* selecting a prediction target

* deciding whether the task is classification or regression

* identifying numerical and categorical features

* preprocessing missing and categorical data

* selecting an estimator

* training models on real data

* calculating ML evaluation metrics

* comparing alternatives options (ML models)

* packaging preprocessing + model logic into reusable code

doing this manually for every new dataset creates repetitive experimentation and setup work.

this Machine Learning Engineering Agent is designed to:

* reduce time spent manually inspecting new datasets

* establish a consistent supervised-learning baseline workflow

* identify numerical and categorical feature requirements

* infer or use a selected classification / regression problem type

* allow the LLM to call machine-learning execution functions

* train real models through scikit-learn

* calculate real holdout evaluation metrics

* compare compatible baseline algorithms

* generate production-oriented scikit-learn pipelines

* export fitted pipelines as Joblib artifacts

* expose the agent's tool calls through a trace for auditability

goal of the app is to combine:

```text
LLM reasoning
      +
ML execution
      +
tool calling
      +
reusable pipeline generation
```

## **Agentic Workflow:**

```text
Dataset
   ↓
 app.py
   ↓
Dataset loading + session state
   ↓
Dataset profile
   ↓
Target selection
   ↓
Problem-type inference / selection
   ↓
Algorithm selection
   ↓
MachineLearningAgent
   ↓
Qwen3-Coder-30B-A3B-Instruct
   ↓
HF InferenceClient
   ↓
tool_choice="auto"
   ↓
Agent decides which ML tool(s) to call
   ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ inspect_dataset                              β”‚
β”‚ recommend_modeling_setup                     β”‚
β”‚ train_candidate_model                        β”‚
β”‚ compare_algorithms                           β”‚
β”‚ generate_pipeline_code                       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
   ↓
Tool observations returned to Qwen
   ↓
Agent evaluates whether another tool is needed
   ↓
Bounded tool-use loop
   ↓
ML assessment
   ↓
Modeling risks
   ↓
Recommended modeling setup
   ↓
Evaluation findings
   ↓
Model comparison
   ↓
Generated scikit-learn pipeline
   ↓
Tool Trace + Diagnostics
```

## **Agent Loop Type**

### **Bounded Single-Agent Function-Calling / Tool-Use Loop**

* agentic pattern where one AI agent can autonomously choose from external ML tools, process their outputs, and repeat the process inside a strictly defined step limit

* unlike open-ended agents that can continue indefinitely, this bounded loop places a hard-fixed limit on execution

* the project uses a **single agent**, not a multi-agent architecture

### **Architecture:**

**observe task β†’ choose tool β†’ execute ML operation β†’ return observation β†’ repeat if needed β†’ synthesize final answer**

the LLM does not directly calculate every machine learning result itself

`MachineLearningAgent` exposes Python / scikit-learn tools to Qwen through Hugging Face function calling

the model receives:

* system instructions

* user machine learning task

* dataset profile

* selected target

* inferred or selected problem type

* selected algorithm

* available tool definitions

the model can then request one or more tool calls.

### Example Input Workflow

```text
Qwen
  ↓
inspect_dataset()
  ↓
dataset profile returned to Qwen
  ↓
recommend_modeling_setup()
  ↓
recommended setup returned to Qwen
  ↓
train_candidate_model()
  ↓
real training metrics returned to Qwen
  ↓
compare_algorithms()
  ↓
algorithm leaderboard returned to Qwen
  ↓
generate_pipeline_code()
  ↓
scikit-learn pipeline code returned to Qwen
  ↓
Final ML response
```

loop is bounded by:

```text
MAX_AGENT_STEPS = 4
```

if the model does not finish within the configured tool loop, the application moves toward final response synthesis rather than allowing unlimited additional tool calls.

this makes the architecture a controlled **bounded tool-calling machine learning agent**.

## **Agent Architecture:**

```text
                         USER
                           β”‚
                           β–Ό
                  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                  β”‚     app.py      β”‚
                  β”‚   Gradio UI     β”‚
                  β”‚ Session state   β”‚
                  β”‚ Dataset loading β”‚
                  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
                           β”‚ task + dataset + target
                           β–Ό
               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
               β”‚ MachineLearningAgent   β”‚
               β”‚       agent.py         β”‚
               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                            β–Ό
               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
               β”‚ Qwen3-Coder 30B A3B    β”‚
               β”‚ HF InferenceClient     β”‚
               β”‚ tool_choice="auto"     β”‚
               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                     decides which tool
                        to execute
                            β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚                   β”‚                    β”‚
        β–Ό                   β–Ό                    β–Ό
 inspect_dataset   recommend_modeling_setup   train_candidate_model
        β”‚                   β”‚                    β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                            β–Ό
                    compare_algorithms
                            β”‚
                            β–Ό
                  generate_pipeline_code
                            β”‚
                            β–Ό
                     Tool observation
                            β”‚
                            β–Ό
               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
               β”‚ Observation added back β”‚
               β”‚    to LLM context      β”‚
               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                            β–Ό
                     More tools needed?
                       /           \
                     yes            no
                      β”‚              β”‚
                      └──────┐       β”‚
                             β”‚       β”‚
                             β–Ό       β–Ό
                         Tool loop   Final synthesis
                                         β”‚
                                         β–Ό
                                  ML assessment
                                  Modeling risks
                                  Recommended setup
                                  Evaluation findings
                                  Model comparison
                                  Pipeline code
                                  Tool trace
```


### **Core Architectural Pattern:**

```text
app.py
   ↓
agent.py
   ↓
MachineLearningAgent
   ↓
Qwen3-Coder + HF tool calling
   ↓
ml_engine.py
   ↓
ML operations
   ↓
tool observations
   ↓
agent.py
   ↓
final ML assessment + pipeline code
```


## **Agent Tools**

### **1. `inspect_dataset`**

analyzes the loaded dataset and returns structural information used by the agent before modeling

typical outputs include:

* source

* row count

* column count

* column names

* feature types

* pandas dtypes

* null information

* unique-value information

* possible target columns

* example values

used when the agent needs to understand the structure of the dataset before recommending a modeling approach

---

### **2. `recommend_modeling_setup`**

evaluates the dataset and selected target to recommend a supervised-learning configuration

recommendation can include:

* target column

* inferred problem type

* candidate algorithms

* dataset characteristics relevant to modeling

* preprocessing expectations

* numerical feature information

* categorical feature information

goal: setup a reasonable baseline modeling configuration before training

---

### **3. `train_candidate_model`**

builds and trains the selected scikit-learn pipeline using the actual loaded dataset

training workflow:

```text
dataset
   ↓
feature / target split
   ↓
train / holdout split
   ↓
numeric preprocessing
   ↓
categorical preprocessing
   ↓
selected estimator
   ↓
  fit
   ↓
holdout prediction
   ↓
holdout evaluation
```

the agent receives metrics produced by the trained model

the agent is instructed not to invent performance values

---

### **4. `compare_algorithms`**

trains compatible baseline algorithms and returns a comparison leaderboard based on real holdout results.

classification, candidate algorithms include:

* Logistic Regression

* Random Forest Classifier

* SGD Classifier

* Linear SVM Classifier

for regression, candidate algorithms include:

* Ridge Regression

* Random Forest Regressor

* SGD Regressor

this allows the agent to compare alternatives using actual evaluation results instead of guessing which model performs best.

---

### **5. `generate_pipeline_code`**

generates reusable scikit-learn pipeline code grounded in:

* loaded dataset

* target column

* problem type

* selected algorithm

* numeric features

* categorical features

generated code includes preprocessing and estimator construction so the workflow can be moved beyond the interactive application.

## **App Fallback**

app also includes a non-agent fallback path.

```text
HF_TOKEN configured?
        β”‚
    β”Œβ”€β”€β”€β”΄β”€β”€β”€β”
    β”‚       β”‚
   yes      no
    β”‚       β”‚
    β–Ό       β–Ό
Qwen agent  fallback
tool loop      β”‚
    β”‚          β”œβ”€β”€ inspect dataset
    β”‚          β”œβ”€β”€ infer modeling setup
    β”‚          β”œβ”€β”€ train baseline model
    β”‚          β”œβ”€β”€ calculate real metrics
    β”‚          └── generate pipeline code
    β”‚
    └──────────┬──────────
               β–Ό
            UI output
```

fallback can also be used if the Hugging Face model request fails.

this means the application can still:

* profile the dataset

* infer a modeling setup

* train the selected baseline

* calculate real holdout metrics

* generate scikit-learn pipeline code

without requiring the Qwen agent to successfully complete the tool-calling workflow.

## **Dataset Support**

app can preload a public Hugging Face dataset or accept a user-uploaded dataset.

uploaded dataset files can include:

1. CSV
2. Parquet
3. JSON
4. JSONL
5. XLSX
6. XLS

the app profiles the dataset before exposing it to the ML workflow.

### **Hugging Face Example Dataset**

default public example dataset:

```text
scikit-learn/adult-census-income
```

default prediction target:

```text
income
```

the sample dataset is intended for binary classification.

users can replace the preloaded example with their own supported dataset through the upload interface.


## **Preprocessing Pipeline**

the scikit-learn workflow separates numerical and categorical processing.

```text
numeric features
      ↓
median imputation
      ↓
scaling when appropriate


categorical features
      ↓
most-frequent imputation
      ↓
one-hot encoding


numeric + categorical features
      ↓
ColumnTransformer
      ↓
selected estimator
      ↓
trained Pipeline
```

this keeps preprocessing and model inference inside the same reusable scikit-learn pipeline.


## **Model Lab**

### **Classification Algorithms**

* Logistic Regression

* Random Forest Classifier

* SGD Classifier

* Linear SVM Classifier

### **Regression Algorithms**

* Ridge Regression

* Random Forest Regressor

* SGD Regressor

the selected algorithm is trained locally through automated scikit-learn pipelines.


## **Evaluation**

### **Classification Metrics**

classification evaluation can include:

* [accuracy](https://www.geeksforgeeks.org/machine-learning/metrics-for-machine-learning-model/)

* [weighted precision](https://www.geeksforgeeks.org/machine-learning/metrics-for-machine-learning-model/)

* [weighted recall](https://www.geeksforgeeks.org/machine-learning/metrics-for-machine-learning-model/)

* [weighted F1](https://www.geeksforgeeks.org/machine-learning/metrics-for-machine-learning-model/)

* [ROC-AUC](https://www.geeksforgeeks.org/machine-learning/metrics-for-machine-learning-model/)

### **Regression Metrics**

regression evaluation includes:

* [**MAE**](https://www.datacamp.com/tutorial/mean-absolute-error)
   * ml regression evaluation metric used to measure the average magnitude of prediction errors in machine learning regression models

* [**RMSE**](https://c3.ai/resources/glossary/data-science/root-mean-square-error-rmse)
   * ml regression evaluation metric used to measure the average magnitude of error in regression machine learning models

* [**RΒ²**](https://www.geeksforgeeks.org/machine-learning/ml-r-squared-in-regression-analysis/)
   * ml regression evaluation metric that measures the goodness of fit for a regression model by showing the proportion of variance in the dependent target variable that is explained by the independent features

**note:** evaluation values are produced by the local scikit-learn execution layer rather than estimated by the LLM.

## **Agent Outputs**

final agent response is designed to contain:

1. ML assessment
2. Modeling risks
3. Recommended modeling setup
4. Evaluation findings
5. Model comparison
6. Pipeline recommendation
7. Generated scikit-learn code
8. Tool trace

app separately exposes structured modeling outputs such as:

* metrics

* leaderboard

* feature importance / coefficients

* pipeline code

* model artifact

* tool trace

* runtime diagnostics


## **Agent Metrics / UI**

### **1. Dataset Workspace**

dataset workspace shows:

**Dataset source**

* Hugging Face example-dataset loading

* local file upload

**Data preview**

* preview of the currently loaded dataset

**Inferred schema / feature information**

* column

* pandas dtype

* numeric / categorical feature information

* null information

* unique-value information

* example values

* possible target columns

---

### **2. Model Lab**

model workspace allows the user to configure:

**Target column**

* selected prediction target

**Problem type**

* classification

* regression

**Algorithmic Selection:**

classification:

* [**Logistic Regression**](https://www.geeksforgeeks.org/machine-learning/understanding-logistic-regression/)
   * classification based supervised ML algorithm used to predict the probability of a categorical target variable

* [**Random Forest Classifier**](https://www.geeksforgeeks.org/random-forest-classifier-using-scikit-learn/)
   * ensemble ML algorithm that builds multiple decision trees and combines their predictions to improve accuracy and reduce overfitting

* [**SGD Classifier**](https://scikit-learn.org/stable/modules/sgd.html)
   * efficient ML estimator that optimizes regularized linear models using a first-order optimization routine. Instead of a distinct machine learning algorithm itself, it represents an optimization methodology used to train traditional linear models like Support Vector Machines (SVM) or Logistic Regression

* [**Linear SVM Classifier**](https://www.geeksforgeeks.org/machine-learning/support-vector-machine-algorithm/)
   * supervised ML algorithm used to sort data into discrete categories by drawing a straight decision boundary

regression:

* [**Ridge Regression**](https://www.geeksforgeeks.org/machine-learning/what-is-ridge-regression/)
   * L2 regularization, is a modified version of linear regression designed to improve a model's stability and prevent overfitting.
   * standard linear regression only focuses on minimizing the difference between predicted and actual values, it often becomes unstable when dealing with highly correlated variables (multicollinearity) or a large number of features. **Ridge regression fixes this by penalizing the model for having excessively large coefficients, forcing them to shrink toward zero.**

* [**Random Forest Regressor**](https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestRegressor.html)
   * ensemble machine learning algorithm used to predict continuous numerical values (e.g. housing prices, temperatures, or stock trends). algorithm works by building multiple independent decision trees at training time and outputting the average prediction of all the individual trees. this method, known as Bootstrap Aggregating (Bagging), reduces overfitting and improves model accuracy

* [**SGD Regressor**](https://www.geeksforgeeks.org/python/stochastic-gradient-descent-regressor/):
   * linear regression model trained using Stochastic Gradient Descent (SGD), an iterative optimization technique that updates model parameters one sample at a time rather than using the entire dataset at once
   * how SGD Regressor Works
      * Sample-by-Sample Updates: estimates the gradient of the loss function using a single randomly chosen data point (or a small mini-batch) per step, then adjusts the weights immediately.
      * Loss Functions: supports ordinary least squares (squared_error), robust regression (huber), and linear support vector regression (epsilon_insensitive).
      * Regularization: includes penalties like L2 (ridge), L1 (lasso), or a mix of both (elasticnet) to shrink weights and avoid overfitting.
      * Key Advantages:
         * Speed with Big Data: trains much faster than traditional batch gradient descent when dealing with massive datasets containing over 10,000 samples.
         * Online Learning: supports partial_fit, meaning it can continuously learn from real-time data streams as new information arrives.
         * Escaping Local Minima: inherent noise in single-sample updates helps the algorithm jump out of shallow local minimums in complex cost surfaces.

app can then expose:

* fitted model metrics

* feature importance or coefficients

* generated pipeline artifact

* generated pipeline code

---

### **3. Model Comparison**

comparison workflow trains compatible baseline estimators and returns a leaderboard using real holdout results.

this provides a comparison layer that the LLM can reference during final synthesis.

the comparison values are derived from actual model execution instead of LLM-generated estimates.

---

### **4. Machine Learning Agent**

agent workspace accepts a natural-language ML engineering task.

Qwen agent can then:

* inspect the dataset

* recommend a modeling setup

* train a candidate model

* compare algorithms

* generate pipeline code

* synthesize findings from tool observations

---

### **5. Tool Trace**

every agent tool invocation is appended to the tool trace.

Example trace:

```json
[
  {
    "tool": "inspect_dataset",
    "arguments": {},
    "result": {
      "rows": 32561,
      "columns": 15
    }
  },
  {
    "tool": "train_candidate_model",
    "arguments": {
      "target": "income",
      "algorithm": "Logistic Regression"
    },
    "result": {
      "metrics": "holdout metrics"
    }
  }
]
```

trace allows the user to analyze / inspect:

* which tools were called

* arguments passed to each tool

* tool observations

* number of tool calls

* modeling operations performed during the agent loop

---

### **6. Diagnostics**

runtime diagnostics can include:

* model

* provider

* HF token configured

* tool-call count

* tools used

* selected algorithm

* problem type

* target

Example:

```json
{
  "model": "Qwen/Qwen3-Coder-30B-A3B-Instruct",
  "provider": "HF automatic routing",
  "hf_token_configured": true,
  "tool_calls": 4,
  "tools_used": [
    "inspect_dataset",
    "recommend_modeling_setup",
    "train_candidate_model",
    "compare_algorithms"
  ],
  "target": "income",
  "problem_type": "classification",
  "algorithm": "Logistic Regression"
}
```

the provider can appear as:

```text
HF automatic routing
```

when a specific inference provider is not explicitly configured.


## **Local ML Execution Model**

model training is performed directly inside the application with scikit-learn.

```text
Loaded dataset
      ↓
pandas DataFrame
      ↓
feature / target split
      ↓
scikit-learn preprocessing
      ↓
scikit-learn estimator
      ↓
local CPU training
      ↓
holdout predictions
      ↓
evaluation metrics
      ↓
Joblib artifact
```

Qwen3-Coder does **not** perform the numerical model fitting itself.

```text
Qwen3-Coder
    ↓
reasoning + tool selection + synthesis

scikit-learn
    ↓
preprocessing + training + prediction + evaluation
```

this keeps model-performance claims grounded in real execution.

## **Machine Learning Execution Separation**

### Qwen3-Coder

responsible for:

* understanding the user's ML task

* selecting appropriate tools

* interpreting dataset observations

* reasoning about modeling risks

* deciding whether additional tools are required

* synthesizing the final response

### scikit-learn

responsible for:

* preprocessing

* train / holdout splitting

* fitting estimators

* making predictions

* calculating evaluation metrics

* model comparison

* fitted-pipeline generation

conceptually:

```text
User task
   ↓
Qwen3-Coder
   ↓
Select ML operation
   ↓
scikit-learn tool
   ↓
Real execution result
   ↓
Qwen3-Coder
   ↓
Interpret result / select next tool
   ↓
Final ML assessment
```

## **File Descriptions**

### **`agent.py`**

main agent implementation.

contains the logic for:

* system prompt

* tool schemas

* `MachineLearningAgent`

* tool dispatch

* fallback

* bounded agent loop

* `HF InferenceClient` requests

* `tool_choice="auto"`

* tool observations

* final response synthesis

architecturally:

```text
agent.py
   ↓
decides WHAT ML action is needed
   ↓
ml_engine.py
   ↓
executes the ML operation
```

---

### **`ml_engine.py`**

machine learning execution layer.

contains:

* dataset loading

* dataset profiling

* target inference

* problem-type inference

* feature separation

* preprocessing construction

* algorithm construction

* train / holdout splitting

* model fitting

* prediction

* evaluation

* model comparison

* feature importance / coefficients

* pipeline-code generation

* Joblib artifact generation

architecturally:

```text
agent.py
   ↓
decides WHAT ML action is needed
   ↓
ml_engine.py
   ↓
executes preprocessing / training / evaluation
   ↓
returns structured observation
```
---

### **`app.py`**

responsibilities include:

* session state

* Hugging Face sample loading

* local dataset upload

* dataset preview

* target controls

* problem-type controls

* algorithm controls

* training callbacks

* comparison callbacks

* generated-code display

* downloadable model artifact

* agent execution

* tool-trace display

* runtime diagnostics

---

### **`config.py`**

agent and application runtime configuration.

controls values such as:

```text
HF_MODEL_ID

HF_PROVIDER

HF_TOKEN

MAX_UPLOAD_MB

MAX_PROFILE_ROWS

MAX_TRAIN_ROWS

MAX_AGENT_STEPS

DEFAULT_MAX_TOKENS

RANDOM_STATE
```

## **Modeling Guardrails**

application separates LLM reasoning from numerical machine learning execution.

Qwen agent can decide which operation should be performed, but:

```text
training

prediction

evaluation

metric calculation

model comparison
```

are handled by scikit-learn execution tools.

this architecture helps prevent fabricated model-performance claims.

additional controls include:

* bounded agent steps

* configurable maximum model tokens

* fixed random state by default

* controlled algorithm list

* maximum training-row limit

* deterministic / structured preprocessing behavior

* fallback execution path

* tool trace

* structured model observations

## **Model Performance Grounding**

the system is designed so the LLM does not invent model metrics.

```text
Dataset
   ↓
scikit-learn model training
   ↓
Prediction
   ↓
Metric calculation
   ↓
Structured tool observation
   ↓
Qwen3-Coder
   ↓
Final interpretation
```

performance values should only be presented as real model results when the associated training / evaluation tool successfully executes.

if the tool does not run successfully, the final response should not claim that a model was trained or evaluated.


## **Model Artifact**

trained preprocessing + estimator pipelines can be serialized through Joblib.

```text
Numeric preprocessing
        +
Categorical preprocessing
        +
Estimator
        ↓
scikit-learn Pipeline
        ↓
fit
        ↓
Joblib serialization
        ↓
.joblib artifact
```

this allows the fitted pipeline to be reused later without manually rebuilding preprocessing and estimator logic.


## **Agent Pattern Workflow:**

```text
Single Agent
    +
Function Calling
    +
Machine Learning Tools
    +
Bounded Tool Loop
    +
Tool Observations
    +
Final LLM Synthesis
```

full execution:

```text
USER
 ↓
Gradio / app.py
 ↓
MachineLearningAgent / agent.py
 ↓
Qwen3-Coder
 ↓
tool_choice="auto"
 ↓
ML Tool
 ↓
ml_engine.py
 ↓
Observation
 ↓
Qwen3-Coder
 ↓
repeat up to MAX_AGENT_STEPS
 ↓
Final ML Assessment
 ↓
Recommended modeling setup
 ↓
Evaluation findings
 ↓
Model comparison
 ↓
Pipeline code
 ↓
Tool Trace
```


# **Core Runtime Components**

## [**scikit-learn**](https://scikit-learn.org/stable/)

### **What it is:**

scikit-learn ml framework used to build preprocessing pipelines, estimators, training workflows, predictions, and evaluation metrics.

### **Why it is used in this project:**

the application needs a real ML execution layer so model-performance values come from fitted models rather than LLM estimates.

### **How it is used here:**

```text
Dataset
   ↓
Preprocessing
   ↓
Estimator
   ↓
scikit-learn Pipeline
   ↓
Training
   ↓
Holdout prediction
   ↓
Holdout evaluation
   ↓
Metrics + fitted artifact
```

scikit-learn is used to:

* build numeric preprocessing

* build categorical preprocessing

* combine transformations through `ColumnTransformer`

* build estimator pipelines

* split datasets into train and holdout sets

* fit models

* generate predictions

* calculate classification metrics

* calculate regression metrics

* compare candidate estimators

* expose supported feature importance / coefficient values

* produce reusable fitted model pipelines


## [**pandas**](https://pandas.pydata.org/docs/)

### **Why it is used in this project:**

the application needs a lightweight in-memory tabular representation before datasets can be profiled and passed into scikit-learn.

### **How it is used here:**

* load supported dataset formats

* hold the active dataset in memory

* inspect columns and pandas data types

* determine numerical and categorical features

* analyze null values

* inspect unique values

* separate prediction target from model features

* provide training data to scikit-learn

workflow:

```text
Uploaded / HF dataset
        ↓
pandas DataFrame
        ↓
Dataset profiling
        ↓
Feature + target identification
        ↓
scikit-learn
```

## **Joblib**

### **What it is:**

Joblib is used to serialize fitted Python machine learning objects

### **Why it is used in this project:**

a trained model is more useful when the complete preprocessing + estimator pipeline can be reused outside the interactive session.

### **How it is used here:**

```text
Fitted preprocessing
        +
Fitted estimator
        ↓
scikit-learn Pipeline
        ↓
Joblib
        ↓
.joblib model artifact
```

after training, the fitted preprocessing + estimator pipeline can be exported as a `.joblib` artifact for later reuse.

## **PyArrow**

### **What it is:**

PyArrow provides support for Apache Arrow / Parquet-based data interchange.

### **How it is used here:**

PyArrow supports loading Parquet datasets into the application's pandas-based dataset workflow.

```text
Parquet file
     ↓
PyArrow support
     ↓
pandas DataFrame
     ↓
ML workflow
```


## **OpenPyXL**

### **What it is:**

OpenPyXL provides Python support for reading Excel workbook formats used by the dataset upload workflow.

### **How it is used here:**

```text
XLSX dataset
     ↓
OpenPyXL
     ↓
pandas
     ↓
Dataset profile
     ↓
ML workflow
```

## **HF Automatic Routing**

### **What it is:**

Hugging Face automatic routing allows `InferenceClient` to route the Qwen model request through an available Hugging Face Inference Provider when a specific provider is not explicitly configured.

### **Why it is used:**

it avoids coupling the application to one inference backend and simplifies deployment of the agent.

### **How it is used here:**

```text
MachineLearningAgent
      ↓
huggingface_hub.InferenceClient
      ↓
provider="auto"
      ↓
Hugging Face Inference Provider
      ↓
Qwen3-Coder
      ↓
tool request or final synthesis
```

model configuration is controlled through:

```text
HF_MODEL_ID

HF_PROVIDER

HF_TOKEN
```

within this project:

* `HF_MODEL_ID` identifies the Qwen model

* `HF_PROVIDER` can configure provider behavior

* automatic routing can be used when a specific backend is not forced

* the routed model performs tool selection, reasoning, and final synthesis

* scikit-learn performs the actual numerical ML operations


## **Training / Evaluation Architecture**

```text
Dataset
    ↓
pandas
    ↓
Feature / target split
    ↓
Train / holdout split
    ↓
ColumnTransformer
    ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Numeric preprocessing      β”‚
β”‚                            β”‚
β”‚ median imputation          β”‚
β”‚ optional scaling           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              +
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Categorical preprocessing  β”‚
β”‚                            β”‚
β”‚ most-frequent imputation   β”‚
β”‚ one-hot encoding           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
    ↓
Estimator
    ↓
scikit-learn Pipeline
    ↓
   fit
    ↓
holdout prediction
    ↓
evaluation metrics
    ↓
Agent observation
```


## **Classification Workflow**

```text
Classification Dataset
        ↓
 Target Selection
        ↓
 Preprocessing
        ↓
Candidate classifier
        ↓
    Training
        ↓
Holdout predictions
        ↓
    accuracy
weighted precision
 weighted recall
   weighted F1
ROC-AUC where supported
        ↓
Agent interpretation
```

supported baseline classifiers include:

* Logistic Regression

* Random Forest Classifier

* SGD Classifier

* Linear SVM Classifier

## **Regression Workflow**

```text
Regression dataset
        ↓
Target selection
        ↓
  Preprocessing
        ↓
Candidate regressor
        ↓
    Training
        ↓
Holdout predictions
        ↓
       MAE
      RMSE
       RΒ²
        ↓
Agent interpretation
```

supported baseline regressors include:

* Ridge Regression

* Random Forest Regressor

* SGD Regressor