Example #1
0
    def runClassification(spend, marital, hh_size, income):
        # define the model
        model = LogisticRegression(max_iter=1000)
        # dummy training to initialize weights and biases of the model
        model.fit(np.array([[0, 0, 0, 0], [1, 1, 1, 1]]), [0, 1])

        # Assigning trained weights and biases to the model
        model.coef_ = np.array(
            [[0.01418876, -0.34609983, 0.14408751, 0.02292672]])  # weights
        model.bias_ = np.array([-0.3975337])  # bias

        example_instance = np.array(
            [[spend, marital, hh_size,
              income]])  # [[TOTAL_SPEND, MARITAL, HH_SIZE, INCOME_RANGE]]

        # Test the model
        prediction = model.predict(example_instance)
        return prediction[0].item()