From ef814df7ff24c3758cbf00a12ac0a75bee43e54c Mon Sep 17 00:00:00 2001 From: Pranjal Pandey Date: Sat, 7 Oct 2023 20:48:05 +0530 Subject: [PATCH 1/2] add command line arguments --- digits.py | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/digits.py b/digits.py index cc3d70a..6e185c8 100644 --- a/digits.py +++ b/digits.py @@ -8,6 +8,7 @@ from utils import preprocess_data, tune_hparams, split_train_dev_test,read_digits,predict_and_eval from joblib import load import pandas as pd +import argparse, sys # The digits dataset consists of 8x8 pixel images of digits. The images attribute of the dataset stores 8x8 arrays of grayscale values for each image. We will use these arrays to visualize the first 4 images. The target attribute of the dataset stores the digit each image represents and this is included in the title of the 4 plots below. # Note: if we were working from image files (e.g., ‘png’ files), we would load them using matplotlib.pyplot.imread. @@ -16,6 +17,25 @@ x,y = read_digits() +parser=argparse.ArgumentParser() + +parser.add_argument("--runs", help="number of runs") +parser.add_argument("--test_sizes", help="comma sprated value of test sizes") +parser.add_argument("--dev_sizes", help="comma sprated value of dev sizes") +parser.add_argument("--models", help="comma sprated value of models") + +args=parser.parse_args() + +max_runs = int(args.runs) +test_sizes = args.test_sizes.split(',') +test_sizes = [float(i) for i in test_sizes] +dev_sizes = args.dev_sizes.split(',') +dev_sizes = [float(i) for i in dev_sizes] +models = args.models.split(',') +models = [str(i) for i in models] + + + #print("Total number of samples : ", len(x)) #print("(number of samples,length of image,height of image) is:",x.shape) @@ -23,11 +43,11 @@ # test_sizes = [0.1, 0.2, 0.3] # dev_sizes = [0.1, 0.2, 0.3] -test_sizes = [0.2] -dev_sizes = [0.2] +# test_sizes = [0.2] +# dev_sizes = [0.2] results = [] -for i in range(5): +for i in range(max_runs): for test_size in test_sizes: for dev_size in dev_sizes: # 3. Data splitting @@ -47,8 +67,6 @@ max_depth = [5,10,15,20,50,100] classifer_hparam['tree'] = [{'max_depth': depth} for depth in max_depth] - models = ['svm','tree'] - # Predict the value of the digit on the test subset # 6.Predict and Evaluate for model in models: From 88b9233e8c6b3096c8627191e3937b1770b861af Mon Sep 17 00:00:00 2001 From: Pranjal Pandey Date: Sat, 7 Oct 2023 20:51:38 +0530 Subject: [PATCH 2/2] fix actions --- .github/workflows/action_demo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/action_demo.yml b/.github/workflows/action_demo.yml index e36f741..d83e8e8 100644 --- a/.github/workflows/action_demo.yml +++ b/.github/workflows/action_demo.yml @@ -21,7 +21,7 @@ jobs: - name: Install dep run: pip3 install --no-cache-dir -r requirements.txt - name: Run code - run: python3 digits.py + run: python3 digits.py --runs 4 --test_sizes 0.2,0.3 --dev_sizes 0.2 --models svm,tree - name: Run test cases run: python3 -m pytest - run: echo "This statment is added to echo as part of quiz question 1"