Professional Documents
Culture Documents
Лаб 6 Биков Нікіта ІА-12
Лаб 6 Биков Нікіта ІА-12
Ігоря Сікорського»
Факультет Інформатики та Обчислювальної Техніки
Кафедра інформаційних систем та технологій
Лабораторна робота №6
з дисципліни «Методи та технології штучного інтелекту»
Виконав:
студент групи ІА-12
Биков Нікіта
Варіант 9
Викладач:
Шимкович. В. М.
Київ – 2023
1. Постановка задачі
Нейро-нечітке моделювання.
Завдання:
x = torch.tensor(features.values).float()
y = torch.tensor(target.values).float()
plot_real_values(y)
def plot_real_values(y):
plt.figure(figsize=(10, 5))
plt.plot(y)
plt.title('Real values of BTC-USD')
plt.xlabel('Data time')
plt.ylabel('Value')
plt.show()
class HybridNeuralNetwork(nn.Module):
def __init__(self):
super(HybridNeuralNetwork, self).__init__()
self.fc1 = nn.Linear(3, 128)
self.fc2 = nn.Linear(128, 64)
self.fc3 = nn.Linear(64, 1)
def forward(self, x):
x = F.relu(self.fc1(x))
x = F.relu(self.fc2(x))
x = self.fc3(x)
return x
training_losses = []
test_losses = []
model.eval()
with torch.no_grad():
test_outputs = model(x_test)
test_loss = criterion(test_outputs, y_test)
test_losses.append(test_loss.item())
plt.figure(figsize=(10, 5))
plt.plot(y_test.numpy(), label='Real Value')
plt.plot(predictions.numpy(), label='Predicted Value')
plt.title('Comparison of Real and Predicted Values')
plt.xlabel('Data time')
plt.ylabel('Value')
plt.legend()
plt.show()
if __name__ == "__main__":
x_train, x_test, y_train, y_test, dataframe = prepare_data('BTC-USD.csv')
neural_network = HybridNeuralNetwork()
training_losses, test_losses = train_model(neural_network, x_train, y_train, x_test, y_test)
plot_losses(training_losses, test_losses)
predict_and_plot(neural_network, x_test, y_test)