Exemple #1
0
def classifyBusinessesTest():
    """
    Runs Classifier in scorers (most up to date classifier), without automatically classifying training data
    """
    # late import
    from scorers import Classifier

    loader.reset_algo_classifiedset()

    thresh = 0.3
    classifier = Classifier(threshhold=thresh)
    classifcations = classifier.classify(implement_rules=True, use_training_data=False)
    loader.write_rows_algo_classified_set(classifcations)
    predictionScoreOfTrainingSet()   
Exemple #2
0
    def run(self):
        S = loader.get_S()
        scorer = Scorer()

        for _ in xrange(10000):
            keys = self.weights_dict.keys()
            shuffle(keys)
            for k in keys:

                sc = -float("inf")
                best_dev = .02
                base = self.weights_dict[k]
                for dev in [.02, 0, -.02]:
                    self.weights_dict[k] = base + dev

                    w = self.weights_dict.values()

                    S_prime = [Si * wi for Si, wi in zip(S, w)]
                    S_prime = reduce(lambda x, y: x + y, S_prime)
                    classifications = []
                    for i in xrange(10000):
                        argmax = np.argmax(S_prime[i, :])
                        ide = column_to_code[argmax]
                        classifications.append((row_to_bizid[i], ide))
                    loader.write_rows_algo_classified_set(classifications)
                    pred, total, _ = scorer.scoreClassifications()
                    score = pred / total
                    if score > sc:
                        sc = score
                        best_dev = dev
                    print sc

                self.weights_dict[k] = base + best_dev
                w = self.weights_dict.values()

                S_prime = [Si * wi for Si, wi in zip(S, w)]
                S_prime = reduce(lambda x, y: x + y, S)
                classifications = []
                for i in xrange(10000):
                    ide = column_to_code[np.argmax(S_prime[i, :])]
                    classifications.append((row_to_bizid[i], ide))
                loader.write_rows_algo_classified_set(classifications)
                pred, total, _ = scorer.scoreClassifications()
                score = pred / total
                if score > sc:
                    sc = score
                    best_dev = dev
                print sc
                print self.weights_dict
Exemple #3
0
    def run(self):
        S = loader.get_S()
        scorer = Scorer()

        for _ in xrange(10000):
            keys = self.weights_dict.keys()
            shuffle(keys)
            for k in keys:

                sc = -float("inf")
                best_dev = .02
                base = self.weights_dict[k]
                for dev in [.02, 0, -.02]:
                    self.weights_dict[k] = base + dev

                    w = self.weights_dict.values()

                    S_prime = [Si * wi for Si, wi in zip(S, w)]
                    S_prime = reduce(lambda x, y: x + y, S_prime)
                    classifications = []
                    for i in xrange(10000):
                        argmax = np.argmax(S_prime[i, :])
                        ide = column_to_code[argmax]
                        classifications.append( (row_to_bizid[i], ide) )
                    loader.write_rows_algo_classified_set(classifications)
                    pred , total , _  = scorer.scoreClassifications()
                    score = pred / total
                    if score > sc:
                        sc = score
                        best_dev = dev
                    print sc

                self.weights_dict[k] = base + best_dev
                w = self.weights_dict.values()

                S_prime = [Si * wi for Si, wi in zip(S, w)]
                S_prime = reduce(lambda x, y: x + y, S)
                classifications = []
                for i in xrange(10000):
                    ide = column_to_code[np.argmax(S_prime[i, :])]
                    classifications.append( (row_to_bizid[i], ide) )
                loader.write_rows_algo_classified_set(classifications)
                pred , total , _ = scorer.scoreClassifications()
                score = pred / total
                if score > sc:
                    sc = score
                    best_dev = dev
                print sc
                print self.weights_dict
Exemple #4
0
def classifyBusinessesTest():
    """
    Runs Classifier in scorers (most up to date classifier), without automatically classifying training data
    """
    # late import
    from scorers import Classifier

    loader.reset_algo_classifiedset()

    thresh = 0.3
    classifier = Classifier(threshhold=thresh)
    classifcations = classifier.classify(implement_rules=True,
                                         use_training_data=False)
    loader.write_rows_algo_classified_set(classifcations)
    predictionScoreOfTrainingSet()