core.model package

Submodules

core.model.gaussian_process_classifier module

class core.model.gaussian_process_classifier.GPC(train, test)[source]

Bases: core.model.superclass.NormalModel

Using Gaussian Process Classifier model to predict the occupancy level

This is a normal supervised learning model.

Parameters
Return type

numpy.ndarray

Returns

Predicted occupancy level corresponding to the test Dataset

run()[source]

core.model.gaussian_process_regression module

class core.model.gaussian_process_regression.GPR(train, test)[source]

Bases: core.model.superclass.NormalModel

Using Gaussian Process Regressor model to predict the occupancy level

This is a normal supervised learning model.

Parameters
Return type

numpy.ndarray

Returns

Predicted occupancy level corresponding to the test Dataset

run()[source]

core.model.hidden_markov_model module

class core.model.hidden_markov_model.HMM(train, test)[source]

Bases: core.model.superclass.NormalModel

Using Midden Markov Model model to predict the occupancy level

This is a normal supervised learning model.

Parameters
Return type

numpy.ndarray

Returns

Predicted occupancy level corresponding to the test Dataset

run()[source]
class core.model.hidden_markov_model.HMM_DA(source, target_retrain, target_test)[source]

Bases: core.model.superclass.DomainAdaptiveModel

Using Midden Markov Model model to predict the occupancy level

This is a domain-adaptive semi-supervised learning model.

Parameters
  • source (core.data.dataset.Dataset) – the source domain with full knowledge for training the model

  • target_retrain (None or core.data.dataset.Dataset) – the labelled ground truth Dataset in the target domain for re-training the model

  • target_test (core.data.dataset.Dataset) – the Dataset in the rest of the target domain for testing by using sensor data only

  • number_of_hidden_states (int) – the number of maximum occupancy level

Return type

numpy.ndarray

Returns

Predicted occupancy level corresponding to the test Dataset

run()[source]

core.model.hmm_core module

class core.model.hmm_core.EmissionModel(meta={})[source]

Bases: object

get_prob(value)[source]

Get probability

learn(data)[source]

Learn parameters

class core.model.hmm_core.Gaussian(meta={})[source]

Bases: core.model.hmm_core.EmissionModel

get_prob(x)[source]

Get probability

learn(data)[source]

Learn parameters

class core.model.hmm_core.HMM_Core(number_of_hidden_states=2, emission_model=<class 'core.model.hmm_core.Gaussian'>, emission_params={})[source]

Bases: object

learn(hidden_seq, emission_seq)[source]
pf_predict(emission_seq, number_of_particles=50)[source]
prior(hmm)[source]
viterbi_predict(emission_seq)[source]

core.model.nn module

class core.model.nn.NN(train, test)[source]

Bases: core.model.superclass.NormalModel

Using Multi-layer Perception Classifier model to predict the occupancy level

This is a normal supervised learning model.

Parameters
  • train (core.data.dataset.Dataset) – the labelled ground truth Dataset for training the model

  • test (core.data.dataset.Dataset) – the Dataset for testing by using sensor data only

  • solver (str) – the solver for weight optimization. Choice of 'lbfgs', 'sgd', or 'adam'

  • alpha (float) – l2 penalty (regularization term) parameter

  • batch_size (int or 'auto') – size of minibatches for stochastic optimizers

  • activation (str) – activation function for the hidden layer. Choice of 'identity', 'logistic', 'tanh', or 'relu'

Return type

numpy.ndarray

Returns

Predicted occupancy level corresponding to the test Dataset

run()[source]

core.model.particle_filtering module

class core.model.particle_filtering.PF(train, test)[source]

Bases: core.model.superclass.NormalModel

Using Particle Filtering model to predict the occupancy level

This is a normal supervised learning model.

Parameters
Return type

numpy.ndarray

Returns

Predicted occupancy level corresponding to the test Dataset

run()[source]
class core.model.particle_filtering.PF_DA(source, target_retrain, target_test)[source]

Bases: core.model.superclass.DomainAdaptiveModel

Using Particle Filtering model to predict the occupancy level

This is a domain-adaptive semi-supervised learning model.

Parameters
  • source (core.data.dataset.Dataset) – the source domain with full knowledge for training the model

  • target_retrain (None or core.data.dataset.Dataset) – the labelled ground truth Dataset in the target domain for re-training the model

  • target_test (core.data.dataset.Dataset) – the Dataset in the rest of the target domain for testing by using sensor data only

  • number_of_hidden_states (int) – the number of maximum occupancy level

Return type

numpy.ndarray

Returns

Predicted occupancy level corresponding to the test Dataset

run()[source]

core.model.random_forest module

class core.model.random_forest.RandomForest(train, test)[source]

Bases: core.model.superclass.NormalModel

Using Random Forest model to predict the occupancy level

This is a normal supervised learning model.

Parameters
Return type

numpy.ndarray

Returns

Predicted occupancy level corresponding to the test Dataset

run()[source]

core.model.rnn module

class core.model.rnn.DALSTM(source, target_retrain, target_test)[source]

Bases: core.model.superclass.DomainAdaptiveModel

Using Long Short Term Memory model to predict the occupancy level

This is a domain-adaptive semi-supervised learning model.

Parameters
  • source (core.data.dataset.Dataset) – the source domain with full knowledge for training the model

  • target_retrain (None or core.data.dataset.Dataset) – the labelled ground truth Dataset in the target domain for re-training the model

  • target_test (core.data.dataset.Dataset) – the Dataset in the rest of the target domain for testing by using sensor data only

  • hm_epochs (int) – maximum number of epoches

  • batch_size (int) – size of minibatches for stochastic optimizers

  • cell (int) – number of LSTM cells in the hidden layer

  • learn_rate (float) – the initial learning rate used. It controls the step-size in updating the weights

Return type

numpy.ndarray

Returns

Predicted occupancy level corresponding to the test Dataset

run()[source]
class core.model.rnn.LSTM(train, test)[source]

Bases: core.model.superclass.NormalModel

Using Long Short Term Memory model to predict the occupancy level

This is a normal supervised learning model.

Parameters
  • train (core.data.dataset.Dataset) – the labelled ground truth Dataset for training the model

  • test (core.data.dataset.Dataset) – the Dataset for testing by using sensor data only

  • hm_epochs (int) – maximum number of epoches

  • batch_size (int) – size of minibatches for stochastic optimizers

  • cell (int) – number of LSTM cells in the hidden layer

  • learn_rate (float) – the initial learning rate used. It controls the step-size in updating the weights

Return type

numpy.ndarray

Returns

Predicted occupancy level corresponding to the test Dataset

run()[source]

core.model.snmf module

class core.model.snmf.NMF(train, test)[source]

Bases: core.model.superclass.NormalModel

Using Sparse Non-negative Matrix Factorization model to predict the occupancy level

This is a normal supervised learning model.

Parameters
  • train (core.data.dataset.Dataset) – the labelled ground truth Dataset for training the model

  • test (core.data.dataset.Dataset) – the Dataset for testing by using sensor data only

  • alpha (float) – constant that multiplies the regularization terms

  • beta (float) – constant that multiplies the regularization terms

Return type

numpy.ndarray

Returns

Predicted occupancy level corresponding to the test Dataset

run()[source]

core.model.superclass module

class core.model.superclass.DomainAdaptiveModel(source, target_retrain, target_test, thread_num=4)[source]

Bases: object

Use all domain-adaptive semi-supervised learning model to train and test the given Datasets

Parameters
  • source (core.data.dataset.Dataset) – the source domain with full knowledge for training the model

  • target_retrain (None or core.data.dataset.Dataset) – the labelled ground truth Dataset in the target domain for re-training the model

  • target_test (core.data.dataset.Dataset) – the Dataset in the rest of the target domain for testing by using sensor data only

  • thread_num (int) – the maximum number of threads can use to speed up

Return type

core.evaluation.superclass.DomainAdaptiveModel

add_model(list_of_model)[source]

Add one or multiple models into the modelling queue

Parameters

list_of_model (str or list(str)) – one or multiple models that additionally add to the modelling queue

Returns

None

get_all_model()[source]

Get all subclasses

Parameter

None

Returns

None

remove_model(list_of_model)[source]

Remove one or multiple mdoels from the modelling queue

Parameters

list_of_model (str or list(str)) – one or multiple models that want to remove from the modelling queue

Returns

None

run_all_model()[source]

Run all models that currently in the queue

Parameter

None

Return type

dict(str, numpy.ndarray)

Returns

the predicted occupancy level data

class core.model.superclass.NormalModel(train, test, thread_num=4)[source]

Bases: object

Use all normal supervised learning model to train and test the given Datasets

Parameters
Return type

core.model.superclass.NormalModel

add_model(list_of_model)[source]

Add one or multiple models into the modelling queue

Parameters

list_of_model (str or list(str)) – one or multiple models that additionally add to the modelling queue

Returns

None

get_all_model()[source]

Get all subclasses

Parameter

None

Returns

None

remove_model(list_of_model)[source]

Remove one or multiple mdoels from the modelling queue

Parameters

list_of_model (str or list(str)) – one or multiple models that want to remove from the modelling queue

Returns

None

run_all_model()[source]

Run all models that currently in the queue

Parameter

None

Return type

dict(str, numpy.ndarray)

Returns

the predicted occupancy level data

core.model.support_vector_machine module

class core.model.support_vector_machine.SVM(train, test)[source]

Bases: core.model.superclass.NormalModel

Using Support Vector Machine model to predict the occupancy level

This is a normal supervised learning model.

Parameters
  • train (core.data.dataset.Dataset) – the labelled ground truth Dataset for training the model

  • test (core.data.dataset.Dataset) – the Dataset for testing by using sensor data only

  • gamma (float or 'auto') – kernel coefficient for 'rbf', 'poly', or 'sigmoid'

  • kernel (str) – specifies the kernel type to be used in the algorithm. It must be one of 'linear', 'poly', 'rbf', 'sigmoid', 'precomputed'

  • penalty_error (float) – penalty parameter C of the error term.

  • n_estimators (int) – estimators used for predictions.

Return type

numpy.ndarray

Returns

Predicted occupancy level corresponding to the test Dataset

run()[source]
class core.model.support_vector_machine.SVR(train, test)[source]

Bases: core.model.superclass.NormalModel

Using Support Vector Regression model to predict the occupancy level

This is a normal supervised learning model.

Parameters
  • train (core.data.dataset.Dataset) – the labelled ground truth Dataset for training the model

  • test (core.data.dataset.Dataset) – the Dataset for testing by using sensor data only

  • gamma (float or 'auto') – kernel coefficient for 'rbf', 'poly', or 'sigmoid'

  • kernel (str) – specifies the kernel type to be used in the algorithm. It must be one of 'linear', 'poly', 'rbf', 'sigmoid', 'precomputed'

  • penalty_error (float) – penalty parameter C of the error term.

  • n_estimators (int) – estimators used for predictions.

Return type

numpy.ndarray

Returns

Predicted occupancy level corresponding to the test Dataset

run()[source]

Module contents