diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..57ee5b5
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+frontend/node_modules
\ No newline at end of file
diff --git a/Procfile b/Procfile
new file mode 100644
index 0000000..c55bee4
--- /dev/null
+++ b/Procfile
@@ -0,0 +1 @@
+web: gunicorn api.api:flask_app
\ No newline at end of file
diff --git a/README.md b/README.md
old mode 100644
new mode 100755
index 659ef67..54ef094
--- a/README.md
+++ b/README.md
@@ -1,4 +1,68 @@
-# dashboard
+This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
-Flask - react app
-formation data scientist
+## Available Scripts
+
+In the project directory, you can run:
+
+### `npm start`
+
+Runs the app in the development mode.
+Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
+
+The page will reload if you make edits.
+You will also see any lint errors in the console.
+
+### `npm test`
+
+Launches the test runner in the interactive watch mode.
+See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
+
+### `npm run build`
+
+Builds the app for production to the `build` folder.
+It correctly bundles React in production mode and optimizes the build for the best performance.
+
+The build is minified and the filenames include the hashes.
+Your app is ready to be deployed!
+
+See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
+
+### `npm run eject`
+
+**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
+
+If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
+
+Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
+
+You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
+
+## Learn More
+
+You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
+
+To learn React, check out the [React documentation](https://reactjs.org/).
+
+### Code Splitting
+
+This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
+
+### Analyzing the Bundle Size
+
+This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
+
+### Making a Progressive Web App
+
+This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
+
+### Advanced Configuration
+
+This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
+
+### Deployment
+
+This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
+
+### `npm run build` fails to minify
+
+This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
diff --git a/api/Dockerfile b/api/Dockerfile
deleted file mode 100644
index 079ff96..0000000
--- a/api/Dockerfile
+++ /dev/null
@@ -1,24 +0,0 @@
-FROM python:3.8
-# RUN apt-get install -y python3-pip python3-dev
-# RUN apt-get update && apt-get install -y \
-# net-tools inetutils-traceroute \
-# iputils-ping xinetd telnetd
-
-# RUN apt-get install software-properties-common\
-# && apt-add-repository universe \
-# && apt-get update\
-# && apt-get install python-pip
-
-RUN mkdir -p /usr/src/app
-WORKDIR /usr/src/app
-
-COPY requirements.txt /usr/src/app
-
-RUN pip install -r requirements.txt
-
-# ENTRYPOINT ["flask"]
-
-COPY . /usr/src/app
-# COPY bdd /usr/src/app/*.sav .
-
-CMD ["python", "./api.py"]
diff --git a/api/api.py b/api/api.py
index aeb6479..0b17e5f 100755
--- a/api/api.py
+++ b/api/api.py
@@ -5,24 +5,27 @@
import h5py
import seaborn as sns
import os
+from statsmodels.nonparametric.kde import KDEUnivariate
+from flask_cors import CORS
-from flask_cors import CORS
+flask_app = Flask(__name__, static_folder='../build', static_url_path='/')
+# flask_app = Flask(__name__,)
+CORS(flask_app)
+path = "api/"
+
+@flask_app.route('/')
+def index():
+ return flask_app.send_static_file('index.html')
-# app = Flask(__name__, static_folder='../build', static_url_path='/')
-app = Flask(__name__)
-CORS(app)
-# @app.route('/')
-# def index():
-# return app.send_static_file('index.html')
THR_OPTI = 0.5172413793103449
-data = pickle.load(open('data_20ieme.sav', 'rb'))
+data = pickle.load(open(path+'data_20ieme.sav', 'rb'))
print("data loaded")
-loaded_model = pickle.load(open('model_lgbm.sav', 'rb'))
+loaded_model = pickle.load(open(path+'model_lgbm.sav', 'rb'))
print("model loaded")
y_proba = loaded_model.predict_proba(data)
@@ -39,75 +42,7 @@ def predict(y_pred_proba, thr = THR_OPTI) :
y_pred = predict(y_proba)
print("y_pred calculated")
-knn = pickle.load(open('knn_1_20ieme.sav', 'rb'))
-
-
-# def knn(id_client) :
-
-# path = "../bdd/"
-
-# idx_clients = pickle.load(open(path + 'idx/idx_clients.sav', 'rb'))
-
-
-# t_start = time.time()
-
-# nbr_nmatrix = 25
-# nbr_split_nmatrix = 10
-
-# nbr_sub = nbr_nmatrix * nbr_split_nmatrix
-
-# nsub = "numero de la sub du client"
-# s_id = "numero de ligne de la sub du client"
-
-
-# for tab in np.arange(nbr_sub) :
-# s = pickle.load(open(path + "idx/idx_split" + str(tab) + ".sav", 'rb'))
-
-
-# idx_d = np.where(s.values == id_client)[0]
-
-# if len(idx_d) == 1 :
-# # print("on a stocké dans 's' uniquement les ID client des lignes de la sub : s_id. Dimension =", np.shape(s))
-
-# nsub = tab
-# s_id = idx_d[0]
-
-# # print("le client est dans la sub" , nsub, " à la s_id", s_id)
-
-# s = pickle.load(open(path+ "idx/idx_split" + str(nsub) + ".sav", 'rb')) # on s = [s_id] du client
-
-# nmatrix = int(nsub / nbr_split_nmatrix) # numero de la matrix du client
-# c_id = s.index[s_id] # numero de colonne de la matrix du client
-
-# # print( "la ligne s_id:",s_id, "de la sub", nsub , "correspond à la colonne c_id:", c_id, "de la matrice", nmatrix)
-
-# col = idx_clients[nmatrix] # colonne matrix du client
-
-# # print("les colonnes de la matrix du client sont de dimension", np.shape(col))
-# # print("on confirme que le numéro du client est par les colonnes c_id: ", col[c_id], ", donc = au numero du client : ", id_client)
-# # print("on confirme que le numéro du client est par la sub s_id: ", s.iloc[s_id])
-
-# h5f = h5py.File(path + "h5/dist_split" + str(nsub) + ".h5",'r') # on charge la sub des distances entre les clients
-# b = h5f['dist'][:]
-# dist = b[s_id,:] # on selectionne la ligne de la sub du client
-# h5f.close()
-
-# # print("la ligne de la sub est de dimension ", np.shape(dist))
-# # print("la distance du client avec lui même devrait être nulle : ", dist[c_id])
-
-# idx_d_500_kkn = list(np.argpartition(dist,500))[0:500] # on selectionne les 500 clients les plus proches en distance sans ordre (dans la sub)
-# idx_knn_client = np.where(idx_d_500_kkn == c_id)[0][0] # on trouve dans cette liste knn non ordonné le c_id du client (dans la sub)
-# idx_d_500_kkn.pop(np.where(idx_d_500_kkn == c_id)[0][0]) # on enlève la distance du client avec lui même (0)
-
-# # print("on a trouvé les 499 plus proches voisins du client dans la sub ", np.shape(idx_d_500_kkn))
-
-# idx_500_kkn = col[idx_d_500_kkn]
-
-# # print("les ID des 10 clients parmis les 499 plus proches voisins sont : \n", idx_500_kkn[:10])
-
-# return idx_500_kkn
-
-from statsmodels.nonparametric.kde import KDEUnivariate
+knn = pickle.load(open(path+'knn_1_20ieme.sav', 'rb'))
def kde_statsmodels_u(y_data, x_grid, bandwidth=0.2, **kwargs):
"""Univariate Kernel Density Estimation with Statsmodels"""
@@ -123,12 +58,12 @@ def density(pred , feature) :
return {"x":list(x_grid),"y":list(y)}
-@app.route('/dashboard')
+@flask_app.route('/api/dashboard')
def get_current_pred():
- idx_clients = pickle.load(open('idx_clients.sav', 'rb'))
+ idx_clients = pickle.load(open(path+'idx_clients.sav', 'rb'))
- s = pickle.load(open("data_20ieme.sav", 'rb'))
+ s = pickle.load(open(path+'data_20ieme.sav', 'rb'))
nmatrix = 0
c_id = s.index[0]
col = idx_clients[nmatrix] # colonne matrix du client
@@ -157,7 +92,7 @@ def get_current_pred():
-@app.route('/dashboard/change', methods=['POST'])
+@flask_app.route('/api/dashboard/change', methods=['POST'])
def change_pred():
print("requette ID arrivée")
@@ -171,7 +106,7 @@ def change_pred():
-@app.route('/dashboard/id', methods=['POST'])
+@flask_app.route('/api/dashboard/id', methods=['POST'])
def my_form_post():
print("requette ID arrivée")
@@ -210,7 +145,8 @@ def my_form_post():
}
}
-if __name__ == "__main__":
- # app.run(debug=True)
- app.run(host='0.0.0.0', debug=True)
- # app.run(host='0.0.0.0', debug=Fa0))
\ No newline at end of file
+# if __name__ == "__main__":
+# flask_app.run(host='0.0.0.0', debug=True)
+
+ if __name__ == "__main__":
+ flask_app.run(host='0.0.0.0', debug=False, port=os.environ.get('PORT', 80))
\ No newline at end of file
diff --git a/api/requirements.txt b/api/requirements.txt
deleted file mode 100644
index da39ea2..0000000
--- a/api/requirements.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-Flask==1.1.2
-h5py
-matplotlib
-numpy
-panda==0.3.1
-pandas==1.1.1
-pickle5==0.0.11
-Pillow==7.2.0
-scikit-learn==0.23.2
-scipy==1.5.2
-seaborn==0.10.1
-sklearn==0.0
-statsmodels==0.11.1
-flask-cors
-lightgbm
diff --git a/build/asset-manifest.json b/build/asset-manifest.json
new file mode 100644
index 0000000..485e9ae
--- /dev/null
+++ b/build/asset-manifest.json
@@ -0,0 +1,27 @@
+{
+ "files": {
+ "main.css": "/static/css/main.1dc9daea.chunk.css",
+ "main.js": "/static/js/main.bfe05604.chunk.js",
+ "main.js.map": "/static/js/main.bfe05604.chunk.js.map",
+ "runtime-main.js": "/static/js/runtime-main.47c836b6.js",
+ "runtime-main.js.map": "/static/js/runtime-main.47c836b6.js.map",
+ "static/css/2.11829350.chunk.css": "/static/css/2.11829350.chunk.css",
+ "static/js/2.d5077f88.chunk.js": "/static/js/2.d5077f88.chunk.js",
+ "static/js/2.d5077f88.chunk.js.map": "/static/js/2.d5077f88.chunk.js.map",
+ "index.html": "/index.html",
+ "precache-manifest.e8c00842bdd4c5d7198b21f580cc151e.js": "/precache-manifest.e8c00842bdd4c5d7198b21f580cc151e.js",
+ "service-worker.js": "/service-worker.js",
+ "static/css/2.11829350.chunk.css.map": "/static/css/2.11829350.chunk.css.map",
+ "static/css/main.1dc9daea.chunk.css.map": "/static/css/main.1dc9daea.chunk.css.map",
+ "static/js/2.d5077f88.chunk.js.LICENSE.txt": "/static/js/2.d5077f88.chunk.js.LICENSE.txt",
+ "static/media/logo.svg": "/static/media/logo.ee7cd8ed.svg",
+ "static/media/nucleo-icons.css": "/static/media/nucleo.f0b489a5.woff"
+ },
+ "entrypoints": [
+ "static/js/runtime-main.47c836b6.js",
+ "static/css/2.11829350.chunk.css",
+ "static/js/2.d5077f88.chunk.js",
+ "static/css/main.1dc9daea.chunk.css",
+ "static/js/main.bfe05604.chunk.js"
+ ]
+}
\ No newline at end of file
diff --git a/build/favicon.ico b/build/favicon.ico
new file mode 100755
index 0000000..bcd5dfd
Binary files /dev/null and b/build/favicon.ico differ
diff --git a/build/index.html b/build/index.html
new file mode 100644
index 0000000..f12d3f1
--- /dev/null
+++ b/build/index.html
@@ -0,0 +1 @@
+
`s get reset. However, we also reset the\n// bottom margin to use `rem` units instead of `em`.\np {\n margin-top: 0;\n margin-bottom: $paragraph-margin-bottom;\n}\n\n// Abbreviations\n//\n// 1. Duplicate behavior to the data-* attribute for our tooltip plugin\n// 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.\n// 3. Add explicit cursor to indicate changed behavior.\n// 4. Remove the bottom border in Firefox 39-.\n// 5. Prevent the text-decoration to be skipped.\n\nabbr[title],\nabbr[data-original-title] { // 1\n text-decoration: underline; // 2\n text-decoration: underline dotted; // 2\n cursor: help; // 3\n border-bottom: 0; // 4\n text-decoration-skip-ink: none; // 5\n}\n\naddress {\n margin-bottom: 1rem;\n font-style: normal;\n line-height: inherit;\n}\n\nol,\nul,\ndl {\n margin-top: 0;\n margin-bottom: 1rem;\n}\n\nol ol,\nul ul,\nol ul,\nul ol {\n margin-bottom: 0;\n}\n\ndt {\n font-weight: $dt-font-weight;\n}\n\ndd {\n margin-bottom: .5rem;\n margin-left: 0; // Undo browser default\n}\n\nblockquote {\n margin: 0 0 1rem;\n}\n\nb,\nstrong {\n font-weight: $font-weight-bolder; // Add the correct font weight in Chrome, Edge, and Safari\n}\n\nsmall {\n @include font-size(80%); // Add the correct font size in all browsers\n}\n\n//\n// Prevent `sub` and `sup` elements from affecting the line height in\n// all browsers.\n//\n\nsub,\nsup {\n position: relative;\n @include font-size(75%);\n line-height: 0;\n vertical-align: baseline;\n}\n\nsub { bottom: -.25em; }\nsup { top: -.5em; }\n\n\n//\n// Links\n//\n\na {\n color: $link-color;\n text-decoration: $link-decoration;\n background-color: transparent; // Remove the gray background on active links in IE 10.\n\n @include hover() {\n color: $link-hover-color;\n text-decoration: $link-hover-decoration;\n }\n}\n\n// And undo these styles for placeholder links/named anchors (without href).\n// It would be more straightforward to just use a[href] in previous block, but that\n// causes specificity issues in many other styles that are too complex to fix.\n// See https://github.com/twbs/bootstrap/issues/19402\n\na:not([href]):not([class]) {\n color: inherit;\n text-decoration: none;\n\n @include hover() {\n color: inherit;\n text-decoration: none;\n }\n}\n\n\n//\n// Code\n//\n\npre,\ncode,\nkbd,\nsamp {\n font-family: $font-family-monospace;\n @include font-size(1em); // Correct the odd `em` font sizing in all browsers.\n}\n\npre {\n // Remove browser default top margin\n margin-top: 0;\n // Reset browser default of `1em` to use `rem`s\n margin-bottom: 1rem;\n // Don't allow content to break outside\n overflow: auto;\n // Disable auto-hiding scrollbar in IE & legacy Edge to avoid overlap,\n // making it impossible to interact with the content\n -ms-overflow-style: scrollbar;\n}\n\n\n//\n// Figures\n//\n\nfigure {\n // Apply a consistent margin strategy (matches our type styles).\n margin: 0 0 1rem;\n}\n\n\n//\n// Images and content\n//\n\nimg {\n vertical-align: middle;\n border-style: none; // Remove the border on images inside links in IE 10-.\n}\n\nsvg {\n // Workaround for the SVG overflow bug in IE10/11 is still required.\n // See https://github.com/twbs/bootstrap/issues/26878\n overflow: hidden;\n vertical-align: middle;\n}\n\n\n//\n// Tables\n//\n\ntable {\n border-collapse: collapse; // Prevent double borders\n}\n\ncaption {\n padding-top: $table-cell-padding;\n padding-bottom: $table-cell-padding;\n color: $table-caption-color;\n text-align: left;\n caption-side: bottom;\n}\n\nth {\n // Matches default `