SURESHBEEKHANI commited on
Commit
e8eb0fa
·
verified ·
1 Parent(s): b27831c

Upload 7 files

Browse files
Files changed (7) hide show
  1. .gitignore +163 -0
  2. Dockerfile +29 -0
  3. README.md +12 -11
  4. app.py +61 -0
  5. git +0 -0
  6. requirements.txt +9 -0
  7. setup.py +40 -0
.gitignore ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
110
+ .pdm.toml
111
+ .pdm-python
112
+ .pdm-build/
113
+
114
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
115
+ __pypackages__/
116
+
117
+ # Celery stuff
118
+ celerybeat-schedule
119
+ celerybeat.pid
120
+
121
+ # SageMath parsed files
122
+ *.sage.py
123
+
124
+ # Environments
125
+ .artifacts/
126
+ .env
127
+ .venv
128
+ env/
129
+ venv/
130
+ ENV/
131
+ env.bak/
132
+ venv.bak/
133
+
134
+ # Spyder project settings
135
+ .spyderproject
136
+ .spyproject
137
+
138
+ # Rope project settings
139
+ .ropeproject
140
+
141
+ # mkdocs documentation
142
+ /site
143
+
144
+ # mypy
145
+ .mypy_cache/
146
+ .dmypy.json
147
+ dmypy.json
148
+
149
+ # Pyre type checker
150
+ .pyre/
151
+
152
+ # pytype static type analyzer
153
+ .pytype/
154
+
155
+ # Cython debug symbols
156
+ cython_debug/
157
+
158
+ # PyCharm
159
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
160
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
161
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
162
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
163
+ #.idea/
Dockerfile ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9
2
+
3
+ ## set the working directory to /code
4
+ WORKDIR /code
5
+
6
+ ## Copy the current directory contents in the container at /code
7
+ COPY ./requirements.txt /code/requirements.txt
8
+
9
+ ## Install the requirements.txt
10
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
11
+
12
+ # Set up a new user named "user"
13
+ RUN useradd user
14
+ # Switch to the "user" user
15
+ USER user
16
+
17
+ # Set home to the user's home directory
18
+
19
+ ENV HOME=/home/user \
20
+ PATH=/home/user/.local/bin:$PATH
21
+
22
+ # Set the working directory to the user's home directory
23
+ WORKDIR $HOME/app
24
+
25
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
26
+ COPY --chown=user . $HOME/app
27
+
28
+ ## Start the FASTAPI App on port 7860
29
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
README.md CHANGED
@@ -1,11 +1,12 @@
1
- ---
2
- title: StudentExamPerformancePrediction
3
- emoji: 📈
4
- colorFrom: yellow
5
- colorTo: yellow
6
- sdk: docker
7
- pinned: false
8
- license: mit
9
- ---
10
-
11
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
1
+ ---
2
+ title: Student-Exam-Performance-Prediction
3
+ emoji: 💬
4
+ colorFrom: purple
5
+ colorTo: blue
6
+ sdk: streamlit
7
+ sdk_version: "1.38.0"
8
+ app_file: src/app.py
9
+ pinned: false
10
+ ---
11
+
12
+ End Two Mchine learining Project
app.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Importing necessary modules from Flask to create the web application
2
+ from flask import Flask, request, render_template
3
+
4
+ # Importing additional necessary libraries
5
+ import numpy as np # For numerical operations
6
+ import pandas as pd # For data manipulation and creating DataFrame objects
7
+
8
+ # Importing custom modules: CustomData and PredictPipeline from the 'src.pipeline.predict_pipeline' module
9
+ from src.pipeline.predict_pipeline import CustomData, PredictPipeline
10
+
11
+ # Initializing the Flask application
12
+ app = Flask(__name__)
13
+
14
+ # Defining the route for the homepage of the web application
15
+ @app.route('/')
16
+ def index():
17
+ # Rendering the 'index.html' template when the root URL is accessed
18
+ return render_template('home.html')
19
+
20
+ # Defining the route for prediction, with both GET and POST methods allowed
21
+ @app.route('/predictdata', methods=['GET', 'POST'])
22
+ def predict_datapoint():
23
+ # If the request method is GET, render 'home.html'
24
+ if request.method == 'GET':
25
+ return render_template('home.html')
26
+ else:
27
+ try:
28
+ # Capture the form data (ensure form field names match these keys)
29
+ data = CustomData(
30
+ gender=request.form.get('gender'),
31
+ race_ethnicity=request.form.get('ethnicity'),
32
+ parental_level_of_education=request.form.get('parental_level_of_education'),
33
+ lunch=request.form.get('lunch'),
34
+ test_preparation_course=request.form.get('test_preparation_course'),
35
+ reading_score=float(request.form.get('reading_score')), # Ensuring correct casting
36
+ writing_score=float(request.form.get('writing_score')) # Ensuring correct casting
37
+ )
38
+
39
+ # Convert the collected form data into a pandas DataFrame
40
+ pred_df = data.get_data_as_data_frame()
41
+ print(f"Input DataFrame: \n{pred_df}")
42
+
43
+ # Initialize the prediction pipeline
44
+ predict_pipeline = PredictPipeline()
45
+
46
+ # Make the prediction
47
+ results = predict_pipeline.predict(pred_df)
48
+ print(f"Prediction Result: {results}")
49
+
50
+ # Render 'home.html' and display the prediction result
51
+ return render_template('home.html', results=results[0])
52
+
53
+ except Exception as e:
54
+ print(f"Error during prediction: {e}")
55
+ # If any error occurs, render the home page with an error message
56
+ return render_template('home.html', error="An error occurred during prediction. Please check your input.")
57
+
58
+ # Run the Flask app
59
+ if __name__ == "__main__":
60
+ # Running the app on host 0.0.0.0 (accessible from any device in the network), debug mode ON for development
61
+ app.run(host="0.0.0.0", debug=True)
git ADDED
File without changes
requirements.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ pandas
2
+ numpy
3
+ seaborn
4
+ matplotlib
5
+ scikit-learn
6
+ catboost
7
+ xgboost
8
+ Flask
9
+
setup.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from setuptools import find_packages, setup
2
+ from typing import List
3
+
4
+ HYPEN_E_DOT = '-e .'
5
+
6
+ def get_requirements(file_path: str) -> List[str]:
7
+ '''
8
+ This function will return the list of requirements
9
+ '''
10
+ requirements = []
11
+ with open(file_path) as file_obj:
12
+ requirements = file_obj.readlines()
13
+ requirements = [req.replace("\n", "") for req in requirements]
14
+
15
+ if HYPEN_E_DOT in requirements:
16
+ requirements.remove(HYPEN_E_DOT)
17
+
18
+ return requirements
19
+
20
+ setup(
21
+ name="student-exam-performance-prediction",
22
+ version="1.0.0",
23
+ packages=find_packages(),
24
+ # Package metadata
25
+ author="Suresh Beekhani",
26
+ author_email="sureshbeekhani26@gmail.com",
27
+ description="A tool for predicting student exam performance based on various factors.",
28
+ long_description="This package provides a comprehensive model for predicting student exam performance using data analysis and machine learning techniques.",
29
+ long_description_content_type="text/markdown",
30
+ url="https://github.com/SURESHBEEKHANI/Student-Exam-Performance-Prediction.git",
31
+ # Read dependencies from requirements.txt
32
+ install_requires=get_requirements('requirements.txt'),
33
+ # License and classification
34
+ license="MIT",
35
+ classifiers=[
36
+ "Programming Language :: Python :: 3.12",
37
+ "License :: OSI Approved :: MIT License",
38
+ "Operating System :: OS Independent",
39
+ ],
40
+ )