Exemplo n.º 1
0
 def predict(self, x, return_var=False):
     y = SumMultiply('i,i', self.weights, x)
     y_hat, var = y.get_moments()
     if return_var:
         return y_hat, var
     else:
         return y_hat
Exemplo n.º 2
0
    from bayespy.nodes import GaussianARD
    B = GaussianARD(0, 1e-6, shape=(X.shape[1], ))
    from bayespy.nodes import SumMultiply
    F = SumMultiply('i,i', B, X)

    from bayespy.nodes import Gamma
    tau = Gamma(1e-3, 1e-3)
    Y = GaussianARD(F, tau)
    Y.observe(y)
    from bayespy.inference import VB
    Q = VB(Y, B, tau)
    #Q.update(repeat=100990)
    distribution = []
    result = []
    distribution = F.get_moments()
    for min_val, max_val in zip(distribution[0], distribution[1]):
        #mean = []
        mean = (min_val + max_val) / 2
        result.append(mean)
        #result = mean
        #x3 = []
        #x3 = pd.DataFrame({result:buffer_data})
        #x1 = x1.append(x3)
    x1[buffer_data] = result

print(x1)

dataframe = pd.DataFrame(x1)
dataframe.to_csv('distribution.csv', mode='a', header=True, index=False)
'''