Example #1
0
def local_prediction(logistic_regressions, test_reader, output, args,
                     exclude=None):
    """Get local logistic_regression and issue prediction

    """
    # Only one logistic_regression at present
    local_logistic = LogisticRegression(logistic_regressions[0])
    test_set_header = test_reader.has_headers()
    for input_data in test_reader:
        input_data_dict = test_reader.dict(input_data, filtering=False)
        prediction_info = local_logistic.predict(
            input_data_dict, by_name=test_set_header)
        write_prediction(prediction_info, output,
                         args.prediction_info, input_data, exclude)
Example #2
0
def local_prediction(logistic_regressions, test_reader, output, args,
                     exclude=None):
    """Get local logistic_regression and issue prediction

    """
    # Only one logistic_regression at present
    local_logistic = LogisticRegression(logistic_regressions[0],
                                        api=args.retrieve_api_)
    kwargs = {"full": True}
    if args.operating_point_:
        kwargs.update({"operating_point": args.operating_point_})
    for input_data in test_reader:
        input_data_dict = test_reader.dict(input_data, filtering=False)
        prediction_info = local_logistic.predict(
            input_data_dict, **kwargs)
        write_prediction(prediction_info, output,
                         args.prediction_info, input_data, exclude)
Example #3
0
def local_prediction(logistic_regressions,
                     test_reader,
                     output,
                     args,
                     exclude=None):
    """Get local logistic_regression and issue prediction

    """
    # Only one logistic_regression at present
    local_logistic = LogisticRegression(logistic_regressions[0])
    test_set_header = test_reader.has_headers()
    for input_data in test_reader:
        input_data_dict = test_reader.dict(input_data, filtering=False)
        prediction_info = local_logistic.predict(input_data_dict,
                                                 by_name=test_set_header)
        write_prediction(prediction_info, output, args.prediction_info,
                         input_data, exclude)
Example #4
0
def local_prediction(logistic_regressions,
                     test_reader,
                     output,
                     args,
                     exclude=None):
    """Get local logistic_regression and issue prediction

    """
    # Only one logistic_regression at present
    local_logistic = LogisticRegression(logistic_regressions[0],
                                        api=args.retrieve_api_)
    test_set_header = test_reader.has_headers()
    kwargs = {"by_name": test_set_header}
    if args.operating_point_:
        kwargs.update({"operating_point": args.operating_point_})
    for input_data in test_reader:
        input_data_dict = test_reader.dict(input_data, filtering=False)
        prediction_info = local_logistic.predict(input_data_dict, **kwargs)
        write_prediction(prediction_info, output, args.prediction_info,
                         input_data, exclude)
    "YEAR": 1,
    "DATE": 1,
    "Index_": 1,
    "ACCNUM": 1,
    "X": 1,
    "Y": 1,
    "AUTOMOBILE": yes,
    "MOTORCYCLE": yes,
    "CYCLIST": yes,
    "STREET1": ave,
    "STREET2": ave,
    "DRIVACT": Driving Properly,
    "MANOEUVER": Going Ahead,
    "DRIVCOND": Normal,
    "FATAL_NO": 1,
    "VEHTYPE": automobile,
    "INITDIR": West,
    "DATE.hour": 1,
    "DATE.day-of-month": 1,
    "DATE.day-of-week": 1,
    "DATE.year": 1,
    "DATE.month": 1
}
logisticregression.predict(input_data, full=True)
#
# input_data: dict for the input values
# (e.g. {"petal length": 1, "sepal length": 3})
# full: if set to True, the output will be a dictionary that includes the
# distribution of each class in the objective field, the predicted class and
# its probability. Please check:
# https://bigml.readthedocs.io/en/latest/#local-logistic-regression-predictions
Example #6
0
# model = api.get_model('model/563a1c7a3cd25747430023ce')
# prediction = api.create_prediction(model, {'petal length': 4.07, 'sepal width': 3.15, 'petal width': 1.51})

# local_model = Model('model/56430eb8636e1c79b0001f90', api=api)
# prediction = local_model.predict({'petal length': 0.96, 'sepal width': 4.1, 'petal width': 2.52}, 2, add_confidence=True, multiple=3)

#local_model = Ensemble('ensemble/563219b8636e1c5eca006d38', api=api)
# local_model = Ensemble('ensemble/564a081bc6c19b6cf3011c60', api=api)
#prediction = local_model.predict({'petal length': 0.96, 'sepal width': 2.25, 'petal width': 1.51, 'sepal length': 6.02}, method=2, add_confidence=True)

#local_model = Ensemble('ensemble/5666fb621d55051209009f0f', api=api)
#prediction = local_model.predict({'Salary': 18000000, 'Team' : 'Atlanta Braves'}, method=0, add_confidence=True)
#local_model = Ensemble('ensemble/566954af1d5505120900bf69', api=api)
#prediction = local_model.predict({'Price' : 5.8, 'Grape' : 'Pinot Grigio', 'Rating' : 89, 'Country' : 'Italy'}, method=1, add_confidence=True, add_distribution=True)

# local_ensemble = Ensemble('ensemble/564623d4636e1c79b00051f7', api=api)
# prediction = local_ensemble.predict({'Price' : 5.8, 'Grape' : 'Pinot Grigio', 'Country' : 'Italy', 'Rating' : 92}, True)

# local_anomaly = Anomaly('anomaly/564c5a76636e1c3d52000007', api=api)
# prediction = local_anomaly.anomaly_score({'petal length': 4.07, 'sepal width': 3.15, 'petal width': 1.51, 'sepal length': 6.02, 'species': 'Iris-setosa'}, True)
# prediction = local_anomaly.anomaly_score({'petal length': 0.96, 'sepal width': 4.1, 'petal width': 2.51, 'sepal length': 6.02, 'species': 'Iris-setosa'}, True)
# prediction = local_anomaly.anomaly_score({'petal length': 0.96, 'sepal width': 4.1, 'petal width': 2.51}, True)

logistic_regression = LogisticRegression(
    'logisticregression/5697c1179ed2334090003217')
prediction = logistic_regression.predict({"petal length": 4.07, "petal width": 14.07,
                             "sepal length": 6.02, "sepal width": 3.15})

api.pprint(prediction)
Example #7
0
# local_model = Model('model/56430eb8636e1c79b0001f90', api=api)
# prediction = local_model.predict({'petal length': 0.96, 'sepal width': 4.1, 'petal width': 2.52}, 2, add_confidence=True, multiple=3)

#local_model = Ensemble('ensemble/563219b8636e1c5eca006d38', api=api)
# local_model = Ensemble('ensemble/564a081bc6c19b6cf3011c60', api=api)
#prediction = local_model.predict({'petal length': 0.96, 'sepal width': 2.25, 'petal width': 1.51, 'sepal length': 6.02}, method=2, add_confidence=True)

#local_model = Ensemble('ensemble/5666fb621d55051209009f0f', api=api)
#prediction = local_model.predict({'Salary': 18000000, 'Team' : 'Atlanta Braves'}, method=0, add_confidence=True)
#local_model = Ensemble('ensemble/566954af1d5505120900bf69', api=api)
#prediction = local_model.predict({'Price' : 5.8, 'Grape' : 'Pinot Grigio', 'Rating' : 89, 'Country' : 'Italy'}, method=1, add_confidence=True, add_distribution=True)

# local_ensemble = Ensemble('ensemble/564623d4636e1c79b00051f7', api=api)
# prediction = local_ensemble.predict({'Price' : 5.8, 'Grape' : 'Pinot Grigio', 'Country' : 'Italy', 'Rating' : 92}, True)

# local_anomaly = Anomaly('anomaly/564c5a76636e1c3d52000007', api=api)
# prediction = local_anomaly.anomaly_score({'petal length': 4.07, 'sepal width': 3.15, 'petal width': 1.51, 'sepal length': 6.02, 'species': 'Iris-setosa'}, True)
# prediction = local_anomaly.anomaly_score({'petal length': 0.96, 'sepal width': 4.1, 'petal width': 2.51, 'sepal length': 6.02, 'species': 'Iris-setosa'}, True)
# prediction = local_anomaly.anomaly_score({'petal length': 0.96, 'sepal width': 4.1, 'petal width': 2.51}, True)

logistic_regression = LogisticRegression(
    'logisticregression/5697c1179ed2334090003217')
prediction = logistic_regression.predict({
    "petal length": 4.07,
    "petal width": 14.07,
    "sepal length": 6.02,
    "sepal width": 3.15
})

api.pprint(prediction)