Spaces:
Build error
Build error
Commit
·
f04bbb4
1
Parent(s):
417c866
messing around with readme
Browse files
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 == "
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
| 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__":
|