Skip to content

Commit

Permalink
add: prepare to merge
Browse files Browse the repository at this point in the history
  • Loading branch information
dtruong46me committed Dec 26, 2023
1 parent b5d4c34 commit b80f69f
Show file tree
Hide file tree
Showing 4 changed files with 4,839 additions and 306 deletions.
56 changes: 56 additions & 0 deletions src/app/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import streamlit as st

laptop_config = {
'Company': ['Apple', 'Best Notebooks', 'Microsoft', 'GIGABYTE', 'Panasonic', 'Samsung', 'LG', 'MSI',
'Asus', 'Acer', 'HP', 'Lenovo',
'Dell'],
'CPU': ['i5', 'i7', 'Ryzen 5', 'Ryzen 7'],
'RAM': ['8GB', '16GB', '32GB'],
'GPU': ['Integrated', 'NVIDIA GTX', 'NVIDIA RTX', 'AMD Radeon'],
'Storage': ['256GB SSD', '512GB SSD', '1TB HDD', '1TB SSD']
}

st.title('Are You Sure Prediction')

st.button("Button thoi :)))")

st.caption("#fromhelaricawithluv")

st.checkbox("I am sure vailon!")

st.code('''def answer_tqk(question: str)
if question == "Are you sure?":
print("I am sure vailon")''')

company = st.selectbox('Brand', laptop_config['Company'])
cpu = st.selectbox('CPU', laptop_config['CPU'])
# ram = st.selectbox('RAM', laptop_config['RAM'])

ram = st.select_slider("RAM", options=['4GB', '8GB', '12GB', '16GB', '32GB', '64GB'])
gpu = st.selectbox('GPU', laptop_config['GPU'])
storage = st.selectbox('Storage', laptop_config['Storage'])

def predict_price(company, cpu, ram, gpu, storage):

return 1500000000


if st.button('Prediction'):
predicted_price = predict_price(company, cpu, ram, gpu, storage)

st.success(f'{predicted_price} USD')

st.camera_input('Camera nek')

st.download_button("Download Button", data="main.py")
st.code('''st.download_button("Download Button", data="str")
# data la string, khi download ve se thanh file txt chua doan string do''')

with st.form("This is form"):
st.write("Ben trong form nek")

st.slider("Slider nek", 15, 20)

st.checkbox("Checkbox nek")

st.form_submit_button("Submit")
25 changes: 16 additions & 9 deletions src/app/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
import pandas as pd
from fuzzywuzzy import fuzz

pd.set_option("display.max_rows", None)
path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
sys.path.insert(0, path)
PARENT_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
PARENT_PATH = os.path.abspath(os.path.join(PARENT_PATH, '..'))
DATA_PATH = os.path.abspath(os.path.join(PARENT_PATH, "data", "raw", "cpu_gpu_mark"))

cpu_df = pd.read_csv(r"C:\python code\Intro to Data Science\laptop-prices-analysis\Data\Raw\Mark\cpu_mark.csv", index_col = 0)
gpu_df = pd.read_csv(r'C:\python code\Intro to Data Science\laptop-prices-analysis\Data\Raw\Mark\gpu_mark.csv', index_col = 0)
CPU_FILENAME = "cpu_mark.csv"
GPU_FILENAME = "gpu_mark.csv"

cpu_df = pd.read_csv(os.path.abspath(os.path.join(DATA_PATH, CPU_FILENAME)), index_col = 0)
gpu_df = pd.read_csv(os.path.abspath(os.path.join(DATA_PATH, GPU_FILENAME)), index_col = 0)

cpu_name_list = [cpu_df['CPU Name'][idx].lower() for idx in cpu_df.index]
gpu_name_list = [gpu_df['GPU Name'][idx].lower() for idx in gpu_df.index]
Expand All @@ -23,18 +26,22 @@ def mapping(s, slist):
found[1] = i
break
acc=sum([fuzz.ratio(slist[i], s2),fuzz.partial_ratio(slist[i], s2),fuzz.token_sort_ratio(slist[i], s2),fuzz.token_set_ratio(slist[i], s2)])/4
# acc=max(fuzz.ratio(slist[i], s2),fuzz.partial_ratio(slist[i], s2),fuzz.token_sort_ratio(slist[i], s2),fuzz.token_set_ratio(slist[i], s2))

if found[0]<acc:
found[0] = acc
found[1] = i
return found

def get_cpu_name(cpu):
acc , pos = mapping(cpu,cpu_name_list)
return cpu_df['CPU Name'][pos]
return cpu_df['CPU Name'][pos], cpu_df['CPU Rank'][pos]

def get_gpu_name(gpu):
acc, pos = mapping(gpu,gpu_name_list)
return gpu_df['GPU Name'][pos]
return gpu_df['GPU Name'][pos], gpu_df['GPU Rank'][pos]

if __name__ == '__main__':
TEST_CPU_NAME = 'Intel core i5 1155g7'

print(get_cpu_name('Intel core i5 1155g7'))
_, cpu_mark = get_cpu_name(TEST_CPU_NAME)
print(cpu_mark)
Loading

0 comments on commit b80f69f

Please sign in to comment.