示例#1
0
        '''Runs training until cost values converge to within some interval'''
        val = self.linreg(learning_rate, ind, dep)
        old_val = 0
        #Can change this variable to decide how much convergence is wanted
        while np.absolute(val-old_val) > 1:
            old_val = val
            val = self.linreg(learning_rate, ind, dep)
        self.getTheta()

    def getTheta(self):
        '''Prints out Value for current weight and bias variables'''
        print "Weight     Bias"
        print self.weight, self.bias

if __name__ == '__main__':
    #command line to run this properly
    #python NiceLinReg.py data.csv [2,3] 1
    np.random.seed(42)
    loader = ReadData()
    loader.load(sys.argv[1], sys.argv[2], int(sys.argv[3]))
    print "Temp Only"
    tempOnly = NiceLinReg()
    dailyTemp = loader.getInd(0)
    DOJIA = loader.getDep()
    tempOnly.train(.000005, dailyTemp, DOJIA)

    print "\nDiff in Temp and avg highest recorded temp"
    diff = NiceLinReg()
    diffList = loader.diff(0,1)
    diff.train(0.000000000049, diffList, DOJIA)