Skip to content

Commit

Permalink
Updated readmes
Browse files Browse the repository at this point in the history
  • Loading branch information
svshivapuja committed Jul 26, 2021
1 parent 1b03817 commit 2f78c3b
Show file tree
Hide file tree
Showing 69 changed files with 26 additions and 77 deletions.
10 changes: 5 additions & 5 deletions binning/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ First put your dataset txt in form of ```image_name,image_count``` in a ```.txt`
To start the training run

```
python train.py -d ./dataset_txt/Train_nwpu.txt
python train.py -d ./dataset_txt/Train_nwpu.txt -f multinomial
```

If you want to get bins on your dataset, change the -d argument to that path itself.
If you want to get bins on your dataset, change the ```-d``` argument to that path itself. The ```-f``` argument helps choose between the fitness functions (```multinomial,poisson```).

### Step 3

After training (Step 2) there are best files generated in the ```select_best``` folder. To print out the top two best binning configurations, run the fowllowing code
After training (Step 2) there are best files generated in the ```select_best``` folder. To print out the top two best binning configurations, run the following code

```
python generate_bins.py
python generate_bins.py -d ./dataset_txt/Train_nwpu.txt -f multinomial
```

Here ```-d``` corresponds to dataset and ```-f``` corresponds to fitness function.

The folder structure of the codes in this folder is:
```
Expand Down
Binary file modified binning/__pycache__/bayesian_blocks.cpython-38.pyc
Binary file not shown.
Binary file modified binning/__pycache__/select_best.cpython-38.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion binning/bayesian_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def bayesian_blocks(t, x=None, sigma=None,
break
ind = last[ind - 1]
change_points = change_points[i_cp:]
print("bins",edges[change_points])
# print("bins",edges[change_points])
return edges[change_points]

# X_train = [1,2,3,4,4,5,5,5,5,6,7,8,0,0,0,0,2,3,4,4,5,5,5,5,6,7,8,0,0,0,0]
Expand Down
16 changes: 14 additions & 2 deletions binning/generate_bins.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
from load_data import load_data,load_data_patch
from select_best import best_2
import os
import glob
import argparse


parser = argparse.ArgumentParser()
# Adding optional argument
parser.add_argument("-d", "--dataset", help = "Give dataset path in txt",type=str,default="./dataset_txt/Train_nwpu.txt")
parser.add_argument("-f", "--fitness_function", help = "Select fitness function",type=str,default="multinomial")

# Read arguments from command line
args = parser.parse_args()

test_ratio_arr=[]
files = glob.glob('./select_best/*')
for f in files:
test_ratio_arr.append(f)
# run this code after running train.py
# this code prins out top 2 bins for each fitness fucntion
# and its corresponding gamma values
fitness_funct='multinomial'
t = load_data(path=[r'Val_new.txt'])
fitness_funct=args.fitness_function
t = load_data(path=[args.dataset])
# t = load_data_patch(path=['crops_bl_nwpu.txt'])
# test_ratio_arr =[2053,4106,5133]
best_2(t,fitness_funct=fitness_funct,test_ratio_arr=test_ratio_arr,gammas=[0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9])
Expand Down
4 changes: 2 additions & 2 deletions binning/select_best.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def best_2(data,fitness_funct,test_ratio_arr,gammas):
# if fitness_funct=="poisson":
# path ="./select_best/poi_mu_sig_"+str(i)+".json"
path = i
print("path",i)
# print("path",i)
with open(path, 'r') as fp:
testt = json.load(fp)

Expand All @@ -92,6 +92,6 @@ def best_2(data,fitness_funct,test_ratio_arr,gammas):
# bins for entire data based on the gamma values
print("Best Bins for the corresponding values of prior are ")
for i in top_2:
print(list(bayesian_blocks(data,fitness=fitness_funct,gamma=i)))
print(" Gamma : ",i," bins : ",list(bayesian_blocks(data,fitness=fitness_funct,gamma=i)))


1 change: 0 additions & 1 deletion binning/select_best/mln_mu_sig_340.json

This file was deleted.

1 change: 0 additions & 1 deletion binning/select_best/mln_mu_sig_681.json

This file was deleted.

1 change: 0 additions & 1 deletion binning/test_jsons/test1124.0_0.1.json

This file was deleted.

1 change: 0 additions & 1 deletion binning/test_jsons/test1124.0_0.2.json

This file was deleted.

Loading

0 comments on commit 2f78c3b

Please sign in to comment.