# Path: discomll/dataset.py
# class Data:
#     def __init__(self, data_tag, X_indices, **kwargs):
#     def generate_urls(self, first_url, last_url):
# 
# Path: discomll/classification/linear_svm.py
# def simple_init(interface, params):
# def map_fit(interface, state, label, inp):
# def reduce_fit(interface, state, label, inp):
# def map_predict(interface, state, label, inp):
# def fit(dataset, nu=0.1, save_results=True, show=False):
# def predict(dataset, fitmodel_url, save_results=True, show=False):
# 
# Path: discomll/utils/model_view.py
# def output_model(fitmodel_url):
# def _rf_model(fitmodel):
# def _dt_model(fitmodel):
# def _kmeans_model(fitmodel):
# def _linsvm_model(fitmodel):
# def _logreg_model(fitmodel):
# def _linreg_model(fitmodel):
# def _naivebayes_model(fitmodel):
# def _tree_view(tree, feature_names=[]):
# 
# Path: discomll/utils/accuracy.py
# def simple_init(interface, params):
# def map_predictions(interface, state, label, inp):
# def map_test_data(interface, state, label, inp):
# def reduce_ca(interface, state, label, inp):
# def reduce_mse(interface, state, label, inp):
# def measure(test_data, predictions, measure="ca", save_results=True, show=False):


from disco.core import result_iterator
from discomll import dataset
from discomll.classification import linear_svm
from discomll.utils import model_view
from discomll.utils import accuracy
# define training dataset
train = dataset.Data(data_tag=["test:breast_cancer_disc"],
                     data_type="chunk",
                     X_indices=xrange(1, 10),
                     id_index=0,
                     y_index=10,
                     delimiter=",",
                     y_map=["2", "4"],
                     # define mapping parameter. "2" is mapped to 1, "4" is mapped to -1.
                     missing_vals=["?"])  # define missing value symbol

# define test dataset
test = dataset.Data(data_tag=["test:breast_cancer_disc_test"],
                    data_type="chunk",
                    X_indices=xrange(1, 10),
                    id_index=0,
                    y_index=10,
                    delimiter=",",
                    y_map=["2", "4"],  # define mapping parameter. "2" is mapped to 1, "4" is mapped to -1.
                    missing_vals=["?"])  # define missing value symbol

# fit model on training dataset
fit_model = linear_svm.fit(train)

# output model
model = model_view.output_model(fit_model)
print model


# start MR job to predict given test data

# Path: discomll/dataset.py
# class Data:
#     def __init__(self, data_tag, X_indices, **kwargs):
#     def generate_urls(self, first_url, last_url):
# 
# Path: discomll/classification/linear_svm.py
# def simple_init(interface, params):
# def map_fit(interface, state, label, inp):
# def reduce_fit(interface, state, label, inp):
# def map_predict(interface, state, label, inp):
# def fit(dataset, nu=0.1, save_results=True, show=False):
# def predict(dataset, fitmodel_url, save_results=True, show=False):
# 
# Path: discomll/utils/model_view.py
# def output_model(fitmodel_url):
# def _rf_model(fitmodel):
# def _dt_model(fitmodel):
# def _kmeans_model(fitmodel):
# def _linsvm_model(fitmodel):
# def _logreg_model(fitmodel):
# def _linreg_model(fitmodel):
# def _naivebayes_model(fitmodel):
# def _tree_view(tree, feature_names=[]):
# 
# Path: discomll/utils/accuracy.py
# def simple_init(interface, params):
# def map_predictions(interface, state, label, inp):
# def map_test_data(interface, state, label, inp):
# def reduce_ca(interface, state, label, inp):
# def reduce_mse(interface, state, label, inp):
# def measure(test_data, predictions, measure="ca", save_results=True, show=False):


# Path: discomll/examples/classification/linear_svm_ddfs.py
from disco.core import result_iterator
from discomll import dataset
from discomll.classification import linear_svm
from discomll.utils import model_view
from discomll.utils import accuracy

# define training dataset
train = dataset.Data(data_tag=["test:breast_cancer_disc"],
                     data_type="chunk",
                     X_indices=xrange(1, 10),
                     id_index=0,
                     y_index=10,
                     delimiter=",",
                     y_map=["2", "4"],
                     # define mapping parameter. "2" is mapped to 1, "4" is mapped to -1.
                     missing_vals=["?"])  # define missing value symbol

# define test dataset
test = dataset.Data(data_tag=["test:breast_cancer_disc_test"],
                    data_type="chunk",
                    X_indices=xrange(1, 10),
                    id_index=0,
                    y_index=10,
                    delimiter=",",
                    y_map=["2", "4"],  # define mapping parameter. "2" is mapped to 1, "4" is mapped to -1.
                    missing_vals=["?"])  # define missing value symbol

# fit model on training dataset
fit_model = linear_svm.fit(train)

# output model
model = model_view.output_model(fit_model)
print model


# start MR job to predict given test data

predictions = linear_svm.predict(test, fit_model)