Skip to main content

Machine Learning. Part III

Non-residential building occupancy modeling. Part III. Defining occupancy patterns.

Recalling from the last part II we have got building occupancy data-set. In this part I will apply k-means cluster algorithm in order to identify typical occupancy patterns with daily resolution. To better visualize input data we have, see the following table below:

Month Day Weekday Minutes Temperature Relative humidity Air Velocity Occupancy out of 24
7 31 3 779 23 89 1.3411 0
8 1 4 823 24 88 3.578 2
... ... ... ... ... ... ... ...
So I changed initial data by transforming Matlab absolute time readings into month, day, weekday(where 1 - Sunday,2 - Monday etc.), day time in minutes (with 15 min time step); temperature,velocity and humidity is general outdoor data; and finally total building occupancy. Original data contained binary occupancy but I decided to combine it for better description of daily occupancy of a whole building. One remark: since we have not considering personal occupancy, we cannot consider personal data inputs like temperature, CO2, humidity etc for each person. We can only use general data equal for every occupant such as outdoor weather readings introduced on table above.
Thus, the first task is to estimate the appropriate k number representing number of centroids or clusters. If do not remember how k-means algorithm works go to this site. To estimate k I has drown plot of k and cost function (also called cost function):
 import pylab as pl  
 import pandas as pd  
 from sklearn.cluster import KMeans  
 df = pd.read_csv('NewClusterInput.csv',header=None)  
 Nc = range(1, 20)  
 kmeans1 = [KMeans(n_clusters=i) for i in Nc]  
 score = [kmeans1[i].fit(df).score(df) for i in range(len(kmeans1))]  
 pl.plot(Nc,score)  
 pl.xlabel('Number of Clusters')  
 pl.ylabel('Score')  
 pl.title('Elbow Curve')  
 pl.savefig('Elbow Curve.png')  
 pl.show()
We will get the following elbow curve:
You might notice that after k>3 module of cost function decreases sharply. I decided to take k=4 and run k-means clusterization for 4 centroids. After running k-means the following different occupancy profiles I got:

Comments

Popular posts from this blog

Machine Learning. Part II.

Non-residential building occupancy modeling. Part II. Occupancy classification So dataset was taken from this place . The dataset comprised of different sources: surveys, data logging from sensors, weather, environment variables. Total feature list consist of 118 features and can be grouped as general (occupancy, time), environment (indoor, outdoor), personal characteristics (age, office type, accepted sensation range etc), comfort/productivity/satisfaction, behavior (clothing, window, interaction with thermostat etc ), personal values (choices on different set points). It contains data on 24 occupants whether it private office or joint one, the first task is to implement binary classification of each occupant using some input data from sensors and time. For rapid protoyping I will use python Tensor Flow wrapper Keras along Anaconda framework. First, loading all required libraries from keras.models import Sequential from keras.layers import Dense import numpy ...

Application of Reinforcement Learning in HVAC systems. Part 2

So, how to model an office building to simulate the work of our controller? In short, I have used the following list of programs: Matlab, EnergyPlus and MLE+ in tandem. First things first, EnergyPlus - is an building simulation engine that will allow you to modulate maybe not all but most of the physical phenomena running inside real physical structures, including heat transfer and temperature spread. Even though it is a quite a hard to understand how to use EnergyPlus if you are not expert (maybe even for civil engineers), you can always download already designed models of a buildings like I did), which can be found on energy.gov site. Therefore, I took one floor three office medium building EnergyPlus model that comes with and .idf and weather files. Basically, the building has three rooms with electric radiant heating floors and one window and some ventilation system. Simple schematics shown on a picture below: As you may guess, I want to be able to test some controllers on th...

Machine Learning. Grid search

How to choose best fit parameters for your ANN or SVM model using scikit learn grid search ? (This topic refers to classification problem). As a beginner, after creating a couple of simple neural networks either via tensorflow or Matlab I was thinking about one question: How do I decide which network architecture (number of layers, neurons) and parameters (epoch number, batch size, optimization algorithms and initialization types) to choose? And actually, this question was answered via Grid Search scikit python library that automatizes process of the best parameters. In example below I tried cover all typical tuning parameters: # Since running GridSearch may be quite time/calculation consuming # I used GPU based tensorflow in order to speed-up calculation import tensorflow as tf from keras.backend.tensorflow_backend import set_session config = tf.ConfigProto() # Defining GPU usage limit to 75% config.gpu_options.per_process_gpu_memory_fraction = 0.75 ...