Skip to content

Commit

Permalink
Good sklearn
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhuoxuan-Zhang committed Oct 23, 2024
1 parent e3268a6 commit 7fa9977
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion sklearn/inputs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
cd "$(realpath $(dirname "$0"))"
mkdir -p tmp
mkdir -p result
mkdir -p inputs

# Currently just dumped the entire dataset, but ideally we actually download it
/usr/bin/env python3 -c "from sklearn.datasets import fetch_kddcup99; fetch_kddcup99(data_home=\"inputs\", percent10=False, download_if_missing=True)"
7 changes: 5 additions & 2 deletions sklearn/run.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/bin/bash

PYTHON="python3"
DIR=$PWD
SCRIPTS=$DIR/scripts
OUT=${OUT:-$PWD/result}
TMP=${TMP:-$PWD/tmp}
#export tmp to env
export TMP
SCRIPTS=${SCRIPTS:-$PWD/scripts}

# Ideally, we'll move on to piping rather than writing to a file
MODEL=$TMP/model.obj
Expand Down
3 changes: 2 additions & 1 deletion sklearn/scripts/adjust_coef.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@
else:
model.intercept_ = np.zeros(n_classes)

with open(destination, 'wb') as file:
filepath = os.path.join(tmp, 'trained_model.obj')
with open(filepath, 'wb') as file:
pickle.dump(model, file)
2 changes: 1 addition & 1 deletion sklearn/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

export PASH_SPEC_TOP=${PASH_SPEC_TOP:-$(git rev-parse --show-toplevel --show-superproject-working-tree)}

benchmark_dir="$PASH_SPEC_TOP/report/benchmarks/sklearn"
benchmark_dir="sklearn"

cd "$(realpath $(dirname "$0"))"
mkdir -p "$PASH_SPEC_TOP/report/resources/sklearn"
Expand Down
2 changes: 1 addition & 1 deletion sklearn/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
control_model.fit(X_train, y_train)
control_score = control_model.score(X_test, y_test)

with open('result/trained_model.obj', 'rb') as file:
with open('tmp/trained_model.obj', 'rb') as file:
experiment_model = pickle.load(file)
experiment_score = experiment_model.score(X_test, y_test)

Expand Down

0 comments on commit 7fa9977

Please sign in to comment.