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


Python Dataset.load_arff方法代码示例

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


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

示例1: LAIMdiscretize

# 需要导入模块: from dataset import Dataset [as 别名]
# 或者: from dataset.Dataset import load_arff [as 别名]
endian_big = args.b
n_folds = args.k[0]
shuffle = args.s
(dataset_name_,) = args.dataset

dataset_name = "data/" + dataset_name_

shutil.copy(dataset_name + ".orig.arff", dataset_name + ".arff")

# first in big endian
if endian_big == False:
    Dataset.arff_to_big_endian(dataset_name + ".arff", dataset_name_, n_labels)

# Discretize the dataset

data = Dataset.load_arff(dataset_name + ".arff", n_labels, endian = "big", input_feature_type = 'float', encode_nominal = True)
D = LAIMdiscretize(data)
D.discretize()

discretized_data_matrix = np.concatenate((data['Y'],D.X_discretized), axis=1)

Uniques = unique_rows(discretized_data_matrix,data['Y'].shape[1])

print("Unique ", discretized_data_matrix.shape[0], Uniques.shape[0])

data_frame = arff.load(open(dataset_name + ".arff", 'r'), encode_nominal = True, return_type=arff.DENSE)
data_frame['data'] = discretized_data_matrix.astype(int).tolist()
# make the attributes nominal
for i in range(len(data_frame['attributes'])):
    (attr_name, attr_value) = data_frame['attributes'][i]
    data_frame['attributes'][i] = (attr_name, ['0', '1'])
开发者ID:nicoladimauro,项目名称:dcsn,代码行数:33,代码来源:preprocessing.py

示例2: range

# 需要导入模块: from dataset import Dataset [as 别名]
# 或者: from dataset.Dataset import load_arff [as 别名]
                Testing_time = ['Testing time']



                for f in range(args.f):
                
                    C = None

                    # initing the random generators
                    seed = args.seed
                    numpy_rand_gen = numpy.random.RandomState(seed)
                    random.seed(seed)

                    _sample_weight = None

                    train = Dataset.load_arff("./data/"+dataset_name+".f"+str(f)+".train.arff", n_labels, endian = "big", input_feature_type = 'int', encode_nominal = True)
                    train_data = np.concatenate((train['X'],train['Y']), axis = 1)

                    if args.l:
                        l_vars = [i+train['X'].shape[1] for i in range(train['Y'].shape[1])]
                    else:
                        l_vars = []

                    min_instances_ = min_instances
                    if min_instances <= 1:
                        min_instances_ = int(train['X'].shape[0] * min_instances)+1
                        print("Setting min_instances to ", min_instances_)
                    else:
                        min_instances_ = min_instances

                    learn_start_t = perf_counter()
开发者ID:nicoladimauro,项目名称:dcsn,代码行数:33,代码来源:runmlcsn.py

示例3: open

# 需要导入模块: from dataset import Dataset [as 别名]
# 或者: from dataset.Dataset import load_arff [as 别名]
Hamming_score = ['Hamming Score']
Exact_match = ['Exact match']
Time = ['Time']
Headers = ['Metric']

with open(out_log_path, 'w') as out_log:

    out_log.write("parameters:\n{0}\n\n".format(args))
    out_log.flush()


    for f in range(args.f):
        train_file_name = dataset_name + ".f" + str(f) + ".train.arff"
        test_file_name = dataset_name + ".f" + str(f) + ".test.arff"

        data = Dataset.load_arff("./data/"+test_file_name, args.c[0], endian = "big", input_feature_type = 'int', encode_nominal = True)

        meka = Meka(args.mc, args.wc, meka_classpath=args.mp)
        learn_start_t = perf_counter()
        predictions, statistics = meka.run("./data/"+train_file_name, "./data/" + test_file_name)
        learn_end_t = perf_counter()
        learning_time = (learn_end_t - learn_start_t)

        print("Accuracy :     :", statistics['Accuracy'])
        print('Hammingloss    :', statistics['Hammingloss'])
        print('Exactmatch', statistics['Exactmatch'])
        print('BuildTime', statistics['BuildTime'])
        print('TestTime', statistics['TestTime'])

        Accuracy.append(sklearn.metrics.jaccard_similarity_score(data['Y'], predictions))
        Hamming_score.append(1-sklearn.metrics.hamming_loss(data['Y'], predictions))
开发者ID:nicoladimauro,项目名称:dcsn,代码行数:33,代码来源:runmeka.py


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