Skip to content

Commit

Permalink
WIP: add benchmark setup for Ridge
Browse files Browse the repository at this point in the history
  • Loading branch information
fcharras committed Jan 11, 2024
1 parent 6101c27 commit 8f06185
Show file tree
Hide file tree
Showing 9 changed files with 863 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ jobs:
run: |
python ./benchmarks/kmeans/consolidate_result_csv.py ./benchmarks/kmeans/results.csv --check-csv
python ./benchmarks/pca/consolidate_result_csv.py ./benchmarks/pca/results.csv --check-csv
python ./benchmarks/ridge/consolidate_result_csv.py ./benchmarks/ridge/results.csv --check-csv
3 changes: 3 additions & 0 deletions .github/workflows/sync_benchmark_files_to_gsheet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ jobs:
run: |
python ./benchmarks/kmeans/consolidate_result_csv.py ./benchmarks/kmeans/results.csv --check-csv
python ./benchmarks/pca/consolidate_result_csv.py ./benchmarks/pca/results.csv --check-csv
python ./benchmarks/ridge/consolidate_result_csv.py ./benchmarks/pca/results.csv --check-csv
echo "$GSPREAD_SERVICE_ACCOUNT_AUTH_KEY" > service_account.json
python ./benchmarks/kmeans/consolidate_result_csv.py ./benchmarks/kmeans/results.csv \
--sync-to-gspread --gspread-url $GSPREAD_URL --gspread-auth-key ./service_account.json
python ./benchmarks/pca/consolidate_result_csv.py ./benchmarks/pca/results.csv \
--sync-to-gspread --gspread-url $GSPREAD_URL --gspread-auth-key ./service_account.json
python ./benchmarks/ridge/consolidate_result_csv.py ./benchmarks/pca/results.csv \
--sync-to-gspread --gspread-url $GSPREAD_URL --gspread-auth-key ./service_account.json
2 changes: 2 additions & 0 deletions .github/workflows/test_cpu_benchmarks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,5 @@ jobs:
PYTHONPATH=$PYTHONPATH:$(realpath ../../kmeans_dpcpp/) benchopt run --no-plot -l -d Simulated_correlated_data[n_samples=1000,n_features=14]
cd ../pca
benchopt run --no-plot -l -d Simulated_correlated_data[n_samples=100,n_features=100]
cd ../ridge
benchopt run --no-plot -l -d Simulated_correlated_data[n_samples=100,n_features=100] # TODO add relevant parameters
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ hardware.
Benchmarks are currently available for the following algorithms:
- [k-means](https://github.com/soda-inria/sklearn-engine-benchmarks/tree/main/benchmarks/kmeans)
- [PCA](https://github.com/soda-inria/sklearn-engine-benchmarks/tree/main/benchmarks/pca)
- [Ridge](https://github.com/soda-inria/sklearn-engine-benchmarks/tree/main/benchmarks/pca)

Here is a (non-exhaustive) list of libraries that are compared in the benchmarks:
- [scikit-learn](https://scikit-learn.org/stable/index.html)
Expand Down
11 changes: 6 additions & 5 deletions benchmarks/kmeans/objective.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,25 @@ def set_data(self, X, **dataset_parameters):
self.X = X
dtype = X.dtype

if self.init == "random" or self.sample_weight == "random":
rng = np.random.default_rng(self.random_state)

if self.sample_weight == "None":
sample_weight = None
elif self.sample_weight == "unary":
sample_weight = np.ones(len(X), dtype=dtype)
elif self.sample_weight == "random":
sample_weight = rng.random(size=len(X)).astype(dtype)
rng_sample_weight = np.random.default_rng(
dataset_parameters["sample_weight"] + 1
)
sample_weight = rng_sample_weight.random(size=len(X)).astype(dtype)
else:
raise ValueError(
"Expected 'sample_weight' parameter to be either equal to 'None', "
f"'unary' or 'random', but got {sample_weight}."
)

if self.init == "random":
rng_init = np.random.default_rng(self.random_state)
init = np.array(
rng.choice(X, self.n_clusters, replace=False), dtype=X.dtype
rng_init.choice(X, self.n_clusters, replace=False), dtype=X.dtype
)
elif self.init == "k-means++":
init = self.init
Expand Down
Loading

0 comments on commit 8f06185

Please sign in to comment.