-
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.
Merge pull request #20 from SchmidtDSE/switch-to-ml
Switch to ML
- Loading branch information
Showing
122 changed files
with
28,689 additions
and
2,363 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,7 @@ output/*.db | |
output/*.csv | ||
output/*.db | ||
data_workspace/ | ||
task | ||
.gitpod.yml | ||
r/pipeline.R | ||
r/pipeline.R | ||
__pycache__ |
This file was deleted.
Oops, something went wrong.
Empty file.
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 @@ | ||
python -m luigi --module tasks ExportTask --local-scheduler --workers 1 |
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,47 @@ | ||
import csv | ||
import sys | ||
|
||
USAGE_STR = 'python check_summary_percents.py [file]' | ||
NUM_ARGS = 1 | ||
|
||
|
||
def check(loc): | ||
with open(loc) as f: | ||
results = list(csv.DictReader(f)) | ||
|
||
row = results[0] | ||
assert 'year' in row | ||
assert 'region' in row | ||
assert 'inputProduceFiberMT' in row | ||
assert 'inputProduceResinMT' in row | ||
assert 'inputImportResinMT' in row | ||
assert 'inputImportArticlesMT' in row | ||
assert 'inputImportGoodsMT' in row | ||
assert 'inputImportFiberMT' in row | ||
assert 'inputAdditivesMT' in row | ||
assert 'consumptionAgricultureMT' in row | ||
assert 'consumptionConstructionMT' in row | ||
assert 'consumptionElectronicMT' in row | ||
assert 'consumptionHouseholdLeisureSportsMT' in row | ||
assert 'consumptionPackagingMT' in row | ||
assert 'consumptionTransporationMT' in row | ||
assert 'consumptionTextileMT' in row | ||
assert 'consumptionOtherMT' in row | ||
assert 'eolRecyclingPercent' in row | ||
assert 'eolIncinerationPercent' in row | ||
assert 'eolLandfillPercent' in row | ||
assert 'eolMismanagedPercent' in row | ||
|
||
assert len(results) > 50 | ||
|
||
|
||
def main(): | ||
if len(sys.argv) != NUM_ARGS + 1: | ||
print(USAGE_STR) | ||
sys.exit(1) | ||
|
||
check(sys.argv[1]) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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,5 @@ | ||
rm -r data_workspace | ||
rm -r output | ||
rm -r task | ||
mkdir task | ||
cp job_template.json task/job.json |
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,44 @@ | ||
import os | ||
import re | ||
import sys | ||
|
||
USAGE_STR = 'python clean_filenames.py [directory]' | ||
NUM_ARGS = 1 | ||
|
||
|
||
def clean_name(target_path): | ||
pieces = target_path.split('/') | ||
filename = pieces[-1] | ||
filename_clean = re.sub(r'[^A-Za-z0-9\\.]', '', filename).lower() | ||
pieces[-1] = filename_clean | ||
return '/'.join(pieces) | ||
|
||
|
||
def execute(directory_path): | ||
all_contents = os.listdir(directory_path) | ||
all_contents_expand = map( | ||
lambda x: os.path.join(directory_path, x), | ||
all_contents | ||
) | ||
file_paths = filter(lambda x: os.path.isfile(x), all_contents_expand) | ||
file_paths_rewrite = map( | ||
lambda x: (x, clean_name(x)), | ||
file_paths | ||
) | ||
|
||
for (prior, new) in file_paths_rewrite: | ||
os.rename(prior, new) | ||
|
||
|
||
def main(): | ||
if len(sys.argv) != NUM_ARGS + 1: | ||
print(USAGE_STR) | ||
sys.exit(1) | ||
|
||
directory_path = sys.argv[1] | ||
|
||
execute(directory_path) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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 @@ | ||
[ -f "output/overview_ml.csv" ] || exit 1 | ||
[ -f "output/overview_curve.csv" ] || exit 2 | ||
[ -f "output/overview_naive.csv" ] || exit 3 |
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,73 @@ | ||
import os | ||
import pathlib | ||
|
||
|
||
PARENT_DIR = pathlib.Path(__file__).parent.absolute() | ||
DEFAULT_TASK_DIR = os.path.join(PARENT_DIR, 'task') | ||
SQL_DIR = os.path.join(PARENT_DIR, 'sql') | ||
|
||
PREPROC_FIELD_NAMES = [ | ||
'year', | ||
'region', | ||
'inputProduceFiberMT', | ||
'inputProduceResinMT', | ||
'inputImportResinMT', | ||
'inputImportArticlesMT', | ||
'inputImportGoodsMT', | ||
'inputImportFiberMT', | ||
'inputAdditivesMT', | ||
'netImportArticlesMT', | ||
'netImportFibersMT', | ||
'netImportGoodsMT', | ||
'netImportResinMT', | ||
'consumptionAgricultureMT', | ||
'consumptionConstructionMT', | ||
'consumptionElectronicMT', | ||
'consumptionHouseholdLeisureSportsMT', | ||
'consumptionPackagingMT', | ||
'consumptionTransporationMT', | ||
'consumptionTextileMT', | ||
'consumptionOtherMT', | ||
'eolRecyclingPercent', | ||
'eolIncinerationPercent', | ||
'eolLandfillPercent', | ||
'eolMismanagedPercent' | ||
] | ||
|
||
AUX_FIELD_NAMES = [ | ||
'year', | ||
'region', | ||
'population', | ||
'gdp' | ||
] | ||
|
||
LIFECYCLE_DISTRIBUTIONS = { | ||
'consumptionAgricultureMT': {'mean': 2, 'std': 1}, | ||
'consumptionConstructionMT': {'mean': 35, 'std': 7}, | ||
'consumptionElectronicMT': {'mean': 8, 'std': 2}, | ||
'consumptionHouseholdLeisureSportsMT': {'mean': 3, 'std': 1}, | ||
'consumptionPackagingMT': {'mean': 0.5, 'std': 0.1}, | ||
'consumptionTransporationMT': {'mean': 13, 'std': 3}, | ||
'consumptionTextileMT': {'mean': 5, 'std': 1.5}, | ||
'consumptionOtherMT': {'mean': 5, 'std': 1.5} | ||
} | ||
|
||
EXPORT_FIELD_NAMES = [ | ||
'year', | ||
'region', | ||
'eolRecyclingMT', | ||
'eolLandfillMT', | ||
'eolIncinerationMT', | ||
'eolMismanagedMT', | ||
'consumptionAgricultureMT', | ||
'consumptionConstructionMT', | ||
'consumptionElectronicMT', | ||
'consumptionHouseholdLeisureSportsMT', | ||
'consumptionPackagingMT', | ||
'consumptionTransporationMT', | ||
'consumptionTextileMT', | ||
'consumptionOtherMT', | ||
'netImportsMT', | ||
'netExportsMT', | ||
'domesticProductionMT' | ||
] |
File renamed without changes.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.