import numpy as np import pandas as pd from aibrite.ml.neuralnet import NeuralNet from aibrite.ml.neuralnetwithmomentum import NeuralNetWithMomentum from aibrite.ml.neuralnetwithrmsprop import NeuralNetWithRMSprop from aibrite.ml.neuralnetwithadam import NeuralNetWithAdam df = pd.read_csv("./data/ex2data1.csv") train_set, dev_set, test_set = NeuralNet.split(df.values, 0.8, 0.1, 0.1) train_x, train_y = train_set[:, 0:-1], train_set[:, -1] dev_x, dev_y = dev_set[:, 0:-1], dev_set[:, -1] test_x, test_y = test_set[:, 0:-1], test_set[:, -1] nn = NeuralNet(train_x, train_y, hidden_layers=(2, 2), iteration_count=6000) train_result = nn.train(lambda nn, iter: print("{0:.2f}".format(iter.cost)) if iter.total_iteration_index % 100 == 0 else None) result = nn.predict(test_x, expected=test_y) print("{0}:\n{1}\n".format(nn, NeuralNet.format_score(result.score)))
from aibrite.ml.neuralnet import NeuralNet from aibrite.ml.neuralnetwithmomentum import NeuralNetWithMomentum from aibrite.ml.neuralnetwithrmsprop import NeuralNetWithRMSprop from aibrite.ml.neuralnetwithadam import NeuralNetWithAdam from aibrite.ml.analyser import NeuralNetAnalyser from aibrite.ml.loggers import CsvLogger df = pd.read_csv("./data/winequality-red.csv", sep=";") np.random.seed(5) data = df.values train_set, test_set, dev_set = NeuralNet.split(data, 0.6, 0.20, 0.20, shuffle=True) train_x, train_y = (train_set[:, 0:-1]), train_set[:, -1] dev_x, dev_y = (dev_set[:, 0:-1]), dev_set[:, -1] test_x, test_y = (test_set[:, 0:-1]), test_set[:, -1] labels = [3.0, 4.0, 5.0, 6.0, 7.0, 8.0] normalize_inputs = [True, False] iteration_count = [50, 100, 150] learning_rate = [0.005, 0.002] hidden_layers = [(32, 64, 128), (4, 4)] lambds = [0.4, 0.8, 0.9] learnin_rate_decay = [0.]
from aibrite.ml.neuralnet import NeuralNet from aibrite.ml.neuralnetwithmomentum import NeuralNetWithMomentum from aibrite.ml.neuralnetwithrmsprop import NeuralNetWithRMSprop from aibrite.ml.neuralnetwithadam import NeuralNetWithAdam from aibrite.ml.analyser import NeuralNetAnalyser df = pd.read_csv("./data/ex2data1.csv", sep=",") # df = df[df['quality'] != 8.0] # df = df[df['quality'] != 3.0] np.random.seed(5) data = df.values data = NeuralNet.shuffle(data) train_set, test_set, dev_set = NeuralNet.split(data, 0.7, 0.15, 0.15) train_x, train_y = train_set[:, 0:-1], train_set[:, -1] train_x, train_y = (train_set[:, 0:-1]), train_set[:, -1] dev_x, dev_y = (dev_set[:, 0:-1]), dev_set[:, -1] test_x, test_y = (test_set[:, 0:-1]), test_set[:, -1] labels = [3.0, 4.0, 5.0, 6.0, 7.0, 8.0] iterations = [200] learning_rates = [0.02] hidden_layers = [(4, 6, 12)] lambds = [0.8] test_sets = { 'dev': (dev_x, dev_y), 'test': (test_x, test_y),
from aibrite.ml.neuralnetwithrmsprop import NeuralNetWithRMSprop from aibrite.ml.neuralnetwithadam import NeuralNetWithAdam df = pd.read_csv("./data/winequality-red.csv", sep=";") # df = df[df['quality'] != 8.0] # df = df[df['quality'] != 3.0] # print(df.values.shape) # np.random.seed(1) data = df.values # data = NeuralNet.shuffle(data) train_set, dev_set, test_set = NeuralNet.split(data, 0.6, 0.2, 0.2) train_x, train_y = train_set[:, 0:-1], train_set[:, -1] train_x, train_y = NeuralNet.zscore(train_set[:, 0:-1]), train_set[:, -1] dev_x, dev_y = NeuralNet.zscore(dev_set[:, 0:-1]), dev_set[:, -1] test_x, test_y = NeuralNet.zscore(test_set[:, 0:-1]), test_set[:, -1] labels = [3.0, 4.0, 5.0, 6.0, 7.0, 8.0] iterations = [2000] learning_rates = [0.008] hidden_layers = [(24, 36, 24, 12, 6)] test_sets = { 'dev': (dev_x, dev_y), 'test': (test_x, test_y), 'train': (train_x, train_y)
import numpy as np import pandas as pd from aibrite.ml.neuralnet import NeuralNet from aibrite.ml.neuralnetwithmomentum import NeuralNetWithMomentum from aibrite.ml.neuralnetwithrmsprop import NeuralNetWithRMSprop from aibrite.ml.neuralnetwithadam import NeuralNetWithAdam df = pd.read_csv("./data/winequality-red.csv", sep=";") train_set, dev_set, test_set = NeuralNet.split(df.values, 0.8, 0.1, 0.1, shuffle=True) train_x, train_y = train_set[:, 0:-1], train_set[:, -1] dev_x, dev_y = dev_set[:, 0:-1], dev_set[:, -1] test_x, test_y = test_set[:, 0:-1], test_set[:, -1] nn = NeuralNetWithAdam(train_x, train_y, hidden_layers=(32, 64, 128, 64), iteration_count=500, learning_rate=0.005, epochs=1, shuffle=True, normalize_inputs=True) train_result = nn.train()