yashasvini121 / predictive-calc

An interactive web application developed with Streamlit, designed for making predictions using various machine learning models. The app dynamically generates forms and pages from JSON configuration files. ⭐ If you found this helpful, consider starring the repo!
https://predictive-calc.streamlit.app/
MIT License
25 stars 72 forks source link

Stress Level Detector Meter Correction #167

Open Xblade9669 opened 1 month ago

Xblade9669 commented 1 month ago

The Stress Level Detector asks us readings from 1 to 5 which according to me needs slight modification i.e. the meter reading should in my opinion start from 0. As for some cases the category might be 0 , for example : seeking validation might be 0 for few people as they might be self satisfied with what they are doing or someone despite of watching social media might not be depressed and might as well be feeling extremely contended.

yashasvini121 commented 1 month ago

Sure @Xblade9669, go ahead!

Xblade9669 commented 1 month ago

i am just a newbie!! you can assign others Thank you

Shreyas-GN commented 1 month ago

Heyyyy @yashasvini121

I agree upon @Xblade9669 and I believe the Stress Level Detector meter should start from 0, as some categories (e.g., compare_to_successful_people,) might not apply to everyone. Based on my experience with similar projects, and my eagerness to contribute to Open source(gssoc-ext), I’d like to work on resolving this. Could you please assign me to this issue?

yashasvini121 commented 1 month ago

Hey, I agree that the Stress Level Detector doesn’t start from 0 because the dataset it’s based on doesn’t include 0. As mentioned in this discussion, the scale ranges from 1 to 5, representing "strongly disagree" to "strongly agree." So, whether it starts from 0 or 1 doesn’t carry any meaningful significance. If you'd like, you could add a description to clarify the scale or include text on the slider for better context.

Let me know if you’d like to proceed in this direction @Shreyas-GN.

Shreyas-GN commented 1 month ago

Hey @yashasvini121 , Thanks for clarifying! I get the reasoning for starting from 1. Adding a description or text on the slider would definitely help users understand the range better.

I'd be happy to work on this, but I’m unsure how to test the changes or use Streamlit for this project. Could you guide me on that? Once I have the info, I can submit a pull request with the updates.

Let me know if that works!

yashasvini121 commented 1 month ago

Unfortunately, Streamlit sliders only accept numerical values internally, so you can't directly replace the slider values with text labels. Instead, you can use radio buttons to achieve a similar effect.

To implement this, modify the form_configs/stress_detection.json file by replacing the sliders with radio fields. Provide the options as ["Strongly Disagree", "Disagree", "Neutral", "Agree", "Strongly Agree"] and specify a default value for each. For now, you don't need to focus on the UI/UX.

Additionally, refer to the form_handler.py file to understand how the JSON file is utilized.

To run the Streamlit project, use the command streamlit run App.py.

Shreyas-GN commented 1 month ago

Hey @yashasvini121 , Got it! Thanks for the clarification. I’ll modify the form_configs/stress_detection.json to replace sliders with radio buttons and set the options as ["Strongly Disagree", "Disagree", "Neutral", "Agree", "Strongly Agree"], with appropriate default values.

I'll also check out the form_handler.py file to understand how the JSON is handled.

Thanks for the guidance, I’ll get started on this!

Shreyas-GN commented 1 month ago

Hey @yashasvini121 , I worked on replacing the sliders with radio buttons and achieved that successfully! Screenshot 2024-10-25 105633

However, when I clicked the predict button, I encountered a NameError: name 'model' is not defined. Screenshot 2024-10-25 105647

Should I focus on resolving that issue, or would you prefer that I proceed with the radio button design for now?

Thanks for your guidance!

Best, Shreyas GN

yashasvini121 commented 1 month ago

Apologies for the late response; I was busy with exams.

The error occurs because strings are being returned where integers are expected. To fix this, add the following input_mapping to the predict.py file:

input_mapping = {
    "Strongly Disagree": 1,
    "Disagree": 2,
    "Neutral": 3,
    "Agree": 4,
    "Strongly Agree": 5,
}

Also, adjust the function parameters before passing them to stress_level_prediction() , like this:

freq_no_purpose = input_mapping[freq_no_purpose]
Shreyas-GN commented 4 weeks ago

Hey @yashasvini121

Thanks for the guidance! I’ll work on implementing the input_mapping in the predict.py file and adjust the parameters accordingly. I’ll let you know once it’s done and tested.

Thanks again for your help!

Best, Shreyas GN