This folder contains the code for the Coupled Matrix Tensor Factorization (CMTF) and Canonical Polyadic (CP) decomposition parts of the project. Note that the code is messy and doesn't make much sense without the report.
The code requires 4 main dependencies. However, loading all of them at the same time will result in conflicts (as different versions of the Tensor Toolbox are required).
- The CMTF toolbox, v1.1
- The Tensor Toolbox, v2.5. Note: the CMTF toolbox will not work with newer versions of the Tensor Toolbox
- The Tensor Toolbox, commit
8357b956
. Required for the CORCONDIA script, but it will conflict with (2) - L-BFGS-B-C. Required for the
cmtf_opt
function in (3).
The data is stored inside of all_avg_2015.mat
, which includes the data tensor X
, which corresponds to data of all the sensors in 2015, and the matrix weather
, which contains the weather data in 2015.
The data may have to be loaded before running the following scripts.
There are several scripts that perform useful functions:
melbourne_to_tensor_rev2.ipynb
: Converts the data from the database into a format easily parsed by MATLAB.benchmark_cmtf
: Measures the performance of CMTF in predicting missing values. Randomly removes 5% of the data to test it.mean_predict
: Estimates missing values by computing the mean of the data at the time slice of missing data. Requiresbenchmark_cmtf
to be run first.specific_mean_predict
: Estimates missing values by computing the mean of the previous and next value from the sensor, given a missing value.diagnostic
: Performs CORCONDIA against various rank CP decompositions ofX
to find a good rank estimation.explore_cp
: Creates a exploratory view of a CP decomposition (e.g. one output byget_best_cp
).get_best_cp
: Performs the CP decomposition of rankR
against a tensor several times and returning the best fit.