当前位置: 首页>>代码示例>>Python>>正文


Python BigML.ok方法代码示例

本文整理汇总了Python中bigml.api.BigML.ok方法的典型用法代码示例。如果您正苦于以下问题:Python BigML.ok方法的具体用法?Python BigML.ok怎么用?Python BigML.ok使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bigml.api.BigML的用法示例。


在下文中一共展示了BigML.ok方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from bigml.api import BigML [as 别名]
# 或者: from bigml.api.BigML import ok [as 别名]
def main(args=sys.argv[1:]):
    """Parses command-line parameters and calls the actual main function.

    """
    # Process arguments
    parser = argparse.ArgumentParser(
        description="JSON PML to DOT",
        epilog="BigML, Inc")

    # Model
    parser.add_argument('--model',
                        type=str,
                        required=True,
                        action='store',
                        dest='model',
                        default=None,
                        help="Model identifier")

    # Output file
    parser.add_argument('--output',
                        type=str,
                        action='store',
                        dest='output',
                        default=None,
                        help="Output file")

    # Parse args
    args = parser.parse_args(args)

    # Instantiate BigML API
    api = BigML()

    model = api.get_model(args.model)
    api.ok(model)

    if args.output:
        output = open(args.output, 'w')
        write_tree(model, output)
        output.close()
    else:
        write_tree(model)
开发者ID:aficionado,项目名称:jsonpml2dot,代码行数:43,代码来源:jsonpml2dot.py

示例2: BigML

# 需要导入模块: from bigml.api import BigML [as 别名]
# 或者: from bigml.api.BigML import ok [as 别名]
from bigml.api import BigML
api = BigML()

source1 = api.create_source("iris.csv")
api.ok(source1)

dataset1 = api.create_dataset(source1)
api.ok(dataset1)

model1 = api.create_model(dataset1, \
    {'name': u'my_model_name'})
api.ok(model1)
开发者ID:Pkuzhali,项目名称:bigmler,代码行数:14,代码来源:reify_model.py

示例3: BigML

# 需要导入模块: from bigml.api import BigML [as 别名]
# 或者: from bigml.api.BigML import ok [as 别名]
from bigml.api import BigML
api = BigML()

source1 = api.create_source("iris.csv")
api.ok(source1)

dataset1 = api.create_dataset(source1)
api.ok(dataset1)

anomaly1 = api.create_anomaly(dataset1)
api.ok(anomaly1)

anomalyscore1 = api.create_anomaly_score(anomaly1, \
    {u'petal length': 0.5,
     u'petal width': 0.5,
     u'sepal length': 1,
     u'sepal width': 1,
     u'species': u'Iris-setosa'}, \
    {'name': u'my_anomaly_score_name'})
api.ok(anomalyscore1)
开发者ID:Pkuzhali,项目名称:bigmler,代码行数:22,代码来源:reify_anomaly_score.py

示例4: BigML

# 需要导入模块: from bigml.api import BigML [as 别名]
# 或者: from bigml.api.BigML import ok [as 别名]
from bigml.api import BigML
api = BigML()

source1 = api.create_source("iris.csv")
api.ok(source1)

dataset1 = api.create_dataset(source1, \
    {'name': u'iris dataset'})
api.ok(dataset1)

ensemble1 = api.create_ensemble(dataset1, \
    {'name': u'my_ensemble_name'})
api.ok(ensemble1)
开发者ID:ABourcevet,项目名称:bigmler,代码行数:15,代码来源:reify_ensemble.py

示例5: BigML

# 需要导入模块: from bigml.api import BigML [as 别名]
# 或者: from bigml.api.BigML import ok [as 别名]
from bigml.api import BigML
api = BigML()

source1 = api.create_source("iris.csv")
api.ok(source1)

dataset1 = api.create_dataset(source1)
api.ok(dataset1)

dataset2 = api.create_dataset(dataset1, \
    {'name': u"iris' dataset - sample (30.00%)",
     'out_of_bag': True,
     'sample_rate': 0.7})
api.ok(dataset2)

dataset3 = api.create_dataset(dataset1, \
    {'name': u"iris' dataset - sample (70.00%)", 'sample_rate': 0.7})
api.ok(dataset3)

model1 = api.create_model(dataset3)
api.ok(model1)

evaluation1 = api.create_evaluation(model1, dataset2, \
    {'name': u'my_evaluation_name'})
api.ok(evaluation1)
开发者ID:javinp,项目名称:bigmler,代码行数:27,代码来源:reify_evaluation_split.py

示例6: main

# 需要导入模块: from bigml.api import BigML [as 别名]
# 或者: from bigml.api.BigML import ok [as 别名]
def main(args=sys.argv[1:]):
    """Parses command-line parameters and calls the actual main function.

    """
    parser = argparse.ArgumentParser(description="Market sentiment analysis", epilog="BigML, Inc")

    # source with activity data
    parser.add_argument("--data", action="store", dest="data", default="data", help="Full path to data with csv files")

    # create private links or not
    parser.add_argument("--share", action="store_true", default=True, help="Share created resources or not")

    args = parser.parse_args(args)

    if not args.data:
        sys.exit("You need to provide a valid path to a data directory")

    api = BigML()

    name = "UpOrDown?"

    log("Creating sources...")
    csvs = glob.glob(os.path.join(args.data, "*.csv"))
    sources = []
    for csv in csvs:
        source = api.create_source(csv)
        api.ok(source)
        sources.append(source)

    log("Creating datasets...")
    datasets = []
    for source in sources:
        dataset = api.create_dataset(source)
        api.ok(dataset)
        datasets.append(dataset)

    new_datasets = []
    for dataset in datasets:
        new_dataset = api.create_dataset(dataset, {"new_fields": new_fields(), "all_fields": False})
        new_datasets.append(new_dataset)

    log("Merging datasets...")
    multi_dataset = api.create_dataset(new_datasets, {"name": name})
    api.ok(multi_dataset)

    # Create training and test set for evaluation
    log("Splitting dataset...")
    training, test = training_test_split(api, multi_dataset)

    log("Creating a model using the training dataset...")
    model = api.create_model(training, {"name": name + " (80%)"})
    api.ok(model)

    # Creating an evaluation
    log("Evaluating model against the test dataset...")
    eval_args = {"name": name + " - Single model: 80% vs 20%"}
    evaluation_model = api.create_evaluation(model, test, eval_args)
    api.ok(evaluation_model)

    log("Creating an ensemble using the training dataset...")
    ensemble = api.create_ensemble(training, {"name": name})
    api.ok(ensemble)

    # Creating an evaluation
    log("Evaluating ensemble against the test dataset...")
    eval_args = {"name": name + " - Ensemble: 80% vs 20%"}
    evaluation_ensemble = api.create_evaluation(ensemble, test, eval_args)
    api.ok(evaluation_ensemble)

    log("Creating model for the full dataset...")
    model = api.create_model(multi_dataset, {"name": name})
    api.ok(model)

    # Create private links
    if args.share:
        log("Sharing resources...")
        dataset_link = share_resource(api, multi_dataset)
        model_link = share_resource(api, model)
        evaluation_model_link = share_resource(api, evaluation_model)
        evaluation_ensemble_link = share_resource(api, evaluation_ensemble)
        log(dataset_link)
        log(model_link)
        log(evaluation_model_link)
        log(evaluation_ensemble_link)
开发者ID:jaor,项目名称:upordown,代码行数:86,代码来源:upordown.py

示例7: BigML

# 需要导入模块: from bigml.api import BigML [as 别名]
# 或者: from bigml.api.BigML import ok [as 别名]
from bigml.api import BigML
api = BigML()

source1 = api.create_source("iris_sp_chars.csv", \
    {'name': 'my_sóurcè_sp_name'})
api.ok(source1)

source1 = api.update_source(source1, \
    {'fields': {'000000': {'name': 'sépal.length', 'optype': 'numeric'},
                '000001': {'name': 'sépal&width', 'optype': 'numeric'},
                '000002': {'name': 'pétal.length', 'optype': 'numeric'},
                '000003': {'name': 'pétal&width\x00', 'optype': 'numeric'},
                '000004': {'name': 'spécies', 'optype': 'categorical'}}})
api.ok(source1)
开发者ID:javinp,项目名称:bigmler,代码行数:16,代码来源:reify_source_sp_py3.py

示例8: BigML

# 需要导入模块: from bigml.api import BigML [as 别名]
# 或者: from bigml.api.BigML import ok [as 别名]
    from bigml.api import BigML
api = BigML()
source1_file = "iris.csv"
args = \
{'fields': {'000000': {'name': 'sepal length', 'optype': 'numeric'},
'000001': {'name': 'sepal width', 'optype': 'numeric'},
'000002': {'name': 'petal length', 'optype': 'numeric'},
'000003': {'name': 'petal width', 'optype': 'numeric'},
'000004': {'name': 'species',
'optype': 'categorical',
'term_analysis': {'enabled': True}}},
}
source2 = api.create_source(source1_file, args)
api.ok(source2)
args = \
{'objective_field': {'id': '000004'},
}
dataset1 = api.create_dataset(source2, args)
api.ok(dataset1)
args = \
{'all_fields': False,
'new_fields': [{'field': '(all-but "000001")',
'names': ['sepal length',
'petal length',
'petal width',
'species']},
{'field': '2', 'names': ['new']}],
'objective_field': {'id': '000004'},
}
dataset2 = api.create_dataset(dataset1, args)
api.ok(dataset2)
开发者ID:shantanusharma,项目名称:bigmler,代码行数:33,代码来源:reify_dataset_dataset_py3.py

示例9: BigML

# 需要导入模块: from bigml.api import BigML [as 别名]
# 或者: from bigml.api.BigML import ok [as 别名]
from bigml.api import BigML
api = BigML()

source1 = api.create_source("iris.csv")
api.ok(source1)

dataset1 = api.create_dataset(source1, \
    {'name': u'my_dataset_name'})
api.ok(dataset1)
开发者ID:ABourcevet,项目名称:bigmler,代码行数:11,代码来源:reify_dataset.py

示例10: main

# 需要导入模块: from bigml.api import BigML [as 别名]
# 或者: from bigml.api.BigML import ok [as 别名]
def main(args):
    print('initialize BigML API')
    if args.username and args.apikey:
        api = BigML(args.username,args.apikey)
    else:
        api = BigML()

    print('generate cross validation splits')
    cv_files = generate_cross_validation(args.filename,args.nfolds)

    cv_datasets = []
    params = {'tags':[args.tag]}
    if args.objective_field >= 0:
        params['objective_field'] = {'id':'%06x' % args.objective_field} 
    for (train_file,test_file) in cv_files:
        if args.sequential:
            # wait for source before creating dataset
            train_source = api.create_source(train_file,params)
            train_dataset = api.create_dataset(train_source,params)
            
            if api.ok(train_dataset):
                test_source = api.create_source(test_file,params)       
                test_dataset = api.create_dataset(test_source,params)
        else:
            # upload sources in parallel and create datasets in parallel
            train_source = api.create_source(train_file,params)
            test_source = api.create_source(test_file,params)    
            
            train_dataset = api.create_dataset(train_source,params)
            test_dataset = api.create_dataset(test_source,params)

        cv_datasets.append((train_dataset,test_dataset))
        
    # don't pass objective field to model
    del(params['objective_field'])


    # wait for dataset creation to finish so we can find out the number of features
    dataset_res = api.check_resource(cv_datasets[0][0],api.get_dataset)
    dataset_obj = dataset_res['object']

    # initial feature set
    field_ids = dataset_obj['fields'].keys()
    field_ids.remove(dataset_obj['objective_field']['id'])
    initial_state = [False for id in field_ids]

    # do best-first search
    done = False
    open_list = [(initial_state,0)]
    closed_list = []
    best_accuracy = -1
    best_unchanged_count = 0
    while not done:
        (v,fv) = find_max_state(open_list)
        v_ids = [field_ids[i] for (i,val) in enumerate(v) if val]
        print('Max state is: %s\n Accuracy = %f' % (v_ids,fv))
        closed_list.append((v,fv))
        open_list.remove((v,fv))
        if (fv - EPSILON) > best_accuracy:
            best_state = v
            best_accuracy = fv
            best_unchanged_count = 0
            print('new best state')
        else:
            best_unchanged_count += 1

        children = expand_state(v)
        for c in children:
            if (c not in [pair[0] for pair in open_list]
            and c not in [pair[0] for pair in closed_list]):
                input_fields = [id for (i,id) in enumerate(field_ids) if c[i]]
                print('Evaluating %s' % input_fields)
                params['input_fields'] = input_fields
                val = evaluate(cv_datasets,params,api,args.penalty,args.sequential)

                open_list.append((c,val))

        if best_unchanged_count >= args.staleness:
            done = True

    best_features = [field_ids[i] for (i,val) in enumerate(best_state) if val]
    print('The best feature subset is: %s \n Accuracy = %0.2f%%' % (best_features,best_accuracy*100))
    print('Evaluated %d/%d feature subsets' % ((len(open_list) + len(closed_list)),2**len(field_ids)))
开发者ID:Sandy4321,项目名称:bigml-feature-subsets,代码行数:85,代码来源:feature_subsets.py

示例11: BigML

# 需要导入模块: from bigml.api import BigML [as 别名]
# 或者: from bigml.api.BigML import ok [as 别名]
 from bigml.api import BigML
 api = BigML()
 source1_file = "iris.csv"
 args = \
     {u'fields': {u'000000': {u'name': u'sepal length', u'optype': u'numeric'},
                  u'000001': {u'name': u'sepal width', u'optype': u'numeric'},
                  u'000002': {u'name': u'petal length', u'optype': u'numeric'},
                  u'000003': {u'name': u'petal width', u'optype': u'numeric'},
                  u'000004': {u'name': u'species',
                              u'optype': u'categorical',
                              u'term_analysis': {u'enabled': True}}},
      }
 source2 = api.create_source(source1_file, args)
 api.ok(source2)
 
 args = \
     {u'objective_field': {u'id': u'000004'},
      }
 dataset1 = api.create_dataset(source2, args)
 api.ok(dataset1)
 
 args = \
     {u'anomaly_seed': u'bigml',
               u'seed': u'bigml'}
 anomaly1 = api.create_anomaly(dataset1, args)
 api.ok(anomaly1)
 
开发者ID:bigmlcom,项目名称:bigmler,代码行数:28,代码来源:reify_anomaly.py

示例12: main

# 需要导入模块: from bigml.api import BigML [as 别名]
# 或者: from bigml.api.BigML import ok [as 别名]
def main(args=sys.argv[1:]):
    """Parses command-line parameters and calls the actual main function.

    """
    parser = argparse.ArgumentParser(
        description="Dataset analysis",
        epilog="BigML, Inc")

    # source with activity data
    parser.add_argument('--source',
                        action='store',
                        dest='source',
                        default=None,
                        help="Full path to file")

    # create private links or not
    parser.add_argument('--share',
                        action='store_true',
                        default=False,
                        help="Share created resources or not")

    # weight models or not
    parser.add_argument('--balance',
                        action='store_true',
                        default=False,
                        help="Weight model or not")

    args = parser.parse_args(args)

    if not args.source:
        sys.exit("You need to provide a valid path to a source")

    api = BigML()

    name = "Sean's activity"

    log("Creating source...")
    source_args = {'name': name}
    source = api.create_source(args.source, source_args)
    if not api.ok(source):
        sys.exit("Source isn't ready...")

    log("Creating dataset...")
    dataset = api.create_dataset(source)
    if not api.ok(dataset):
        sys.exit("Dataset isn't ready...")

    log("Transforming dataset...")
    # Extends dataset with new field for previous activity, previous duration,
    # start day, and start hour. Removes first column, start, and end fields.
    new_dataset_args = {
        'name': name,
        'new_fields': new_fields(),
        'all_but': excluded_fields()}
    new_dataset = api.create_dataset(dataset, new_dataset_args)
    if not api.ok(new_dataset):
        sys.exit("Dataset isn't ready...")

    # Set objective field to activity
    fields = Fields(new_dataset['object']['fields'])
    objective_id = fields.field_id('activity')
    new_dataset_args = {
        'objective_field': {'id': objective_id}}
    new_dataset = api.update_dataset(new_dataset, new_dataset_args)

    # Create training and test set for evaluation
    log("Splitting dataset...")
    training, test = train_test_split(api, new_dataset)

    log("Creating a model using the training dataset...")
    model_args = {
        'objective_field': objective_id,
        'balance_objective': args.balance,
        'name': training['object']['name']}
    model = api.create_model(training, model_args)
    if not api.ok(model):
        sys.exit("Model isn't ready...")

    # Creating an evaluation
    log("Evaluating model against the test dataset...")
    eval_args = {
        'name': name + ' - 80% vs 20%'}
    evaluation = api.create_evaluation(model, test, eval_args)
    if not api.ok(evaluation):
        sys.exit("Evaluation isn't ready...")

    log("Creating model for the full dataset...")
    model = api.create_model(new_dataset, model_args)
    if not api.ok(model):
        sys.exit("Model isn't ready...")

    # Create private links
    if args.share:
        log("Sharing resources...")
        dataset_private_link = share_dataset(api, new_dataset)
        model_private_link = share_model(api, model)
        evaluation_private_link = share_evaluation(api, evaluation)
        log(dataset_private_link)
        log(model_private_link)
        log(evaluation_private_link)
开发者ID:aficionado,项目名称:nextactivity,代码行数:102,代码来源:next_activity.py

示例13: Cluster

# 需要导入模块: from bigml.api import BigML [as 别名]
# 或者: from bigml.api.BigML import ok [as 别名]

#.........这里部分代码省略.........
        """
        return self.critical_value is not None

    def fill_numeric_defaults(self, input_data, average="mean"):
        """Checks whether input data is missing a numeric field and
        fills it with the average quantity provided in the
        ``average`` parameter
        """

        for field_id, field in self.fields.items():
            if (field_id not in self.summary_fields and \
                    field['optype'] not in OPTIONAL_FIELDS and
                    field_id not in input_data):
                if average not in NUMERIC_DEFAULTS:
                    raise ValueError("The available defaults are: %s" % \
                 ", ".join(NUMERIC_DEFAULTS))
                default_value = 0 if average == "zero" \
                    else field['summary'].get(average)
                input_data[field_id] = default_value
        return input_data

    def get_unique_terms(self, input_data):
        """Parses the input data to find the list of unique terms in the
           tag cloud

        """
        unique_terms = {}
        for field_id in self.term_forms:
            if field_id in input_data:
                input_data_field = input_data.get(field_id, '')
                if isinstance(input_data_field, basestring):
                    case_sensitive = self.term_analysis[field_id].get(
                        'case_sensitive', True)
                    token_mode = self.term_analysis[field_id].get(
                        'token_mode', 'all')
                    if token_mode != TM_FULL_TERM:
                        terms = parse_terms(input_data_field,
                                            case_sensitive=case_sensitive)
                    else:
                        terms = []
                    if token_mode != TM_TOKENS:
                        terms.append(
                            input_data_field if case_sensitive
                            else input_data_field.lower())
                    unique_terms[field_id] = get_unique_terms(
                        terms, self.term_forms[field_id],
                        self.tag_clouds.get(field_id, []))
                else:
                    unique_terms[field_id] = input_data_field
                del input_data[field_id]
        # the same for items fields
        for field_id in self.item_analysis:
            if field_id in input_data:
                input_data_field = input_data.get(field_id, '')
                if isinstance(input_data_field, basestring):
                    # parsing the items in input_data
                    separator = self.item_analysis[field_id].get(
                        'separator', ' ')
                    regexp = self.item_analysis[field_id].get(
                        'separator_regexp')
                    if regexp is None:
                        regexp = ur'%s' % re.escape(separator)
                    terms = parse_items(input_data_field, regexp)
                    unique_terms[field_id] = get_unique_terms(
                        terms, {},
                        self.items.get(field_id, []))
开发者ID:charleslparker,项目名称:python,代码行数:70,代码来源:cluster.py

示例14: BigML

# 需要导入模块: from bigml.api import BigML [as 别名]
# 或者: from bigml.api.BigML import ok [as 别名]
from bigml.api import BigML

api = BigML()

source1 = api.create_source("iris.csv")
api.ok(source1)

dataset1 = api.create_dataset(source1)
api.ok(dataset1)

cluster1 = api.create_cluster(dataset1)
api.ok(cluster1)

batchcentroid1 = api.create_batch_centroid(cluster1, dataset1, {"name": u"my_batch_centroid_name"})
api.ok(batchcentroid1)
开发者ID:Pkuzhali,项目名称:bigmler,代码行数:17,代码来源:reify_batch_centroid.py

示例15: BigML

# 需要导入模块: from bigml.api import BigML [as 别名]
# 或者: from bigml.api.BigML import ok [as 别名]
from bigml.api import BigML
api = BigML()
source1_file = "iris_sp_chars.csv"
args = \
{'fields': {'000000': {'name': 'sépal.length', 'optype': 'numeric'},
'000001': {'name': 'sépal&width', 'optype': 'numeric'},
'000002': {'name': 'pétal.length', 'optype': 'numeric'},
'000003': {'name': 'pétal&width\x00', 'optype': 'numeric'},
'000004': {'name': 'spécies',
'optype': 'categorical',
'term_analysis': {'enabled': True}}},
}
source2 = api.create_source(source1_file, args)
api.ok(source2)
开发者ID:bigmlcom,项目名称:bigmler,代码行数:16,代码来源:reify_source_sp_py3.py


注:本文中的bigml.api.BigML.ok方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。