diff --git a/src/utils/ml.py b/src/utils/ml.py new file mode 100644 index 0000000..b9f3c51 --- /dev/null +++ b/src/utils/ml.py @@ -0,0 +1,32 @@ +""" + This file is intended to perfom certain machine learning tasks based on numpy + We are trying to keep it lean that's why no sklearn involved yet +""" +import numpy as np + +class ML: + @staticmethod + def Filter (attr,value,data) : + # + # @TODO: Make sure this approach works across all transport classes + # We may have a potential issue of how the data is stored ... it may not scale + # + return [item[0] for item in data if item[0][attr] == value] + @staticmethod + def Extract(lattr,data): + return [[row[id] for id in lattr] for row in data] + + def init(self,lattr,data): + self.lattr = attr + self.data = data + self.X = [] + self.Xmeans = [] + for id in lattr: + xvalues = [item for item in self.data[id]] + self.Xmeans.append(np.mean(xvalues)) + self.X.append(xvalues) + slef.Xcov = np.cov(self.X) + # + # Let's get the covariance matrix here ... + # + \ No newline at end of file