本文整理汇总了Python中dataset.Dataset.split_dataset方法的典型用法代码示例。如果您正苦于以下问题:Python Dataset.split_dataset方法的具体用法?Python Dataset.split_dataset怎么用?Python Dataset.split_dataset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dataset.Dataset
的用法示例。
在下文中一共展示了Dataset.split_dataset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from dataset import Dataset [as 别名]
# 或者: from dataset.Dataset import split_dataset [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