forked from jimthompson5802/gh_copilot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ludwig_training.py
32 lines (26 loc) · 921 Bytes
/
ludwig_training.py
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
import pandas as pd # Commentary: added import
from ludwig.api import LudwigModel # Commentary: added import
# read csv file into pandas dataframe
df = pd.read_csv('data.csv')
# define Ludwig config dictionary
config = {
# define 4 numerical input features
'input_features': [
{'name': 'input_feat_1', 'type': 'numerical'},
{'name': 'input_feat_2', 'type': 'numerical'},
{'name': 'input_feat_3', 'type': 'numerical'},
{'name': 'input_feat_4', 'type': 'numerical'},
],
# define 1 numerical output feature
'output_features': [
{'name': 'target', 'type': 'numerical'},
],
# train for 50 epochs, batch size of 64 and learning rate of 0.01
'training': {'epochs': 50, 'batch_size': 64, 'learning_rate': 0.01},
}
# defin Ludwig model
model = LudwigModel(config)
# train model
train_stats = model.train(data_df=df)
# save model
model.save('model')