Algorithm for best choice
Project description
best-choice
1 - pip Install
pip install best-choice
2 - all function
#library
from bestchoice import Generate
#data
#object,price,importance level
table = [['pants',75,10],
['jeans',50,7],
['shirt',45,8],
['dress',65,7],
['ball',25,5]]
#call function generate
gen = Generate(table)
#all possibilities
for x in gen.list_all():
print(x)
#call function to generate calculation results
#parameters 1 and 2 are columns for calculation
#in this case, the price and importance level
calc = gen.list_results([1,2])
#all calculated results
for x in calc:f
print(x)
#new table after filter
#the first parameter 1 and 2 are index columns
#the second parameter 1 <= 200 filter your new table
new = gen.list_best([1,2],[[1,'<=',200]])
#all filtered results
for x in new:
print(x)
3 - example to find best choice
#library
from bestchoice import Generate
#data
#object,price,importance level
table = [['pants',75,10],
['jeans',50,7],
['shirt',45,8],
['dress',65,7],
['ball',25,5]]
#column for calculation
#in this case, the price and importance level
columns = [1,2]
#index of column importance
importance = 2
#filters where 1 is the price <= 200 dollars
filters = [[1,'<=',200]]
#call function generate
gen = Generate(table)
#get all possibilities
lista = gen.list_all()
#new table after filter
#the first parameter 1 and 2 are index columns
#the second parameter 1 <= price filter your new table
res = gen.list_best(columns,filters)
#saves the best filtered result
top = max([sublist[-1] for sublist in res])
filters.append([importance,'==',top])
#table with new result
new = gen.list_best(columns,filters)
#set index of top values
best = [x[0] for x in new][0]
#result
print(f'This is your best choice: {", ".join([str(x[0]) for x in lista[best]])}')
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
best-choice-0.0.1.tar.gz
(3.1 kB
view details)
Built Distribution
File details
Details for the file best-choice-0.0.1.tar.gz
.
File metadata
- Download URL: best-choice-0.0.1.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b10b29980663d0675d979f8746322af6dbf6852bab3d0c8990df3383f17dc47e |
|
MD5 | 90b1d73b0b5021b1da0d130ca26347c6 |
|
BLAKE2b-256 | f3b2f9b8ea5f2fddc3c7c9af35145d5f6a9a3354239d638eab68770ac0cd0b69 |
File details
Details for the file best_choice-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: best_choice-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4395d1f4b8792a31d7339a41913da6428eb681fe1f77686fb4393a0439cc79b |
|
MD5 | 0b07c2020374e74672f8c31c051c12b3 |
|
BLAKE2b-256 | 7ee785445a9df5a4d8fc6860adbfaceae5284c2af6581eab08ec4123d8bfbe2a |