Skip to main content

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  
    import matplotlib.pyplot as plt  
    # fix random seed for reproducibility  
    numpy.random.seed(15) 
    
  • Next loading required data and splitting for X and Y (input matrix and output matrix)
  • In my case I took Time, Temperature, CO2 input values

    # load pima indians dataset  
      dataset = numpy.loadtxt("sample.csv", delimiter=",")  
      # split into input (X) and output (Y) variables  
      X = dataset[:,0:3] # Take 3 columns from 0 to 2 as inputs 
      Y = dataset[:,3]  #Third index or fourth column from input file is occupancy value 0 or 1
      # either present or absent
    
  • After, we create three layer nerual network by creating a model and adding layers one by one:
  • # create model  
     model = Sequential()# In this example, we will use a fully-connected network structure with three layers  
     model.add(Dense(7, input_dim=7, activation='tanh'))# First layer 7 neurons, 8 inputs, rectifier activation func  
     model.add(Dense(3, activation='tanh'))# hidden layer   
     model.add(Dense(1, activation='sigmoid'))  
    
  • Finally, we compiling model and training it:
  • # Compile model  
     model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])  
     # We can train or fit our model on our loaded data by calling the fit() function on the model.  
     # Fit the model or Model Training  
     model.fit(X, Y, epochs=150, batch_size=4)  
    '''
      In this case we are fitting the whole our data (X,Y) and running it for 150 iterations.
      However if you want to split your data into training and validation parts you 
      can write: 
      model.fit(X, Y,validation_split=0.33, epochs=150, batch_size=10)
      thus, model will split data into 77% training, 33% validation
    '''
     # calculate predictions  
     predictions = model.predict(X)  
     rounded = [round(x[0]) for x in predictions]  
    

Some thoughts about model's accuracy and loss

While analyzing mine dataset I tried to figure out what input data I may choose so that model will give the highest accuracy result. Of course, there is not solid and general approach towards defining correct inputs for your prediction model, but we always can experiment with it. So in my case experimented with different combinations such as [temperature, relative humidity] - accuracy 74%, [temperature, CO2] - accuracy 79.16%, [time, temperature, CO2] - accuracy 91.54%. Finally, it is possible to notice how particular data input affect accuracy. Comparing 1st and 2nd set you see that CO2 increeses accuracy on ~ 5%, therefore we may suggest that CO2 reading are preferable over relative humidity data. Big thanks to Dr.Jason Brownlee and his site about ML.

Comments

  1. Great post i must say and thanks for the information. Education is definitely a sticky subject. However, is still among the leading topics of our time. I appreciate your post and look forward to more. google ads promo code

    ReplyDelete
  2. Learn the latest technology in Artificial Intelligence & Machine Learning in real-time with the top Machine Learning Training in Hyderabad program offered by AI Patasala.
    Online Machine Learning Training in Hyderabad

    ReplyDelete

Post a Comment

Popular posts from this blog

Machine Learning

Machine Learning. Non-residential building occupancy modeling. Part I. Idea : providing occupancy driven energy efficiency model. Since about 40% of building energy goes to HVAC(heating, ventilation and air conditioning) it is quite good idea to use these equipment when it is really required,e.g. switch on the air conditioner or ventilation when people in a room The study discusses approaches towards optimizing energy consumption of commercial buildings. Such task is considered to be a part of more broad topics, e.g. smart buildings, green buildings. During the past years, the number of papers dedicated to energy efficiency optimization in buildings has been growing which confirms societal concern about finding the most efficient methods of improving energy usage by buildings. To maximize building’s energy efficiency various methods are known and can be split into re-organizational advances and strengthening currently employed management systems [1], [2]. This methods incl...

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...