NEXAS commited on
Commit
0ad2874
1 Parent(s): afa9af5

Upload 9 files

Browse files
Files changed (8) hide show
  1. .gitignore +1 -0
  2. LICENSE +21 -0
  3. Procfile +1 -0
  4. app.yaml +1 -0
  5. main.py +28 -0
  6. model.pkl +3 -0
  7. requirements.txt +4 -0
  8. streamlit_app.py +39 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ venv
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2023 NARESH KUMAR LAHAJAL
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
Procfile ADDED
@@ -0,0 +1 @@
 
 
1
+ web: gunicorn app:app
app.yaml ADDED
@@ -0,0 +1 @@
 
 
1
+ runtime: python311
main.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask,request,jsonify
2
+ import numpy as np
3
+ import pickle
4
+
5
+ model = pickle.load(open('model.pkl','rb'))
6
+
7
+ app = Flask(__name__)
8
+
9
+ @app.route('/')
10
+ def index():
11
+ return "Stock prediction"
12
+
13
+ @app.route('/predict',methods=['POST'])
14
+ def predict():
15
+ high = request.form.get('high')
16
+ low = request.form.get('low')
17
+ open = request.form.get('open')
18
+ volume = request.form.get('volume')
19
+ high=float(high)
20
+ low=float(low)
21
+ open=float(open)
22
+ volume=float(volume)
23
+ input_query = np.array([[high,low,open,volume]])
24
+ result = model.predict(input_query)[0]
25
+ return jsonify({'res':str(result)})
26
+
27
+ if __name__ == '__main__':
28
+ app.run(debug=True)
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d5a99e0309c7d50fb45171fd927c7dc84140c132dc1bd0bbc2214113c9649d75
3
+ size 523
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ flask
2
+ numpy
3
+ sklearn
4
+ gunicorn
streamlit_app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+
4
+ st.title("Predictive Model App")
5
+
6
+ # Create input fields
7
+ high = st.number_input("High", format="%f")
8
+ low = st.number_input("Low", format="%f")
9
+ open_val = st.number_input("Open", format="%f") # renamed to avoid conflict with the built-in open function
10
+ volume = st.number_input("Volume", format="%f")
11
+
12
+ url = "https://nareshstp.pythonanywhere.com/predict"
13
+
14
+ # Create a button to trigger the prediction
15
+ if st.button("Predict"):
16
+ # Prepare the parameters for the POST request
17
+ params = {
18
+ "high": str(high),
19
+ "low": str(low),
20
+ "open": str(open_val),
21
+ "volume": str(volume)
22
+ }
23
+
24
+ # Make the POST request
25
+ try:
26
+ response = requests.post(url, data=params)
27
+
28
+ # Parse the response and display the result
29
+ if response.status_code == 200:
30
+ result_data = response.json()
31
+
32
+ # Display the result in a bigger font and inside a text box
33
+ st.markdown(f"## Result")
34
+ st.markdown(f"<div style='background-color: ##050505; padding: 20px; border-radius: 5px;'><span style='font-size: 24px;'>{result_data.get('res')}</span></div>", unsafe_allow_html=True)
35
+ else:
36
+ st.error(f"API Error: {response.status_code}. {response.text}")
37
+
38
+ except Exception as e:
39
+ st.error(f"Error: {e}")