@@ -16,10 +16,10 @@ or becomes powerful with `params()`:
1616
1717``` python
1818params().a.b.c.getOrElse(3 ) # 3 (default value)
19- params().a.b.c(3 ) # 3 (shortcut for default value)
19+ params().a.b.c(3 ) # 3 (shortcut for default value)
2020
21- params().a.b.c = 4 # set value to param `a.b.c`
22- params().a.b.c(3 ) # 4 (default value is ignored)
21+ params().a.b.c = 4 # set value to param `a.b.c`
22+ params().a.b.c(3 ) # 4 (default value is ignored)
2323```
2424
2525## Scoped Parameter
@@ -35,8 +35,8 @@ or becomes powerful with `nested scope`:
3535``` python
3636with param_scope(a = 1 ) as hp:
3737 with param_scope(a = 2 ) as hp:
38- hp.a == 2 # True
39- hp.a == 1 # True
38+ hp.a == 2 # True, a=2 for inner scope
39+ hp.a == 1 # True, a=1 for outer scope
4040```
4141
4242even more powerful when using ` param_scope ` in function:
@@ -59,3 +59,17 @@ foo() # 1
5959with param_scope(param1 = 2 ):
6060 foo() # 2
6161```
62+
63+ ## Predefined Parameter
64+ ``` python
65+ @auto_param # convert keyword arguments into hyper parameters
66+ def model_train (X , y , learning_rate = 1.0 , penalty = ' l1' ):
67+ LR = LogisticRegression(C = 1.0 ,
68+ lr = local_param(' learning_rate' ),
69+ penalty = local_param(' penalty' ))
70+ LR .fit(X, y)
71+
72+ # specify predefined parameter using `param_scope`
73+ with param_scope(' model_train.learning_rate=0.01' ):
74+ model_train(X, y)
75+ ```
0 commit comments