[{"content":"","date":"2021-01-10","externalUrl":null,"permalink":"/en/posts/","section":"Articles","summary":"","title":"Articles","type":"posts"},{"content":"","date":"2021-01-10","externalUrl":null,"permalink":"/en/categories/","section":"Categories","summary":"","title":"Categories","type":"categories"},{"content":"This article is a follow-up of part 1.\nNode-Red: record data # Fetch MQTT messages… # As introduced, we’re going to record data coming up on the broker by using Node-Red on a PostgreSQL database.\nIf setting-up Node-Red is successfull, you can reach it on port 1880 (e.g. raspberrypi.local:1880). Then over its user interface, you need to set-up:\npostgresql nodes by Digitaloak And that’s it!\nAn MQTT node already exists. By placing a MQTT IN node on the current flow tab, you can configure the broker after double-clicking on it as you did previously in python. Then edit the node itself with the correct channel name under Topic to listen to this sensor.\nNode Red works with scopes. There are three:\nmsg: this scope points to objects shared among all nodes that are linked with each other. The object that interests us here is msg.payload, it holds the message coming from your source MQTT IN node. flow: this scope points to all objects you wish to share with all nodes on that tab, whether they’re linked or not. global: as its name indicates it, this scope is shared with all flows, thence all tabs. Here is a flow using the office sensor as example, zigbee2mqtt/TH_bureau, which outputs to the debugger (printed on the right):\nThe output message from the MQTT canal is held in a javascript object.\nAs Output, use parsed JSON object to receive a javascript object as shown on the debugger.\nWe find our 6 features: battery level, humidity, link quality, air pressure, temperature and the battery voltage in mV.\nOur objective here is to get the same message format for each similar sensor. We can then use a unique flow for all sensors: fewer nodes means less code, so also fewer bugs and less maintenance!\nLink quality is not always sent by the Xiaomi sensors. So we need to add it should it be missing. We can also add a friendly name in the msg rather than using the long Topic. We use a switch node to detect whether linkquality is lacking and change nodes to add missing elements.\nThe name object is added, linkquality as well if missing\n…and insert them in SQL tables # As indicated in the introduction of the preceding article, we have created a th schema within which we will add a table per sensor. Our objective in our flow is to create the tables if they’re missing, then insert the new data.\nAdd a PostgreSQL node to your flow. By double clicking, you can here as well indicate the server authentication parameters. You can also deactivate the Output function: we are only inserting.\nBetween the MQTT IN node and the postgresql node, you need to add two nodes:\na switch node within which we inject the SQL query parameters inside the msg.data object. a template node within which we write our SQL query and put it in the msg.query object. In the first node, you create an empty object then declare your parameters.\nAn empty object is created, then we add sensor data within it\nBehind msg.data.sensors is:\n{\u0026#34;name\u0026#34;:msg.name, \u0026#34;battery\u0026#34;: msg.payload.battery, \u0026#34;humidity\u0026#34;:msg.payload.humidity, \u0026#34;pressure\u0026#34;:msg.payload.pressure, \u0026#34;temperature\u0026#34;:msg.payload.temperature, \u0026#34;voltage\u0026#34;:msg.payload.voltage, \u0026#34;linkquality\u0026#34;:msg.payload.linkquality, \u0026#34;msg_ts\u0026#34;:$now() } Note msg_ts. It has been added to capture the datetime. We could have also used the default now value of PostgreSQL, but I prefer capturing a time as close as possible to the emitting event.\nIn the second node, select the msg.query property, use the Mustache template format, select text as output format and write the following SQL query:\nCREATE TABLE IF NOT EXISTS th.{{{data.sensors.name}}}( ID SERIAL PRIMARY KEY NOT NULL, battery INT, humidity REAL NOT NULL, pressure REAL, temperature REAL NOT NULL, voltage INT, linkquality INT, msg_ts TIMESTAMP NOT NULL ); INSERT INTO th.{{{data.sensors.name}}}(battery, humidity, pressure, temperature, voltage, linkquality, msg_ts) VALUES ({{{data.sensors.battery}}}, {{{data.sensors.humidity}}}, {{{data.sensors.pressure}}}, {{{data.sensors.temperature}}}, {{{data.sensors.voltage}}}, {{{data.sensors.linkquality}}}, \u0026#39;{{{data.sensors.msg_ts}}}\u0026#39;); COMMIT; The first part of the query is explicit: if there is no table named after the sensor, it should be created. We find our 6 features, the datetime and a unique ID.\nThe second part of the request is the insert. Timestamp is between single quotes as it is a string, not an int.\nNow all you need to do is to put everything together! We can link several channels to the same switch node after giving the sensor names as can be seen in the image herebelow.\nHere is an example to import (Sandwich menu → import)\nPanel: watch historical data # As we did for live data, we can build a Panel application to visualize sensor measurements held in the database. This time the Dashboard will be more classic and easier to implement.\nHerebelow a notebook describing step after step how to build it.\nAs previously, you can use this notebook as code source for your application:\npanel serve yournotebook.ipynb --port 5006 --address localhost --show above command will open a webpage showing only the last element, called with the .servable() method. It would be smarter to clean the notebook a little as every cell will be executed upon calling above command. Or you could directly use the notebook available on GitHub.\nImplement # You can now add this application to your raspberry pi service. Bokeh, the library behind Panel, let you serve several applications in parallel. It automatically generates a home webpage letting your users pick the application.\nSimply modify the ExecStart line from your home_on_bokeh.service file by adding the application (the modification adds plotting_hist_data.py):\nsudo nano /etc/systemd/system/home_on_bokeh.service Description=Serve panel to access zigbee sensor data After=multi-user.target [Service] Type=simple ExecStart=/home/pi/.local/bin/panel serve /home/pi/home_on_bokeh/plotting_live_data.py /home/pi/home_on_bokeh/plotting_hist_data.py --port 80 --address yourrpiaddress Restart=on-abort User=pi [Install] WantedBy=multi-user.target If you’ve used environment variables for authenticating to your database, you must add them:\nsudo systemctl edit home_on_bokeh.service [Service] Environment=\u0026#34;MQTT_ADDRESS=localhost\u0026#34; Environment=\u0026#34;MQTT_USER=pi\u0026#34; Environment=\u0026#34;MQTT_PASSWORD=verycomplexpassphrase\u0026#34; Environment=\u0026#34;SQL_ADDRESS=localhost\u0026#34; Environment=\u0026#34;SQL_USER=pi\u0026#34; Environment=\u0026#34;SQL_PASSWORD=unguessablepassword\u0026#34; Environment=\u0026#34;BOKEH_ALLOW_WS_ORIGIN=raspberrypi.local:80,192.168.10.10:80\u0026#34; Now restart your service:\nsudo systemctl restart home_on_bokeh.service There you go! This second application is slower to start than the first one. On top of it, the poor RPi must run a Node-Red server and a postgresql server.\nSwaping to a RPi 4 will certainly help. But if all you do concerns domotic applications, I strongly suggest you to use Home Assistant and add the Grafana and InfluxDB modules to reach a similar result (well, without all the fun 😉 ).\n","date":"2021-01-10","externalUrl":null,"permalink":"/en/2021/01/10/dashboards-for-iot-sensors-part-2-2/","section":"Articles","summary":"","title":"Dashboards for IoT sensors, part 2/2","type":"posts"},{"content":"","date":"2021-01-10","externalUrl":null,"permalink":"/en/tags/holoviews/","section":"Tags","summary":"","title":"Holoviews","type":"tags"},{"content":" About me Who I am, what I like, and what I stand for. About me My expertise Many years of data platform engineering and data science team leadership in the manufacturing industry. Discover my expertise and the services I offer. What I can do for you My blog A few articles I did not want to let go: industrial data, IoT dashboards and Python. Read the articles ","date":"2021-01-10","externalUrl":null,"permalink":"/en/","section":"Home","summary":"","title":"Home","type":"page"},{"content":"","date":"2021-01-10","externalUrl":null,"permalink":"/en/series/iot-sensors/","section":"Series","summary":"","title":"Iot-Sensors","type":"series"},{"content":"","date":"2021-01-10","externalUrl":null,"permalink":"/en/tags/mqtt/","section":"Tags","summary":"","title":"Mqtt","type":"tags"},{"content":"","date":"2021-01-10","externalUrl":null,"permalink":"/en/tags/node-red/","section":"Tags","summary":"","title":"Node-Red","type":"tags"},{"content":"","date":"2021-01-10","externalUrl":null,"permalink":"/en/categories/panel/","section":"Categories","summary":"","title":"Panel","type":"categories"},{"content":"","date":"2021-01-10","externalUrl":null,"permalink":"/en/tags/panel/","section":"Tags","summary":"","title":"Panel","type":"tags"},{"content":"","date":"2021-01-10","externalUrl":null,"permalink":"/en/tags/postgresql/","section":"Tags","summary":"","title":"Postgresql","type":"tags"},{"content":"","date":"2021-01-10","externalUrl":null,"permalink":"/en/series/","section":"Series","summary":"","title":"Series","type":"series"},{"content":"","date":"2021-01-10","externalUrl":null,"permalink":"/en/tags/","section":"Tags","summary":"","title":"Tags","type":"tags"},{"content":"","date":"2021-01-02","externalUrl":null,"permalink":"/en/tags/bokeh/","section":"Tags","summary":"","title":"Bokeh","type":"tags"},{"content":"This is part 1. Part 2 is there.\nIntroduction # It’s been two years since I’ve written an article. It’s never too late to start again, especially for a subject that covers the whole chain from physical measurement to its analysis in a simple way.\nWe will therefore talk about a subject that seems particularly important to me: how to record the measurements of sensors that send their data asynchronously, visualize their live status or analyze their past measurements.\nTo do this, we will talk about humidity, temperature and atmospheric pressure sensors in the field of home automation. The objective will not be to reinvent Home Automation (HA), but to explore Node-Red and the excelent holoviz Holoviews \u0026amp; Panel libraries using sensors costing a few euros. The same principle could be applied to any field.\nIn a few sections:\nHardware: from Zigbee to MQTT Dashboard live data using Holoviews stream Record data using Node-Red and PostgreSQL Dashboard historical data Section 3 and 4 are for my next blog post.\nHardware # a computer that can run Zigbee2MQTT[EN], here a RaspberryPi 3B+. A zigbee sniffer. I opted for one advised on a guide by projetsdiy.fr: le CC2531 de Texas Instrument[FR] (links are certainly sponsored), but others are compatible [EN]. A set of sensors using the Zigbee protocol and preferably compatible with the Zigbee2MQTT library [EN]. Here, a set of temperature, humidity, pressure sensors by Xiaomi are used. The raspberryPi 3B+ will not only be a Zigbee coordinator and the MQTT broker, but also serve Node-Red, PostgreSQL and our self-developped Panel applications. Within your local network, you can of course distribute these services on different hosts.\nSetting up # We won’t be talking details here. Each module is thoroughly documented by each project website. I’ll be giving only an overview with specifics for this project.\nZigbee sniffer and MQTT broker # The documented is very good on the main website: https://www.zigbee2mqtt.io.\nA small tip: note the time and the order for which you reset your sensors. You can then find their id back on the journal using journalctl -u zigbee2mqtt.service. Then you can give them friendly names in the configuration file /opt/zigbee2mqtt/data/configuration.yaml.\nYou must also add the retain option for each sensor. We need your broker to record the last sent data by your sensor. Otherwise, if nobody is listening, the information is lost for ever. In the case of Zigbee sensor, new data may take up to one hour to be sent (remember, it’s low consumption). When rebooting your application, you may still want to know what was the last data and when it was.\nNote: Xiaomi sensors have a small button to send current measurements right away.\nExtract from the configuration file:\ndevices: \u0026#39;0x00158d00054692fd\u0026#39;: friendly_name: TH_Chambre retain: true TH for _Temperature, Humidit_y.\nDatabase # I have opted for PostgreSQL that you can simply install with sudo apt install postgresql postgresql-contrib\nI advise you to make a user, let’s call it pi, with remote access to a database called sensors. I have added a schematics th where one table per sensor will be automatically made. We’ll come back to in in the section about Node-Red.\nNode-Red # The documentation is here as well thorough: https://nodered.org/docs/getting-started/raspberrypi\nPython 3.7 and its libraries # Luckily, the last Raspbian version is compatible with Python 3.7. Simply calling sudo apt install python3 will suffice (python2 stays the default engine).\nThen:\npip3 install paho-mqtt for MQTT. pip3 install holoviews panel hvplot for the dashboard pip3 install sqlalchemy psycopg2 to access the database. On your own machine, I strongly invite you to use conda‘s virtual environment to install these. Also you can use Jupyter Notebook. One of the nice features of Panel is to be editable live, and you can use the notebook as the source code for your application.\nVisualize live data # A little bit of python… # You can reproduce herebelow notebook or check it on github here. To executed from a computer without jupyter (like a RPi), you can convert it to a python file with jupyter nbconvert yournotebook.ipynb --to python\nA full fledge Dashboard # To make it a Panel application, you must call the servable method from a Panel layout as the last line of your jupyter notebook. Using above example:\nlayout=pn.panel(room_plots) layout.servable() Then from your RPi terminal (or any other server ), call:\npanel serve yournotebook.ipynb --port 8080 --address youraddress If you want to make it accessible from your local network like a normal http website (on port 80), you must bind the python3.7 execute as follows:\nsudo setcap \u0026#39;cap_net_bind_service=+ep\u0026#39; /usr/bin/python3.7 Note that all python3.7 application will have access to ports under 1024, which can be considered as a security issue.\nYou can find my whole application on GitHub following this link. You’ll need to adapt it to your configuration of course!\nMake it a service # You now have a new app. But you want it to start automatically without having to prompt passwords and such. Then make it a service!\nIt is very simple. You first need to create a file in the right folder, as follows:\n\u0026gt;\u0026gt; sudo nano /etc/systemd/system/home_on_bokeh.service Description=Serve panel to access zigbee sensor data After=multi-user.target [Service] Type=simple ExecStart=/home/pi/.local/bin/panel serve /home/pi/home_on_bokeh/plotting_live_data.py --port 80 --address yourrpiaddress Restart=on-abort User=pi [Install] WantedBy=multi-user.target change yourrpiaddress and, if necessary, --port 80 for an accessible port. You now need to define the broker address and authentification as well as Bokeh paramters as environmental variables:\n\u0026gt;\u0026gt; sudo systemctl edit home_on_bokeh.service [Service] Environment=\u0026#34;MQTT_ADDRESS=localhost\u0026#34; Environment=\u0026#34;MQTT_USER=pi\u0026#34; Environment=\u0026#34;MQTT_PASSWORD=verycomplexpassphrase\u0026#34; Environment=\u0026#34;BOKEH_ALLOW_WS_ORIGIN=raspberrypi.local:80,192.168.10.10:80\u0026#34; This file is accessible under /etc/systemd/system/home_on_bokeh.service.d .\nNote the BOKEH_ALLOW_WS_ORIGIN variable: without it, your thing isn’t accessible! Change the address here by your real address.\nIf you’d prefer having nobody reading its content (and passphrases!), changing access rights is not enough, see this server fault response. You can now start the service:\n\u0026gt;\u0026gt; sudo systemctl start home_on_bokeh enable it for automated start:\n\u0026gt;\u0026gt; sudo systemctl enable home_on_bokeh check that everything goes well (no sudo is necessary)\n\u0026gt;\u0026gt; systemctl status home_on_bokeh And check the logs:\n\u0026gt;\u0026gt; journalctl -u home_on_bokeh -r You can now access the dashboard from any of your devices present on your local network!\nNext time, I’ll discuss how Node-Red can be used to record the data then make a new dashboard to look at them (hint: it’s already on GitHub).\n","date":"2021-01-02","externalUrl":null,"permalink":"/en/2021/01/02/dashboards-for-iot-sensors/","section":"Articles","summary":"","title":"Dashboards for IoT sensors","type":"posts"},{"content":"","date":"2021-01-02","externalUrl":null,"permalink":"/en/tags/holoviz/","section":"Tags","summary":"","title":"Holoviz","type":"tags"},{"content":"","date":"2021-01-02","externalUrl":null,"permalink":"/en/tags/iot/","section":"Tags","summary":"","title":"IoT","type":"tags"},{"content":"","date":"2021-01-02","externalUrl":null,"permalink":"/en/tags/postgres/","section":"Tags","summary":"","title":"Postgres","type":"tags"},{"content":"","date":"2021-01-02","externalUrl":null,"permalink":"/en/tags/zigbee/","section":"Tags","summary":"","title":"Zigbee","type":"tags"},{"content":"","date":"2018-05-20","externalUrl":null,"permalink":"/en/categories/computing/","section":"Categories","summary":"","title":"Computing","type":"categories"},{"content":"","date":"2018-05-20","externalUrl":null,"permalink":"/en/tags/hpc/","section":"Tags","summary":"","title":"Hpc","type":"tags"},{"content":"","date":"2018-05-20","externalUrl":null,"permalink":"/en/tags/machine-learning/","section":"Tags","summary":"","title":"Machine Learning","type":"tags"},{"content":"I was granted an access to the super computer of the University of Strasbourg, which is perfect for tackling machine learning challenges where many models need to be tried.\nUsing scikit-learn, it is relatively easy to take advantage of the multiple cores of a PC with the n_jobs option. Parallel computing on a remote machine using the Slurm queuing system is not as straightforward.\nI want to achieve the following:\nUse python 3 and be able to install any library Run jobs in parallel for any custom function With a little search and testing, I came up with the following solution.\nConnecting and setting up your environment # After registering, you will obtain a username and a password. If you are using Ubuntu like me, connecting through ssh is easy. Open a terminal and type\nssh -Y username@hpc-login.u-strasbg.fr followed by your password. You can also use sshpass if you don’t want to type your password in blind mode.\nInstalling Anaconda # Anaconda is a widely used python package manager. It is pre-installed on the HPC and could be activated with load module python/Anaconda3. However, I was unable to add new libraries using the conda install command. Luckily, it can be installed without admin rights! Simply do the following in the terminal:\nwget \u0026#34;https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh\u0026#34; bash Miniconda3-latest-Linux-x86_64.sh #installs in ~/conda export PATH=$HOME/conda/bin:$PATH conda install scikit-learn -y you can add any python package you need with conda install.\nRunning tests in parallel # workflow # My workflow consists in developping on my PC and testing with little data. When I want to use the whole train data set, I can then transfer everything using scp.\nFor testing purpose, you can make a test_parallel directory on both your PC and the remote super computer.\nmkdir test_parallel cd ./test_parallel Python code # We are going to use the standard “digits” data set included as an example in scikit-learn. We will not try to optimize for the perfect model, but only show how a custom function to classify this data set can be tested with several parameters in parallel.\nAs I said earlier, it is not as straightforward as calling the option n_jobs in most sklearn classes. We will need to use the package ipyparallel from the ipython project. Don’t forget to install it using conda install ipyparallel!\nIt requires functions to be pickle-able, so we will have to create two files: one containing your script script.py and one containing your functions some_funcs.py.\nNote: unless you implement your own algorithm, using functions from the sklearn.model_selection rather than a custom function is certainly much better. For debugging and testing purpose, home-made functions can let you write information into files.\nscript.py # #!/usr/bin/env python3 # -*- coding: utf-8 -*- \u0026#34;\u0026#34;\u0026#34; Run it with: python3 script.py -p ipy_profile where ipy_profile is the name of the ipython profile. @author: hyamanieu \u0026#34;\u0026#34;\u0026#34; import argparse import logging import os import sys from sklearn.externals.joblib import Parallel, parallel_backend from sklearn.externals.joblib import register_parallel_backend from sklearn.externals.joblib import delayed from sklearn.externals.joblib import cpu_count from sklearn.datasets import load_digits from sklearn.model_selection import train_test_split from ipyparallel import Client from ipyparallel.joblib import IPythonParallelBackend import numpy as np import datetime #module in the same directory from some_funcs import SVC_rbf FILE_DIR = os.path.dirname(os.path.abspath(__file__)) sys.path.append(FILE_DIR) #prepare the logger parser = argparse.ArgumentParser() parser.add_argument(\u0026#34;-p\u0026#34;, \u0026#34;--profile\u0026#34;, default=\u0026#34;ipy_profile\u0026#34;, help=\u0026#34;Name of IPython profile to use\u0026#34;) args = parser.parse_args() profile = args.profile logging.basicConfig(filename=os.path.join(FILE_DIR,profile+\u0026#39;.log\u0026#39;), filemode=\u0026#39;w\u0026#39;, level=logging.DEBUG) logging.info(\u0026#34;number of CPUs found: {0}\u0026#34;.format(cpu_count())) logging.info(\u0026#34;args.profile: {0}\u0026#34;.format(profile)) #prepare the engines c = Client(profile=profile) #The following command will make sure that each engine is running in # the right working directory to access the custom function(s). c[:].map(os.chdir, [FILE_DIR]*len(c)) logging.info(\u0026#34;c.ids :{0}\u0026#34;.format(str(c.ids))) bview = c.load_balanced_view() register_parallel_backend(\u0026#39;ipyparallel\u0026#39;, lambda : IPythonParallelBackend(view=bview)) #Get data digits = load_digits() #prepare it for the custom function X_train, X_test, y_train, y_test = train_test_split(digits.data, digits.target, test_size=0.3) #some parameters to test in parallel param_space = { \u0026#39;C\u0026#39;: np.logspace(-6, 6, 12), } gamma = 0.1 with parallel_backend(\u0026#39;ipyparallel\u0026#39;): scores = Parallel(n_jobs=len(c))(delayed(SVC_rbf)(C, gamma, X_train, X_test, y_train, y_test, profile) for C in param_space[\u0026#39;C\u0026#39;]) #write down the scores in a file. with open(\u0026#39;scores_rbf_digits.csv\u0026#39;, \u0026#39;w\u0026#39;) as f: f.write(\u0026#39;C,gamma,MAE\\n\u0026#39;) f.write(\u0026#34;\\n\u0026#34;.join(\u0026#39;,\u0026#39;.join(str(c) for c in l) for l in scores)) f.write(\u0026#39;\\n\u0026#39;) Make sure to import joblib functions from sklearn.external, not from joblib itself.\nIf you prefer using the GridSearchCV from sklearn rather than a custom function (strongly advised), you can replace the last bit with:\nfrom sklearn.model_selection import GridSearchCV svc_rbf = SVC(kernel=\u0026#39;rbf\u0026#39;, shrinking=False) search = GridSearchCV(svc_rbf, param_space, return_train_score=True, n_jobs=len(c)) with parallel_backend(\u0026#39;ipyparallel\u0026#39;): search.fit(X_train, y_train) results = search.cv_results_ results = pd.DataFrame(results) results.to_csv(os.path.join(FILE_DIR,\u0026#39;scores_rbf_digits.csv\u0026#39;)) some_funcs.py # import os import datetime from sklearn import metrics from sklearn.svm import SVC import numpy as np now = datetime.datetime.now FILE_DIR = os.path.dirname(os.path.abspath(__file__)) def SVC_rbf(C,gamma, X_train, X_test, y_train, y_test, profile): file_path = os.path.join(os.getcwd(), \u0026#39;{0}_C{1:06}.log\u0026#39;.format(profile,C)) #logging will not work from the HPC engines #need to write into a file manualy. with open(file_path, \u0026#39;a+\u0026#39;) as f: f.write(\u0026#39;new task for C=\u0026#39;+str(C)+\u0026#39; and gamma=\u0026#39;+str(gamma)+\u0026#39;\\n\u0026#39;) t0 = now() with open(file_path, \u0026#39;a+\u0026#39;) as f: f.write(\u0026#39;Start learning at {0}\\n\u0026#39;.format(t0.isoformat())) svc_rbf_reg = SVC(kernel=\u0026#39;rbf\u0026#39;, C=C, gamma=gamma, shrinking=False) svc_rbf_reg.fit(X_train,y_train) predictions = svc_rbf_reg.predict(X_test) score = metrics.mean_absolute_error(y_test,predictions) ##uncomment if you want to make the function slower #with open(file_path, \u0026#39;a+\u0026#39;) as f: # f.write(\u0026#39;Compute complex matrix inverse\u0026#39;) # m = np.random.randn(10000,10000) # np.linalg.inv(m) t1 = now() h = (t1-t0).total_seconds()//3600 m = (t1-t0).total_seconds()//60 - h*60 s = (t1-t0).total_seconds() -m*60 - h*60 with open(file_path, \u0026#39;a+\u0026#39;) as f: f.write(\u0026#39;Finished at {0} after \u0026#39; \u0026#39;{1}h {2}min {3:0.2f}s\\n\u0026#39;.format(t1.isoformat(), h,m,s)) f.write(\u0026#39;SVC rbf\\n\u0026#39;) f.write(\u0026#39;C: {0}, gamma: {1}\\n\u0026#39;.format(str(C),str(gamma))) f.write(\u0026#39;MAE: {0}\\n\u0026#39;.format(str(score))) return (C, gamma, score) And voila!\nRun your code locally # Let’s first test it on your own PC. You’ll need to open 1+n terminals, where n is the number of cores you can to use and run:\nipcontroller --profile=ipy_profile ipengine --profile=ipy_profile (*n) Alternatively, you can also run a cluster in a single terminal with\nipcluster start --profile=ipy_profile \u0026amp; It will automatically start as many engines as there are cores. You can then stop it by typing:\nipcluster stop --profile=ipy_profile You can find other options in the documentation. You can now run your python script with python3 script.py. If you used ipcontroller+ipengine(s), you should see the controller dispatching the jobs to the engines. Also, the log files will be created.\nRun it on the remote HPC # The first thing you need to do is to copy both python files to the HPC:\n#run this on your local computer scp *.py username@hpc-login.u-strasbg.fr:~/test_parallel Now you need to make a bash file to start the engines, your script, and define the needed resources in the header for Slurm.\n#run this after ssh-ing into the HPC cd ~/test_parallel nano start_script.sh You can then insert:\n#! /bin/bash #SBATCH -p public #available partition, depends on your HPC #SBATCH -J ipy_engines #job name #SBATCH -n 4 # 4 cores, you can increase it #SBATCH -N 1 # 1 node, you can increase it #SBATCH -t 1:00:00 # Job is killed after 1h #SBATCH --mail-type=END # Sends an email when the job finishes #SBATCH --mail-user=nickname@domain.com#your email address #the following deletes all the ipython profiles older than 1 day. find ~/.ipython/profile_job* -maxdepth 0 -type d -ctime +1 | xargs rm -r #create a new ipython profile appended with the job id number profile=job_${SLURM_JOB_ID} echo \u0026#34;Creating profile_${profile}\u0026#34; $HOME/conda/bin/ipython profile create ${profile} $HOME/conda/bin/ipcontroller --ip=\u0026#34;*\u0026#34; --profile=${profile} \u0026amp; sleep 10 #srun: runs ipengine on each available core srun $HOME/conda/bin/ipengine --profile=${profile} --location=$(hostname) \u0026amp; sleep 25 echo \u0026#34;Launching job for script $1\u0026#34; $HOME/conda/bin/python $1 -p ${profile} I have allocated only 4 cores to compare the performance with my PC with similar resources.\nNow exit (ctrl+X) and run it:\nsbatch start_script.sh script.py You can check where it is in the queue with queue -u username. It should not take that long: 4 cores and 1 hours computing time is rather little, it should be put on priority. The script should finish within a couple minutes only.\nYou can now compare the results on each by reading the *.log files! Once you’re done with testing, I would advise using GridSearchCV and run many more parameters than only 12! There will be a single log file and of course the results in a .csv.\nNext # I am currently using the Alsacalcul HPC to find a solution from one of the ENS challenges, check them out! I will post my first solution soon, as well as how I combined working on the jupyter notebook and ran calculations on the HPC.\nsome sources I used: – https://services-numeriques.unistra.fr/les-services-aux-usagers/hpc.html – http://www.makeloft.org/2016/05/work-in-progress-parallel-ipython-from.html – http://twiecki.github.io/blog/2014/02/24/ipython-nb-cluster/ – https://github.com/scikit-learn/scikit-learn/issues/7168 (ivdorelian 10 Aug 2016) – https://stackoverflow.com/questions/38601026/easy-way-to-use-parallel-options-of-scikit-learn-functions-on-hpc – image copyright owner: AlsaCalcul Services, http://alsacalcul.unistra.fr/\n","date":"2018-05-20","externalUrl":null,"permalink":"/en/2018/05/20/parallel-super-computing-with-scikit-learn/","section":"Articles","summary":"","title":"Parallel (super) computing with scikit-learn","type":"posts"},{"content":"","date":"2018-05-20","externalUrl":null,"permalink":"/en/tags/parallel-computing/","section":"Tags","summary":"","title":"Parallel Computing","type":"tags"},{"content":"","date":"2018-05-20","externalUrl":null,"permalink":"/en/tags/scikit-learn/","section":"Tags","summary":"","title":"Scikit-Learn","type":"tags"},{"content":"This website is subject to French law.\nHugues-Yanis Amanieu # A person, a parent, a biker, an independent consultant, represented by\nNEEDEXPERTS # SAS au capital de 7500€ 2 rue de la faisanderie BP40015 67380 LINGOLSHEIM SIRET : 79955462100018\nwithin the framework of an umbrella employment contract (portage salarial). Quotations and invoices will be issued by the company representing the consultant. The consultant remains solely responsible for all exchanges with the users, the content of the website, as well as the provision of a service.\nContacts # Publishing # The publishing director is the independent consultant. He bears full legal responsibility for the content of the website.\nHosting # The host is ouvaton.coop\nSociété Anonyme Coopérative à capital variable\nCapital minimum : 19 057 euros\nR.C.S. Paris B 438 168 718 (2001B11755)\nAdresse du siège :\nOuvaton Coop. SA\n16 bis, rue d’Odessa\nBoîte 37\n75014 Paris\nFrance ouvaton.coop\nCredits # Theme Blowfish by Nuno Coração\nIcons by Font Awesome (CC BY 4.0)\nSome illustrations are generated by AI\nPrivacy # Cookies may be stored automatically by your browser during your visit. These cookies are used to record your language preference and can be deleted and refused through your browser settings.\nNo information recorded by these cookies or via the contact form will be transmitted to any third parties whatsoever, except upon a written request from the user. All information and exchange platforms, including the use of a Git, used during the setup of a service will remain confidential except upon a written request from the user.\nIn the case of a quotation request, some information will have to be transmitted to NEEDEXPERTS in order to prepare it, in particular the name and address of the contracting company as well as the type of service provided.\nhCaptcha # We use the hCaptcha security service (hereinafter \u0026ldquo;hCaptcha\u0026rdquo;) on our website. This service is provided by Intuition Machines, Inc., a Delaware US Corporation (\u0026ldquo;IMI\u0026rdquo;). hCaptcha is used to check whether user actions on our online service (such as submitting a login or contact form) meet our security requirements. To do this, hCaptcha analyzes the behavior of the website or mobile app visitor based on various characteristics. This analysis starts automatically as soon as the website or mobile app visitor enters a part of the website or app with hCaptcha enabled. For the analysis, hCaptcha evaluates various information (e.g. IP address, how long the visitor has been on the website or app, or mouse movements made by the user). The data collected during the analysis will be forwarded to IMI. hCaptcha analysis in the \u0026ldquo;invisible mode\u0026rdquo; may take place completely in the background. Website or app visitors are not advised that such an analysis is taking place if the user is not shown a challenge. Data processing is based on Art. 6(1)(b) of the GDPR: the processing of personal data is necessary for the performance of a contract to which the website visitor is party (for example, the website terms) or in order to take steps at the request of the website visitor prior to entering into a contract. Our online service (including our website, mobile apps, and any other apps or other forms of access offered by us) needs to ensure that it is interacting with a human, not a bot, and that activities performed by the user are not related to fraud or abuse. In addition, processing may also be based on Art. 6(1)(f) of the GDPR: our online service has a legitimate interest in protecting the service from abusive automated crawling, spam, and other forms of abuse that can harm our service or other users of our service. IMI acts as a \u0026ldquo;data processor\u0026rdquo; acting on behalf of its customers as defined under the GDPR, and a \u0026ldquo;service provider\u0026rdquo; for the purposes of the California Consumer Privacy Act (CCPA). For more information about hCaptcha’s privacy policy and terms of use, please visit the following links: https://www.hcaptcha.com/privacy and https://www.hcaptcha.com/terms\n","date":"2018-04-20","externalUrl":null,"permalink":"/en/legal-notice/","section":"Home","summary":"","title":"Legal notice","type":"page"},{"content":"Under construction\n","date":"2018-04-02","externalUrl":null,"permalink":"/en/about/","section":"Home","summary":"","title":"About","type":"page"},{"content":"","externalUrl":null,"permalink":"/en/authors/","section":"Authors","summary":"","title":"Authors","type":"authors"},{"content":" Let\u0026rsquo;s talk about your data Whether you have a quick question or want to discuss a project in depth, pick whichever suits you best.\nPrefer a real conversation?\nBook an appointment! The form below does not load? Open it directly or send me an e-mail.\n","externalUrl":null,"permalink":"/en/contact/","section":"Home","summary":"Two ways to reach me: a quick message or a booked appointment.","title":"Contact","type":"page"},{"content":"Many organizations recognize the potential of data and artificial intelligence but lack a clear understanding of where to start, which use cases to prioritize, or what foundations are required to succeed.\nThere are two main objectives provided by this service:\nidentify the primary pain point identify quick wins This service provides a structured assessment of the current situation, including operational processes, production systems, data availability, reporting practices, and existing technology platforms.\nThe objective is to identify opportunities that can generate measurable business value while remaining technically and operationally feasible.\nTypical deliverables include:\nInventory of available data sources and systems Evaluation of data quality, accessibility, and governance Identification of additional operational and business pain points Prioritization of data and AI initiatives based on value and complexity Definition of key performance indicators and decision-support requirements High-level architecture recommendations Implementation roadmap and project sequencing This service is intended for executive teams, operations leaders, digital transformation programs, and organizations seeking a practical starting point for data-driven initiatives in the industry.\n","externalUrl":null,"permalink":"/en/expertise/opportunity-assessment/","section":"Informed decision making for the Industry","summary":"Many organizations recognize the potential of data and artificial intelligence but lack a clear understanding of where to start, which use cases to prioritize, or what foundations are required to succeed.\n","title":"Industrial Data \u0026 AI Opportunity Assessment","type":"service"},{"content":"Many industrial data projects begin with ERP, reporting, or business intelligence initiatives. As projects progress, operational data, production systems, and industrial constraints often become critical success factors.\nThis service provides hands-on data engineering support during implementation and delivery phases, with a focus on production environments and industrial data sources.\nTypical activities include:\nIndustrial data acquisition and integration with direct communication with PLC Data pipeline development and orchestration ETL and ELT implementation Operational and analytical data modeling Time-series and production data management Data mart and KPI layer development Data quality and validation processes Integration with reporting, monitoring, and analytics platforms Deployment and operation of data services The objective is to bridge the gap between industrial operations, software systems, and analytics platforms, ensuring that production data can be transformed into reliable and actionable information for business and operational stakeholders.\n","externalUrl":null,"permalink":"/en/expertise/it-ot-engineering/","section":"Informed decision making for the Industry","summary":"Many industrial data projects begin with ERP, reporting, or business intelligence initiatives. As projects progress, operational data, production systems, and industrial constraints often become critical success factors.\n","title":"Industrial Data Engineering (IT/OT)","type":"service"},{"content":"Once strategic objectives and business requirements have been defined, industrial organizations need a concrete architecture capable of supporting implementation, operation, and future growth.\nThis service focuses on the design of industrial data platforms and the information structures required to create a reliable and maintainable foundation.\nThe scope may include:\nData platform architecture design fitting your cybersecurity strategy Industrial and business system integration patterns Data flow and processing architecture Data storage and analytical layer design Information modelling and ontology definition Asset, production, product, and process data structures Security, access management, and governance principles Technology selection and implementation guidelines Particular attention is given to establishing a common vocabulary and data model across systems, teams, and business domains. This foundation enables consistent reporting, traceability, analytics, and future AI initiatives.\nThe resulting architecture serves as a reference for implementation teams, software developers, data engineers, system integrators, and technology partners.\n","externalUrl":null,"permalink":"/en/expertise/platform-architecture/","section":"Informed decision making for the Industry","summary":"Once strategic objectives and business requirements have been defined, industrial organizations need a concrete architecture capable of supporting implementation, operation, and future growth.\n","title":"Industrial Data Platform Architecture \u0026 Information Modeling","type":"service"},{"content":" Industrial data platform engineering Whether decision making is done by an AI or by a human agent, the first pillar to any successful implementation is clean and structured data.\nWork with me Services # Industrial Data \u0026 AI Opportunity Assessment 166 words\u0026middot;1 min Service Industrial Data Engineering (IT/OT) 137 words\u0026middot;1 min Service Industrial Data Platform Architecture \u0026 Information Modeling 145 words\u0026middot;1 min Service Lessons from the Field # Sharing what works Focus Keep the focus on your pain point Iterate Build on several, successive small successes Empower Empower your employees with controlled low-code platforms Structure Maximize order with clear conventions About my expertise # My assessment # Modern laboratory and industrial environments generate large volumes of data from production equipment, legacy and modern industrial protocols, business applications, quality systems, and operational processes. The challenge is not collecting data, but turning it into reliable information that supports daily operations, performance monitoring, and strategic decision making.\nMy work # I design, build, and operate industrial data platforms that connect production systems with business intelligence and analytics tools. My expertise covers the full data lifecycle, including:\nIndustrial data acquisition and integration (MQTT, OPC-UA, Modbus, custom interfaces, APIs) Data pipeline design and orchestration ETL/ELT workflows and data transformation Relational and time-series data management Data marts and KPI-oriented analytical models Production performance and productivity reporting Containerized application deployment and operation Identity and access management for data-driven applications Dashboarding and reporting platforms (Power BI, Grafana, custom applications) Data governance and single-source-of-truth architectures Platform Independence # I design solutions to minimize vendor lock-in and keep switching costs low. From hosting infrastructure to AI models and LLM providers, my architectures prioritize portability, interoperability, and the freedom to change suppliers at little cost.\nTechnical details \u0026amp; technologies Infrastructure and hosting\nI design portable solutions for deployment across a wide range of environments:\nCloud providers: Microsoft Azure, AWS, Google Cloud, OVHcloud, Hetzner, and other providers. On-premise infrastructure: Physical servers, virtual machines, and hypervisors. Deployment and orchestration: Docker, Terraform, and SkyPilot, selected according to the project\u0026rsquo;s needs. The goal is to make infrastructure replaceable without rebuilding the entire solution.\nAI and LLM integration\nI help organizations integrate AI capabilities without becoming dependent on a single model or supplier:\nCommercial LLM APIs: Integration with leading providers, including OpenAI, Anthropic, Mistral, and Google. Open-weight models: Deployment of models from Hugging Face and other model ecosystems, on-premise or on remote infrastructure. Independent inference: Self-hosted inference environments for greater control over data, deployment, and operating costs. LLM routing and cost optimization: Tools such as LiteLLM to centralize access to multiple providers and simplify model switching. My principle: Choose the best-performing solution for the use case, retain control over the architecture, and keep the cost of switching providers as low as reasonably possible.\nMy Approach # My approach combines data engineering, software engineering, and industrial operations knowledge to deliver pragmatic, maintainable, and business-focused solutions.\nI believe industrial digitalization should be built on open, modular and interoperable architectures, using open-source software as reusable building blocks rather than relying on one-size-fits-all solutions.\nEvery manufacturing plant has its own requirements, but many of the underlying challenges are shared across industries. By building on open technologies and reusable components, manufacturers can combine proven solutions, integrate systems from different vendors, and retain the flexibility to evolve their digital infrastructure over time.\nOPC-UA is a compelling example of this principle in action: its open, standardized approach to industrial data exchange enables interoperability across equipment and software from different vendors.\nCV # Li-ion batteries and Data Science # I have been working since 2010 in the Li-ion battery field. I have developed a particular interest in improving our interaction with the complex measurements produced in this field. From crystal properties during my PhD to systemic control as of now.\nBatteries are in fact the perfect candidates for data analytics: they are complex and involve a lot of unknown underlying mechanisms, yet experimental set-ups are well structured thence produce tidy data. The same tools can be developed for many domains, including the semi conductor industry, medical field, acoustics, etc.\nTimeline # Team Leader Data Science \u0026amp; Engineering 2023 – Present Leclanché Leading a team turning production and quality data into decisions, by people or automatically. Data Scientist, Production Engineering 2019 – 2023 Leclanché Factory digitization, automated analytical reports, ad-hoc analytics. R\u0026amp;D Project Manager 2016 – 2019 Leclanché EU-funded projects; built a Python/MySQL pipeline for lab and production measurement data. PhD, Materials Science (Summa Cum Laude) 2015 Univ. Duisburg-Essen Coupling of mechanical failure and electrochemical activity in Li-ion batteries. Research Engineer 2012 – 2015 Robert Bosch GmbH Finding accurate propertiers of Li-ion electrode materials through new measurement techniques for a simulation team. Physics engineering 2011 INSA Toulouse Applied physics and nanotechnologies. Student society: theater writing and playing. ","externalUrl":null,"permalink":"/en/expertise/","section":"Informed decision making for the Industry","summary":" Industrial data platform engineering Whether decision making is done by an AI or by a human agent, the first pillar to any successful implementation is clean and structured data.\n","title":"Informed decision making for the Industry","type":"expertise"},{"content":"","externalUrl":null,"permalink":"/en/tags/service/","section":"Tags","summary":"","title":"Service","type":"tags"}]