def computeDecisionBoundary(self, w_full, lam, stepSize=0.01, maxFunctionCalls=10000, printSummary=True,
                                plot=False, plotIter=False, useGradientCriterion=False, tol=1e-4):
        gd = self.constructGradientDescentObject(lam)
        gd.stepSize = stepSize

        storeIterValues=False
        if plotIter:
            storeIterValues=True

        sol = gd.computeMin(w_full, maxFunctionCalls=maxFunctionCalls, printSummary=printSummary,
                            storeIterValues=storeIterValues, tol=tol,
                            useGradientCriterion=useGradientCriterion)
        w_star = sol[0];
        w_star_normalized = 1/np.linalg.norm(w_star)*w_star

        if printSummary:
            print "--- Classification Summary ---"
            print "w_full = " + str(w_star)
            print "w_full normalized = " + str(w_star_normalized)
            print "norm of w_full = " + str(np.linalg.norm(w_star))
            print "lambda = " + str(lam)
            self.classificationErrorRate(w_star, verbose=True)
            print "------------------"
            print ""



        if plot:
            self.plotData(w_star)

        if plotIter:
            gd.plotIterValues()

        return w_star
Exemplo n.º 2
0
    def computeDecisionBoundary(self,
                                w_full,
                                lam,
                                stepSize=0.01,
                                maxFunctionCalls=10000,
                                printSummary=True,
                                plot=False,
                                plotIter=False,
                                useGradientCriterion=False,
                                tol=1e-4):
        gd = self.constructGradientDescentObject(lam)
        gd.stepSize = stepSize

        storeIterValues = False
        if plotIter:
            storeIterValues = True

        sol = gd.computeMin(w_full,
                            maxFunctionCalls=maxFunctionCalls,
                            printSummary=printSummary,
                            storeIterValues=storeIterValues,
                            tol=tol,
                            useGradientCriterion=useGradientCriterion)
        w_star = sol[0]
        w_star_normalized = 1 / np.linalg.norm(w_star) * w_star

        if printSummary:
            print "--- Classification Summary ---"
            print "w_full = " + str(w_star)
            print "w_full normalized = " + str(w_star_normalized)
            print "norm of w_full = " + str(np.linalg.norm(w_star))
            print "lambda = " + str(lam)
            self.classificationErrorRate(w_star, verbose=True)
            print "------------------"
            print ""

        if plot:
            self.plotData(w_star)

        if plotIter:
            gd.plotIterValues()

        return w_star