Jensen-holm commited on
Commit
f04bbb4
·
1 Parent(s): 417c866

messing around with readme

Browse files
Files changed (2) hide show
  1. README.md +30 -0
  2. app.py +17 -16
README.md ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Data Mining from scratch backend
2
+
3
+ Currently living [here](https://data-mining-from-scratch-backend.onrender.com/)
4
+
5
+ ### Example Useage
6
+
7
+ ```python
8
+ import requests
9
+ import json
10
+
11
+ request_params = {
12
+ "algorithm": "neural-network",
13
+ "arguments": {
14
+ "epochs": 100,
15
+ "activation_func": "relu",
16
+ "hidden_size": "8",
17
+ "learning_rate": 0.1,
18
+ }
19
+ }
20
+
21
+ r = requests.post(
22
+ "https://data-mining-from-scratch-backend.onrender.com/",
23
+ json=request_params,
24
+ )
25
+
26
+ response_data = json.loads(r.json)
27
+ print(response_data)
28
+
29
+ ```
30
+
app.py CHANGED
@@ -26,22 +26,23 @@ def not_valid(params: dict):
26
 
27
  @app.route("/", methods=["POST", "GET"])
28
  def index():
29
- if request.method == "POST":
30
- params = request.json
31
- error_message = not_valid(params=params)
32
- if error_message:
33
- return make_response(error_message, 400)
34
-
35
- # parse arguments
36
- algorithm = options[params["algorithm"]]
37
- args = params["arguments"]
38
-
39
- # in the future instead of a random data set
40
- # we should do a more real one like palmer penguins
41
- X, y = random_dataset(100, 10)
42
- model = algorithm(X, y, args)
43
- return jsonify(model)
44
- return render_template("index.html")
 
45
 
46
 
47
  if __name__ == "__main__":
 
26
 
27
  @app.route("/", methods=["POST", "GET"])
28
  def index():
29
+ if request.method == "GET":
30
+ return render_template("index.html")
31
+
32
+ params = request.json
33
+ error_message = not_valid(params=params)
34
+ if error_message:
35
+ return make_response(error_message, 400)
36
+
37
+ # parse arguments
38
+ algorithm = options[params["algorithm"]]
39
+ args = params["arguments"]
40
+
41
+ # in the future instead of a random data set
42
+ # we should do a more real one like palmer penguins
43
+ X, y = random_dataset(100, 10)
44
+ model = algorithm(X, y, args)
45
+ return jsonify(model)
46
 
47
 
48
  if __name__ == "__main__":