-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Complete evaluation and add experiments
- Loading branch information
Showing
17 changed files
with
275 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[flake8] | ||
exclude = .git | ||
max-line-length = 90 | ||
per-file-ignores = | ||
tests/test_*.py:F401,F403,F405,F811 | ||
__init__.py:F401,E402 |
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 |
---|---|---|
@@ -1,6 +1,11 @@ | ||
/conda/ | ||
/dist/ | ||
__pycache__/ | ||
.coverage | ||
.ipynb_checkpoints/ | ||
.pytest_cache/ | ||
.snakemake/ | ||
.coverage* | ||
.DS_Store | ||
*.pyc | ||
*.csv | ||
*.ipynb |
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,34 @@ | ||
{ | ||
"files.trimTrailingWhitespace": true, | ||
"files.trimFinalNewlines": true, | ||
"files.watcherExclude": { | ||
"**/conda/**": true, | ||
"**/__pycache__/**": true, | ||
"**/.ipynb_checkpoints/**": true, | ||
"**/.pytest_cache/**": true, | ||
"**/.snakemake/**": true, | ||
"**/.coverage*": true | ||
}, | ||
"files.exclude": { | ||
"**/conda/**": true, | ||
"**/__pycache__/**": true, | ||
"**/.ipynb_checkpoints/**": true, | ||
"**/.pytest_cache/**": true, | ||
"**/.snakemake/**": true, | ||
"**/.coverage*": true | ||
}, | ||
"editor.formatOnSave": true, | ||
"python.defaultInterpreterPath": "./conda/bin/python", | ||
"python.testing.pytestEnabled": true, | ||
"python.analysis.typeCheckingMode": "off", | ||
"python.analysis.diagnosticSeverityOverrides": { | ||
"reportShadowedImports": "none" | ||
}, | ||
"[python]": { | ||
"editor.defaultFormatter": "ms-python.black-formatter", | ||
"editor.formatOnPaste": false, | ||
"editor.codeActionsOnSave": { | ||
"source.organizeImports": true | ||
} | ||
} | ||
} |
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,33 @@ | ||
from argparse import ArgumentParser, Namespace | ||
from pathlib import Path | ||
|
||
import pandas as pd | ||
import yaml | ||
from sklearn.metrics import mean_squared_error, r2_score | ||
|
||
|
||
def parse_args() -> Namespace: | ||
parser = ArgumentParser() | ||
parser.add_argument("--true", type=Path, required=True) | ||
parser.add_argument("--pred", type=Path, required=True) | ||
parser.add_argument("--output", type=Path, required=True) | ||
return parser.parse_args() | ||
|
||
|
||
def main(args: Namespace) -> None: | ||
true = pd.read_csv(args.true, index_col=0) | ||
pred = pd.read_csv(args.pred, index_col=0) | ||
|
||
args.output.parent.mkdir(parents=True, exist_ok=True) | ||
with args.output.open("w") as f: | ||
yaml.dump( | ||
{ | ||
"r2": r2_score(true, pred).item(), | ||
"mse": mean_squared_error(true, pred).item(), | ||
}, | ||
f, | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
main(parse_args()) |
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,24 @@ | ||
suppressPackageStartupMessages({ | ||
library(dplyr) | ||
library(ggplot2) | ||
library(reshape2) | ||
}) | ||
|
||
|
||
main <- function(snakemake) { | ||
df <- read.csv(snakemake@input[[1]]) %>% | ||
transmute(Method = method, Dataset = dataset, MSE = mse, R2 = r2) %>% | ||
melt( | ||
value.vars = c("MSE", "R2"), | ||
value.name="Score", | ||
variable.name="Metric", | ||
) | ||
gp <- ggplot(df, aes(x = Method, y = Score, fill = Method)) + | ||
geom_bar(stat = "identity") + | ||
facet_grid(Metric ~ Dataset, labeller = label_both, scales = "free_y") + | ||
theme_bw() | ||
ggsave(snakemake@output[[1]], gp, width = 7, height = 7) | ||
} | ||
|
||
|
||
main(snakemake) |
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,30 @@ | ||
from argparse import ArgumentParser, Namespace | ||
from pathlib import Path | ||
|
||
import numpy as np | ||
import pandas as pd | ||
|
||
|
||
def parse_args() -> Namespace: | ||
parser = ArgumentParser() | ||
parser.add_argument("--train-x", type=Path, required=True) | ||
parser.add_argument("--train-y", type=Path, required=True) | ||
parser.add_argument("--test-x", type=Path, required=True) | ||
parser.add_argument("--test-y", type=Path, required=True) | ||
return parser.parse_args() | ||
|
||
|
||
def main(args: Namespace) -> None: | ||
train_y = pd.read_csv(args.train_y, index_col=0) | ||
test_x = pd.read_csv(args.test_x, index_col=0) | ||
mean, std = train_y.mean().iloc[0], train_y.std().iloc[0] | ||
test_y = pd.DataFrame( | ||
np.random.randn(test_x.shape[0]) * std + mean, | ||
index=test_x.index, | ||
) | ||
args.test_y.parent.mkdir(parents=True, exist_ok=True) | ||
test_y.to_csv(args.test_y) | ||
|
||
|
||
if __name__ == "__main__": | ||
main(parse_args()) |
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,37 @@ | ||
from argparse import ArgumentParser, Namespace | ||
from pathlib import Path | ||
|
||
import pandas as pd | ||
from sklearn.model_selection import train_test_split | ||
|
||
|
||
def parse_args() -> Namespace: | ||
parser = ArgumentParser() | ||
parser.add_argument("--input-x", type=Path, required=True) | ||
parser.add_argument("--input-y", type=Path, required=True) | ||
parser.add_argument("--output-train-x", type=Path, required=True) | ||
parser.add_argument("--output-train-y", type=Path, required=True) | ||
parser.add_argument("--output-test-x", type=Path, required=True) | ||
parser.add_argument("--output-test-y", type=Path, required=True) | ||
return parser.parse_args() | ||
|
||
|
||
def main(args: Namespace) -> None: | ||
x = pd.read_csv(args.input_x, index_col=0) | ||
y = pd.read_csv(args.input_y, index_col=0) | ||
|
||
train_x, test_x, train_y, test_y = train_test_split(x, y, test_size=0.2) | ||
|
||
args.output_train_x.parent.mkdir(parents=True, exist_ok=True) | ||
args.output_train_y.parent.mkdir(parents=True, exist_ok=True) | ||
args.output_test_x.parent.mkdir(parents=True, exist_ok=True) | ||
args.output_test_y.parent.mkdir(parents=True, exist_ok=True) | ||
|
||
train_x.to_csv(args.output_train_x) | ||
train_y.to_csv(args.output_train_y) | ||
test_x.to_csv(args.output_test_x) | ||
test_y.to_csv(args.output_test_y) | ||
|
||
|
||
if __name__ == "__main__": | ||
main(parse_args()) |
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
Oops, something went wrong.