esteele commited on
Commit
46075c6
·
1 Parent(s): 54623ab

Initial Commit

Browse files
.gitignore ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### JupyterNotebooks template
2
+ # gitignore template for Jupyter Notebooks
3
+ # website: http://jupyter.org/
4
+
5
+ .ipynb_checkpoints
6
+ */.ipynb_checkpoints/*
7
+
8
+ # IPython
9
+ profile_default/
10
+ ipython_config.py
11
+
12
+ # Remove previous ipynb_checkpoints
13
+ # git rm -r .ipynb_checkpoints/
14
+
15
+ ### Python template
16
+ # Byte-compiled / optimized / DLL files
17
+ __pycache__/
18
+ *.py[cod]
19
+ *$py.class
20
+
21
+ # C extensions
22
+ *.so
23
+
24
+ # Distribution / packaging
25
+ .Python
26
+ build/
27
+ develop-eggs/
28
+ dist/
29
+ downloads/
30
+ eggs/
31
+ .eggs/
32
+ lib/
33
+ lib64/
34
+ parts/
35
+ sdist/
36
+ var/
37
+ wheels/
38
+ share/python-wheels/
39
+ *.egg-info/
40
+ .installed.cfg
41
+ *.egg
42
+ MANIFEST
43
+
44
+ # PyInstaller
45
+ # Usually these files are written by a python script from a template
46
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
47
+ *.manifest
48
+ *.spec
49
+
50
+ # Installer logs
51
+ pip-log.txt
52
+ pip-delete-this-directory.txt
53
+
54
+ # Unit test / coverage reports
55
+ htmlcov/
56
+ .tox/
57
+ .nox/
58
+ .coverage
59
+ .coverage.*
60
+ .cache
61
+ nosetests.xml
62
+ coverage.xml
63
+ *.cover
64
+ *.py,cover
65
+ .hypothesis/
66
+ .pytest_cache/
67
+ cover/
68
+
69
+ # Translations
70
+ *.mo
71
+ *.pot
72
+
73
+ # Django stuff:
74
+ *.log
75
+ local_settings.py
76
+ db.sqlite3
77
+ db.sqlite3-journal
78
+
79
+ # Flask stuff:
80
+ instance/
81
+ .webassets-cache
82
+
83
+ # Scrapy stuff:
84
+ .scrapy
85
+
86
+ # Sphinx documentation
87
+ docs/_build/
88
+
89
+ # PyBuilder
90
+ .pybuilder/
91
+ target/
92
+
93
+ # Jupyter Notebook
94
+
95
+ # IPython
96
+
97
+ # pyenv
98
+ # For a library or package, you might want to ignore these files since the code is
99
+ # intended to run in multiple environments; otherwise, check them in:
100
+ # .python-version
101
+
102
+ # pipenv
103
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
104
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
105
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
106
+ # install all needed dependencies.
107
+ #Pipfile.lock
108
+
109
+ # poetry
110
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
111
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
112
+ # commonly ignored for libraries.
113
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
114
+ #poetry.lock
115
+
116
+ # pdm
117
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
118
+ #pdm.lock
119
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
120
+ # in version control.
121
+ # https://pdm.fming.dev/#use-with-ide
122
+ .pdm.toml
123
+
124
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
125
+ __pypackages__/
126
+
127
+ # Celery stuff
128
+ celerybeat-schedule
129
+ celerybeat.pid
130
+
131
+ # SageMath parsed files
132
+ *.sage.py
133
+
134
+ # Environments
135
+ .env
136
+ .venv
137
+ env/
138
+ venv/
139
+ ENV/
140
+ env.bak/
141
+ venv.bak/
142
+
143
+ # Spyder project settings
144
+ .spyderproject
145
+ .spyproject
146
+
147
+ # Rope project settings
148
+ .ropeproject
149
+
150
+ # mkdocs documentation
151
+ /site
152
+
153
+ # mypy
154
+ .mypy_cache/
155
+ .dmypy.json
156
+ dmypy.json
157
+
158
+ # Pyre type checker
159
+ .pyre/
160
+
161
+ # pytype static type analyzer
162
+ .pytype/
163
+
164
+ # Cython debug symbols
165
+ cython_debug/
166
+
167
+ # PyCharm
168
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
169
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
170
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
171
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
172
+ #.idea/
173
+
.idea/.gitignore ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
4
+ # Editor-based HTTP Client requests
5
+ /httpRequests/
6
+ # Datasource local storage ignored files
7
+ /dataSources/
8
+ /dataSources.local.xml
.idea/Loan_Classifier.iml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="PYTHON_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$" />
5
+ <orderEntry type="jdk" jdkName="Python 3.11 (venv)" jdkType="Python SDK" />
6
+ <orderEntry type="sourceFolder" forTests="false" />
7
+ </component>
8
+ </module>
.idea/inspectionProfiles/Project_Default.xml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
5
+ <option name="ignoredPackages">
6
+ <value>
7
+ <list size="1">
8
+ <item index="0" class="java.lang.String" itemvalue="scikit-learn" />
9
+ </list>
10
+ </value>
11
+ </option>
12
+ </inspection_tool>
13
+ </profile>
14
+ </component>
.idea/inspectionProfiles/profiles_settings.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <component name="InspectionProjectProfileManager">
2
+ <settings>
3
+ <option name="USE_PROJECT_PROFILE" value="false" />
4
+ <version value="1.0" />
5
+ </settings>
6
+ </component>
.idea/misc.xml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (venv)" project-jdk-type="Python SDK" />
4
+ </project>
.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/Loan_Classifier.iml" filepath="$PROJECT_DIR$/.idea/Loan_Classifier.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
app.py ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import joblib
3
+ import pandas as pd
4
+
5
+ model = joblib.load("best_random_forest_model.joblib")
6
+
7
+
8
+ def predict_loan_status(
9
+ loan_original_amount,
10
+ credit_score_range_lower,
11
+ stated_monthly_income,
12
+ investors,
13
+ monthly_loan_payment,
14
+
15
+ ):
16
+ input_dict = {
17
+ 'LoanOriginalAmount': loan_original_amount,
18
+ 'CreditScoreRangeLower': credit_score_range_lower,
19
+ 'StatedMonthlyIncome': stated_monthly_income,
20
+ 'Investors': investors,
21
+ 'MonthlyLoanPayment': monthly_loan_payment,
22
+
23
+ }
24
+
25
+ user_input_df = pd.DataFrame(data=[[loan_original_amount,
26
+ credit_score_range_lower,
27
+ stated_monthly_income,
28
+ investors,
29
+ monthly_loan_payment]],
30
+ columns=[
31
+ 'LoanOriginalAmount',
32
+ 'CreditScoreRangeLower',
33
+ 'StatedMonthlyIncome',
34
+ 'Investors',
35
+ 'MonthlyLoanPayment',
36
+ ])
37
+
38
+ scaler = joblib.load('std_scaler.bin')
39
+ # Convert the dictionary to a 2D array
40
+ input_array = user_input_df.values
41
+ # print(user_input_df)
42
+ scaled_array = scaler.transform(input_array)
43
+ # print('scaled array', scaled_array)
44
+ prediction = model.predict(scaled_array)
45
+ # print('Prediction: ', prediction)
46
+
47
+ return prediction[0]
48
+
49
+
50
+ options = ['Current', 'Completed', 'ChargedOff']
51
+
52
+ inputs = [
53
+ gr.Slider(1000, 100000, label="Loan Original Amount"),
54
+ gr.Slider(100, 2000, step=1, label='Credit Score Range (Lower)'),
55
+ gr.Slider(1000, 100000, step=10, label="Stated Monthly Income"),
56
+ gr.Slider(0, 1000, step=1, label='Number of Investors'),
57
+ gr.Slider(20, 5000, step=5, label="Monthly Loan Payment")
58
+
59
+ ]
60
+
61
+ outputs = gr.Label()
62
+ title = "Loan Status Classifier"
63
+ description = (
64
+ "Enter the details of the loan to check the status of the loan."
65
+ )
66
+ gr.Interface(
67
+ fn=predict_loan_status,
68
+ inputs=inputs,
69
+ outputs=outputs,
70
+ title=title,
71
+ description=description,
72
+ ).launch()
73
+
74
+ # def greet(name):
75
+ # return "Hello " + name + "!!"
76
+ #
77
+ #
78
+ # iface = gr.Interface(fn=greet, inputs="text", outputs="text")
79
+ # iface.launch()
best_random_forest_model.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dc67deb703312706a00f20863c8216285e623ac2fda87373031161e3c25a5e46
3
+ size 409970209
flagged/log.csv ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ name,output,flag,username,timestamp
2
+ ,,,,2023-09-29 15:05:20.783000
3
+ 31100,170,2360,0,2990,C:\Users\Carla\Workspace\DataScience\Apps\Loan_Classifier\flagged\output\tmpcntrnzpp.json,,,2023-09-29 16:00:28.884976
4
+ 13800,263,6790,239,3080,C:\Users\Carla\Workspace\DataScience\Apps\Loan_Classifier\flagged\output\tmpz7l8vohc.json,,,2023-09-29 16:19:42.908098
flagged/output/tmpcntrnzpp.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"label": "Completed"}
flagged/output/tmpz7l8vohc.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"label": "Completed"}
requirements.txt ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiofiles==23.2.1
2
+ altair==5.1.1
3
+ annotated-types==0.5.0
4
+ anyio==3.7.1
5
+ argon2-cffi==23.1.0
6
+ argon2-cffi-bindings==21.2.0
7
+ arrow==1.2.3
8
+ asttokens==2.4.0
9
+ async-lru==2.0.4
10
+ attrs==23.1.0
11
+ Babel==2.12.1
12
+ backcall==0.2.0
13
+ beautifulsoup4==4.12.2
14
+ bleach==6.0.0
15
+ blinker==1.6.2
16
+ cachetools==5.3.1
17
+ certifi==2023.7.22
18
+ cffi==1.15.1
19
+ charset-normalizer==3.2.0
20
+ click==8.1.7
21
+ colorama==0.4.6
22
+ comm==0.1.4
23
+ contourpy==1.1.0
24
+ cycler==0.11.0
25
+ debugpy==1.8.0
26
+ decorator==5.1.1
27
+ defusedxml==0.7.1
28
+ executing==1.2.0
29
+ fastapi==0.103.2
30
+ fastjsonschema==2.18.0
31
+ ffmpy==0.3.1
32
+ filelock==3.12.4
33
+ fonttools==4.42.1
34
+ fqdn==1.5.1
35
+ fsspec==2023.9.2
36
+ gitdb==4.0.10
37
+ GitPython==3.1.36
38
+ gradio==3.45.2
39
+ gradio_client==0.5.3
40
+ h11==0.14.0
41
+ httpcore==0.18.0
42
+ httpx==0.25.0
43
+ huggingface-hub==0.17.3
44
+ idna==3.4
45
+ importlib-metadata==6.8.0
46
+ importlib-resources==6.1.0
47
+ ipykernel==6.25.2
48
+ ipython==8.15.0
49
+ ipython-genutils==0.2.0
50
+ ipywidgets==8.1.1
51
+ isoduration==20.11.0
52
+ jedi==0.19.0
53
+ Jinja2==3.1.2
54
+ joblib==1.3.2
55
+ json5==0.9.14
56
+ jsonpointer==2.4
57
+ jsonschema==4.19.0
58
+ jsonschema-specifications==2023.7.1
59
+ jupyter==1.0.0
60
+ jupyter-console==6.6.3
61
+ jupyter-events==0.7.0
62
+ jupyter-lsp==2.2.0
63
+ jupyter_client==8.3.1
64
+ jupyter_core==5.3.1
65
+ jupyter_server==2.7.3
66
+ jupyter_server_terminals==0.4.4
67
+ jupyterlab==4.0.5
68
+ jupyterlab-pygments==0.2.2
69
+ jupyterlab-widgets==3.0.9
70
+ jupyterlab_server==2.25.0
71
+ kiwisolver==1.4.5
72
+ markdown-it-py==3.0.0
73
+ MarkupSafe==2.1.3
74
+ matplotlib==3.7.3
75
+ matplotlib-inline==0.1.6
76
+ mdurl==0.1.2
77
+ mistune==3.0.1
78
+ nbclient==0.8.0
79
+ nbconvert==7.8.0
80
+ nbformat==5.9.2
81
+ nest-asyncio==1.5.7
82
+ notebook==7.0.3
83
+ notebook_shim==0.2.3
84
+ numpy==1.25.2
85
+ orjson==3.9.7
86
+ overrides==7.4.0
87
+ packaging==23.1
88
+ pandas==2.1.0
89
+ pandocfilters==1.5.0
90
+ parso==0.8.3
91
+ pickleshare==0.7.5
92
+ Pillow==9.5.0
93
+ platformdirs==3.10.0
94
+ plotly==5.16.1
95
+ prometheus-client==0.17.1
96
+ prompt-toolkit==3.0.39
97
+ protobuf==4.24.3
98
+ psutil==5.9.5
99
+ pure-eval==0.2.2
100
+ pyarrow==13.0.0
101
+ pycparser==2.21
102
+ pydantic==2.4.2
103
+ pydantic_core==2.10.1
104
+ pydeck==0.8.0
105
+ pydub==0.25.1
106
+ Pygments==2.16.1
107
+ Pympler==1.0.1
108
+ pyparsing==3.1.1
109
+ python-dateutil==2.8.2
110
+ python-json-logger==2.0.7
111
+ python-multipart==0.0.6
112
+ pytz==2023.3.post1
113
+ pytz-deprecation-shim==0.1.0.post0
114
+ pywin32==306
115
+ pywinpty==2.0.11
116
+ PyYAML==6.0.1
117
+ pyzmq==25.1.1
118
+ qtconsole==5.4.4
119
+ QtPy==2.4.0
120
+ referencing==0.30.2
121
+ requests==2.31.0
122
+ rfc3339-validator==0.1.4
123
+ rfc3986-validator==0.1.1
124
+ rich==13.5.2
125
+ rpds-py==0.10.2
126
+ scikit-learn==1.2.2
127
+ scipy==1.11.2
128
+ seaborn==0.12.2
129
+ semantic-version==2.10.0
130
+ Send2Trash==1.8.2
131
+ six==1.16.0
132
+ smmap==5.0.0
133
+ sniffio==1.3.0
134
+ soupsieve==2.5
135
+ stack-data==0.6.2
136
+ starlette==0.27.0
137
+ streamlit==1.26.0
138
+ tenacity==8.2.3
139
+ terminado==0.17.1
140
+ threadpoolctl==3.2.0
141
+ tinycss2==1.2.1
142
+ toml==0.10.2
143
+ toolz==0.12.0
144
+ tornado==6.3.3
145
+ tqdm==4.66.1
146
+ traitlets==5.9.0
147
+ typing_extensions==4.7.1
148
+ tzdata==2023.3
149
+ tzlocal==4.3.1
150
+ uri-template==1.3.0
151
+ urllib3==2.0.4
152
+ uvicorn==0.23.2
153
+ validators==0.22.0
154
+ watchdog==3.0.0
155
+ wcwidth==0.2.6
156
+ webcolors==1.13
157
+ webencodings==0.5.1
158
+ websocket-client==1.6.3
159
+ websockets==11.0.3
160
+ widgetsnbextension==4.0.9
161
+ zipp==3.16.2
std_scaler.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8314a7ed1f382cdea9ed59235b10ddf4e783085bf8d28442dcffde378e9e10eb
3
+ size 1135