Skip to content

Commit

Permalink
move unnecessary imports to main
Browse files Browse the repository at this point in the history
  • Loading branch information
xunzheng committed Oct 30, 2018
1 parent f2701e0 commit b1d6760
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions simple_demo.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
"""Demo for the simple 50-line version of notears algorithm.
"""Implementation of the simple 50-line version of NOTEARS algorithm.
Steps:
1. Simulate a random graph with d nodes.
2. Simulate n samples from the SEM.
3. Run the simple notears algorithm.
4. Evaluate the predictive accuracy.
Defines the h function, the augmented Lagrangian, and its gradient.
Each augmented Lagrangian subproblem is minimized by L-BFGS-B from scipy.
Note: this version implements NOTEARS without l1 regularization,
i.e. lambda = 0, hence it requires n >> d.
"""
import numpy as np
import scipy.linalg as slin
import scipy.optimize as sopt
import glog as log
import networkx as nx

import utils


def notears_simple(X: np.ndarray,
Expand Down Expand Up @@ -72,6 +65,10 @@ def _grad(w):


if __name__ == '__main__':
import glog as log
import networkx as nx
import utils

# configurations
n, d = 1000, 10
graph_type, degree, sem_type = 'erdos-renyi', 4, 'linear-gauss'
Expand Down

0 comments on commit b1d6760

Please sign in to comment.