Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 5
0
def i_create_local_logistic_regression_from_file(step, export_file):
    world.local_logistic = LogisticRegression(res_filename(export_file))
Esempio n. 6
0
def i_create_local_logistic_regression_from_file(step, export_file):
    world.local_logistic = LogisticRegression( \
        res_filename(export_file),
        api=BigML("wrong-user", "wrong-api-key"))
Esempio n. 7
0
import pandas as pd
import streamlit as st
from bigml.logistic import LogisticRegression
from bigml.api import BigML
from PIL import Image
import altair as alt

logisticregression = LogisticRegression(
    'logisticregression/607e21b3f7af1513af005db6',
    api=BigML("vlv7",
              "5bfb457d1ad360008520230eee0c229084b85f04",
              domain="bigml.io"))


# To make predictions fill the desired input_data in next line.
@st.cache(suppress_st_warning=True)
def setup_fxn():
    #st.header("SetupFXN Run")
    input_data = {
        "director": "Woody Allen",
        "writer": "Woody Allen",
        "genre": 'Drama',
        "duration": 1,
        "Month": 'October',
        "production_company": 'twentieth century fox',
        "actors": 'Maggie Smith',
        "OscarWinner": 'FALSE',
        "budget": 10000
    }
    # setup for initial data seeding
    main_df = pd.read_csv('data/IMDB Data v3.csv')
def i_create_a_local_logistic_model(step):
    world.local_model = LogisticRegression(world.logistic_regression)
Esempio n. 9
0
def i_create_a_local_logistic_model(step):
    world.local_model = LogisticRegression(world.logistic_regression)
    if hasattr(world, "local_ensemble"):
        world.local_ensemble = None
# Requires BigML Python bindings
#
# Install via: pip install bigml
#
# or clone it:
#   git clone https://github.com/bigmlcom/python.git
from bigml.logistic import LogisticRegression
from bigml.api import BigML
# Downloads and generates a local version of the logistic regression,
# if it hasn't been downloaded previously.
logisticregression = LogisticRegression('logisticregression/5c9cf98ede2d4d09b60001b7',
                  api=BigML("rshelton",
                            "adabd734dd2a2af5cb4e49176f0eb472cfa8ce5a",
                            domain="bigml.io"))
# To predict probabilities fill the desired input_data
# in next line. Numeric fields are compulsory if the model was not
# trained with missing numerics.
input_data = {
    "EMERG_VEH": yes,
    "Division": d42,
    "DISABILITY": yes,
    "ACCLASS": Non-Fatal Injury,
    "RDSFCOND": Dry,
    "INVTYPE": Driver,
    "IMPACTYPE": Turning Movement,
    "TRAFFCTL": No Control,
    "ACCLOC": At Intersection,
    "VISIBILITY": Clear,
    "Ward_Name": scarborough,
    "INJURY": None,
    "INVAGE": unknown,
Esempio n. 11
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)
Esempio n. 12
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)