-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify adding new data distributions (#12)
* more reuse in kernel management * refactored PC and adapted tests * fix small bug * update readme and benchmarks * Update gpucsl/pc/pc.py Co-authored-by: PeterTsayun <40639972+PeterTsayun@users.noreply.github.com> * Update gpucsl/pc/pc.py Co-authored-by: PeterTsayun <40639972+PeterTsayun@users.noreply.github.com> * requested changes * put vaildation into extra file * update docu * added examples and adapted documentation * Update docs/Public-api.md Co-authored-by: PeterTsayun <40639972+PeterTsayun@users.noreply.github.com> * Update docs/examples/README.md Co-authored-by: PeterTsayun <40639972+PeterTsayun@users.noreply.github.com> * apply linting * remove pc from docs Co-authored-by: PeterTsayun <40639972+PeterTsayun@users.noreply.github.com>
- Loading branch information
1 parent
110e121
commit 833bca9
Showing
21 changed files
with
480 additions
and
319 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
All examples in these files are executable from the project main directory. | ||
For the examples to work it is assumed that the `data` directory exists in the project's main directory and it contains `alarm/alarm.csv` and `coolingData/coolingData.csv`. | ||
(To get the data files execute the `download-data.sh` script from the scripts folder - see `download-data.sh` section in `README.md` in the top directory for details) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import pandas as pd | ||
from gpucsl.pc.pc import DiscretePC | ||
|
||
samples = pd.read_csv("data/alarm/alarm.csv", header=None).to_numpy() | ||
max_level = 3 | ||
alpha = 0.05 | ||
|
||
( | ||
( | ||
directed_graph, | ||
separation_sets, | ||
pmax, | ||
discover_skeleton_runtime, | ||
edge_orientation_runtime, | ||
discover_skeleton_kernel_runtime, | ||
), | ||
pc_runtime, | ||
) = ( | ||
DiscretePC(samples, max_level, alpha).set_distribution_specific_options().execute() | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import pandas as pd | ||
from gpucsl.pc.pc import GaussianPC | ||
import networkx as nx | ||
from gpucsl.pc.edge_orientation.edge_orientation import orient_edges | ||
|
||
samples = pd.read_csv("data/coolingData/coolingData.csv", header=None).to_numpy() | ||
max_level = 3 | ||
alpha = 0.05 | ||
|
||
# you will need the skeleton and separation sets from the skeleton discovery | ||
|
||
pc = GaussianPC(samples, max_level, alpha).set_distribution_specific_options() | ||
|
||
((skeleton, separation_sets, _, _), _) = pc.discover_skeleton() | ||
|
||
# do stuff | ||
|
||
(directed_graph, edge_orientation_time) = orient_edges( | ||
nx.DiGraph(skeleton), separation_sets | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import pandas as pd | ||
from gpucsl.pc.pc import GaussianPC | ||
|
||
samples = pd.read_csv("data/coolingData/coolingData.csv", header=None).to_numpy() | ||
max_level = 3 | ||
alpha = 0.05 | ||
|
||
( | ||
( | ||
directed_graph, | ||
separation_sets, | ||
pmax, | ||
discover_skeleton_runtime, | ||
edge_orientation_runtime, | ||
discover_skeleton_kernel_runtime, | ||
), | ||
pc_runtime, | ||
) = ( | ||
GaussianPC(samples, max_level, alpha).set_distribution_specific_options().execute() | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import pandas as pd | ||
from gpucsl.pc.discover_skeleton_gaussian import discover_skeleton_gpu_gaussian | ||
from gpucsl.pc.helpers import init_pc_graph | ||
from gpucsl.pc.pc import GaussianPC | ||
|
||
samples = pd.read_csv("data/coolingData/coolingData.csv", header=None).to_numpy() | ||
max_level = 3 | ||
alpha = 0.05 | ||
|
||
# way 1: use the PC class | ||
|
||
pc = GaussianPC(samples, max_level, alpha).set_distribution_specific_options() | ||
|
||
( | ||
(skeleton, separation_sets, pmax, computation_time), | ||
discovery_runtime, | ||
) = pc.discover_skeleton() | ||
|
||
|
||
# way 2: call the discover method yourself | ||
|
||
graph = init_pc_graph(samples) | ||
num_variables = samples.shape[1] | ||
num_observations = samples.shape[0] | ||
|
||
( | ||
(skeleton, separation_sets, pmax, computation_time), | ||
discovery_runtime, | ||
) = discover_skeleton_gpu_gaussian( | ||
graph, samples, None, alpha, max_level, num_variables, num_observations | ||
) |
Oops, something went wrong.