pushpikaLiyanagama commited on
Commit
cdcb2f9
·
verified ·
1 Parent(s): 316afb5

Upload 6 files

Browse files
main.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, request, jsonify
2
+ import joblib
3
+ import numpy as np
4
+
5
+ # Load the scaler and models
6
+ scaler = joblib.load('scaler.joblib')
7
+ models = {target: joblib.load(f'svm_model_{target}.joblib') for target in ['processing', 'perception', 'input', 'understanding']}
8
+
9
+ app = Flask(__name__)
10
+
11
+ @app.route('/predict', methods=['POST'])
12
+ def predict():
13
+ data = request.json.get('user_input')
14
+ if not data:
15
+ return jsonify({"error": "No input provided"}), 400
16
+
17
+ user_input_array = np.array(data).reshape(1, -1)
18
+ user_input_scaled = scaler.transform(user_input_array)
19
+
20
+ predictions = {target: model.predict(user_input_scaled)[0] for target, model in models.items()}
21
+
22
+ return jsonify(predictions)
23
+
24
+ if __name__ == '__main__':
25
+ app.run(host='0.0.0.0', port=5000)
scaler.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:716237c8daa8b3ff6474304982f64e745ef2fd1f6159e1daac03fdf0604a5586
3
+ size 1431
svm_model_input.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:31bf1c0b7ed4a190da8178ffd9bd4fa3ace472e89758f59f95cfe76fa1508f03
3
+ size 34539
svm_model_perception.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:11b96afabaa858fa31c09a79da2128775921a56e6401a21dbc107b6dd544dc65
3
+ size 30139
svm_model_processing.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:95d16ec55a13538b6de43b771ccf226b0d60e3003da9e347bead01f74eb3dc12
3
+ size 68651
svm_model_understanding.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6713ca9fcc952b6166d1e061e9f8fee1da652296ca2292950a607d6019cf441d
3
+ size 53451