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


Python Dataset.data方法代码示例

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


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

示例1: main

# 需要导入模块: from dataset import Dataset [as 别名]
# 或者: from dataset.Dataset import data [as 别名]
def main():
    while True:
        data_set_name = input("Please provide the name of the data set you want to work with: ")

        # Load, Randomize, Normalize, Discretize Dataset
        data_set = Dataset()
        data_set.read_file_into_dataset("C:\\Users\\Grant\\Documents\\School\\Winter 2016\\CS 450\\Prove03\\" + data_set_name)
        data_set.randomize()
        data_set.data = normalize(data_set.data)
        data_set.discretize()

        data_set.set_missing_data()

        # Split Dataset
        split_percentage = 0.7
        data_sets    = split_dataset(data_set, split_percentage)
        training_set = data_sets['train']
        testing_set  = data_sets['test']

        # Create Custom Classifier, Train Dataset, Predict Target From Testing Set
        id3Classifier = ID3()
        id3Classifier.train(training_set)
        predictions = id3Classifier.predict(testing_set)

        id3Classifier.display_tree(0, id3Classifier.tree)

        # Check Results
        my_accuracy = get_accuracy(predictions, testing_set.target)
        print("Accuracy: " + str(my_accuracy) + "%")

        # Compare To Existing Implementations
        dtc = tree.DecisionTreeClassifier()
        dtc.fit(training_set.data, training_set.target)
        predictions = dtc.predict(testing_set.data)

        dtc_accuracy = get_accuracy(predictions, testing_set.target)
        print("DTC Accuracy: " + str(dtc_accuracy) + "%")

        # Do another or not
        toContinue = False

        while True:
            another = input("Do you want to examine another dataset? (y / n) ")

            if another != 'y' and another != 'n':
                print("Please provide you answer in a 'y' or 'n' format.")
            elif another == 'y':
                toContinue = True
                break
            else:
                toContinue = False
                break

        if not toContinue:
            break
开发者ID:gshawm,项目名称:CS450,代码行数:57,代码来源:main.py

示例2: main

# 需要导入模块: from dataset import Dataset [as 别名]
# 或者: from dataset.Dataset import data [as 别名]
def main():
    while True:
        data_set_name = input("Please provide the name of the data set you want to work with: ")

        # Load, Randomize, Normalize, Discretize Dataset
        data_set = Dataset()
        data_set.read_file_into_dataset("C:\\Users\\Grant\\Documents\\School\\Winter 2016\\CS 450\\Neural\\" + data_set_name)
        data_set.randomize()
        data_set.data = normalize(data_set.data)
        #data_set.discretize()
        #print(data_set.data)

        data_set.set_missing_data()

        # Split Dataset
        split_percentage = 0.7
        data_sets    = data_set.split_dataset(split_percentage)
        training_set = data_sets[0]
        testing_set  = data_sets[1]

        # Create Custom Classifier, Train Dataset, Predict Target From Testing Set
        iterations = int(input("How many iterations do you want to do? "))
        layers = int(input("How many layers do you want in your neural network? "))
        num_nodes = []
        for i in range(layers):
            if i + 1 == layers:
                number = int(input("How many nodes on the output layer? "))
            else:
                number = int(input("How many nodes on the " + str(i) + " layer? "))
            num_nodes.append(number)

        neuralNetwork = NeuralNetwork(iterations)
        neuralNetwork.create_layered_network(num_nodes, training_set.feature_names.__len__())
        #neuralNetwork.display_network()
        neuralNetwork.train(training_set)
        predictions = neuralNetwork.predict(testing_set)

        # Check Results
        my_accuracy = get_accuracy(predictions, testing_set.target)
        print("Accuracy: " + str(my_accuracy) + "%")

        # Compare To Existing Implementations
        layers_objs = []
        for i in range(layers):
            if i + 1 == layers:
                layers_objs.append(Layer("Softmax", units=num_nodes[i]))
            else:
                layers_objs.append(Layer("Sigmoid", units=num_nodes[i]))

        mlp_nn = Classifier(layers=layers_objs, learning_rate=0.4, n_iter=iterations)
        mlp_nn.fit(np.array(training_set.data), np.array(training_set.target))
        predictions = mlp_nn.predict(np.array(testing_set.data))

        mlp_nn_accuracy = get_accuracy(predictions, testing_set.target)
        print("NN Accuracy: " + str(mlp_nn_accuracy) + "%")

        create_csv_file(neuralNetwork.accuracies, "C:\\Users\\Grant\\Documents\\School\\Winter 2016\\CS 450\\Neural\\" + data_set_name + ".csv")
        # Do another or not
        toContinue = False

        while True:
            another = input("Do you want to examine another dataset? (y / n) ")

            if another != 'y' and another != 'n':
                print("Please provide you answer in a 'y' or 'n' format.")
            elif another == 'y':
                toContinue = True
                break
            else:
                toContinue = False
                break

        if not toContinue:
            break
开发者ID:gshawm,项目名称:CS450,代码行数:76,代码来源:main.py


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