Do you want to share the code for the project.
I am trying to find out something like this, but dont really know how to start.
I have been collecting all the changes to a mysql database for the last year so have plenty of data for the learning
Do you want to share the code for the project.
I will share the code for the project when I feel I can provide enough instructions for people to be able to set it up easily. I have open sourced software in the past and if it isnt fair complete then you end up spending all of your time supporting people intead of developing it properly.
Currently, you would have to write all of your own SQL questions for the binary ML code and this isnt feasible for a lot of people. I am however investigating ways around this.
I’d be interested in this too. I’ve been waiting / hoping for something like this.
do you guys have any specific ideas on what to use it for?
One area that I’ve been thinking of is whether something like this can provide easier/better control of home heating than the usual rule based solutions, taking into account when people are at home, day of week etc, but also outside weather conditions. Not quite a Nest, but something that can benefit from the increased data that we have available in an openHAB type of system.
A learning solution would also be much easier to manage when there are many zones (e.g. the evohome smart thermostat system has 12 zones - which would then possibly require 12 lots of manual rules etc).
I just realised this thread now I have been thinking of the same for months now, never thought that someone tried to implement such thing. Your high rates are looking great. Do you have any suggestions what I should do in order to prepare openHab for something like this? Because I thought that if I have enough sensors/actuators and persisted data for a bigger period of time (1 year for example) it can be a good start for it.
Do you have rules defined in openHab besides this neural network? It won’t effect them? Like it learns that a proxy switch receives a command then some other switches be turned on, so it overrides them or sends the command duplicated… all your items are exposed to the neural network?
Also what hardware are you running this system on? Trainings might need a powerful computer, right? Besides training, is it using significant resources?
I’m very interested in the mode of your implementation, too!
Probably the preprocessing of the data is the biggest problem - but maybe it could be generalized for some item categories like switches or dimmer.
I will share it as soon as I have something. However this is a long-range project for me, so now I just started grabbing as many info as I can before I start to implement my way. I have to make my OH as stable as I can and also buy a more powerful server…
I plan to start off with only one light. Tomorrow I’ll try to grab as much data from the past months as I can get.
after normalizing it, hopefully I can train a simple net using the time of day and presence as parameter and the on off states as output classifiers.
not sure about the hidden layer though!
Update: I have done some experiments with the history data of my kitchen light. Just extracted the data with time stamps and trained a classifier for ON and OFF using a 3 layer NN in self written python code.
I have not yet included presence as parameter, getting about 70 percent confidence on the training and the validation set.
Thought I would just post an update. I have been testing out the neural network cluster for a few months with the one set up and despite some promising initial readings, I was only getting around 80% accuracy. So I spent a few weeks running machine learning algorithms and parameters through an evolutionary algorithm and I am happy to say I am achieving a much higher accuracy score. Mostly reporting around 99.74% which is beyond my best expectations (humans are pretty hard to predict).
The newer algorithm is now much more flexible. Not only is it getting much higher results, but it is also a multi-classification algorithm. So instead of just knowing if something should be on or off, it can say what setting it should be set too - it even predicted the humidity for today (5% off but pretty damn close).
Additionally, I have re-written the historical/training data code so it can dynamically figure out what data you have and format it correctly - no more writing a custom SQL query for your house.
Lastly, the new algorithm is much much much faster. It can train 3 months of data and find a prediction in a few seconds. if you save the training run it will make a prediction within a few milliseconds.
As an example, this is the current prediction for the fan in the room I’m writing this from. As you can see the fan has 4 settings and it has accurately guessed what it should be (and is 99.096% sure):
Bedroom Fan: LOW : 99.096% MEDIUM : 0.702% OFF : 0.202% HIGH : 0.0% Best Guess : LOW (99.096%) Currently : LOW
Study Light: OFF : 0.0% ON : 100.0% Best Guess : ON (100.0%) Currently : ON
TV Source: HDMI1 : 100.0% TV : 0.0% Best Guess : HDMI1 (100.0%) Currently : HDMI1
It was actually pretty hard to find anything that was <100% or incorrect.
So, I am pretty confident in how things are now currently running and I am trying to clean up some of the code and writing some documentation so I can publish it on GitHub for other people to test out and improve on.
If you are interested in testing it out in the near future, here are some of the requirements:
- Code is written in python 2.7 and tested on a Linux operating system (can be run on the same machine as openhab or a different machine)
- It currently uses MySQL for historical/training data but it was fairly easy to modify this to use SQLite too. However, if you are not a developer I suggest setting up MySQL data now.
- Currently I have been running with approximately 3 months worth of training data. I suspect accuracy would be much lower with an only a few weeks worth of historical readings.
- Haven’t tested this on a raspberry pi yet. It will likely work fine, but not sure how fast it will be.
Can’t wait to share this with the rest of the OpenHab community. I’m really hoping that we can almost stop writing rules(or at least drastically reduce them) and get our houses to learn from us. I personally feel like this could be the future of home automation.
is your “current prediction” based on in-sample or out-of-sample data?
Sounds very interesting! It would be nice to have an overview of what you are actually doing (in a bit more detail), Inputs/Outputs, etc.
I’d like to try this myself, so I’m looking forward to your writeup/github link.
Have you seen this post of mine ? Probably no because of the thread it is in.
Is that idea of mine (to have a generic ML module to provide ‘more intelligent’ triggers) something your algorithm/implementation could, well let’s say be developed into ?
The current prediction is based on out of sample data. Basically, training on historical data daily then predictions based on current data during the day.
I hadn’t read that post before but it does sound fairly similar. I will however need to come up with a benchmark for measuring when the results have enough accurately to enable - currently you have to manually specify which items you want actuated, though I suspect most users would want to define this themselves anyway. My stuff seems to be mostly the “intelligence” you spoke about it your post.
@nodgesoft I am about to initiate something very similar as a university project. However, if you are about to publish your code, it wouldn’t make sense to create something new from scratch. It would be probably better if I contribute my ideas based on the structure that you will propose.
Would that be okay for you? Do you have a schedule in mind?
Up to now you are working only with neuronal networks, right?
I cant wait for your release.
I have been waiting for a long time now and through that you had canceled the project.
I have been collecting all the data from Items into MySQL for about ½ year now.
So should have some data for training ready
Any ideas are welcome but there is no schedule.
- dump data script done
- prediction script done
- auto refreh data done
Only thing really left before I publish is finding a good place to hook in the prediction script. Currently you can run it on a cron job or loop the script and it works fine but it can be a little slow if for example you want it to turn on a light when you enter a room. For things like adjusting a air conditioner this is fine.
Any input on this would be very helpful.
Lastly I suppose I should give it a name - OpenHABai maybe? Idk
Without seeing your code or architecture, using the new rules engine (jython), we can dynamically create cron based rules for each predicted date/time. Alternatively, if we stick to the DSL rules engine, we could create timers for each item to trigger a state, that is updated whenever predicted states are updated. I think the first option may be neater.
What about changes that occur spontaneously, i.e. not time-dependent but depending on change of states? This can also be learned.
Exampe: Whenever I switch on my TV, I switch off my living room lights (which is a simple rule to learn). This would also need an execution of the prediction script, but not at a fixed time. Clearly, one could write a rule that executes the prediction script on a change, but this required lots of manual coding, I assume…?