Welcome to Assignments Writing

Your Trusted Partner in Term Paper Writing

At Assignments Writing, we’re a team of passionate educators and skilled writers committed to supporting students in their academic journey.

Implement a Neural Network using Pytorch

Implement a Neural Network using Pytorch


To accomplish this task, you’ll need to follow these steps:

  1. Import necessary libraries.
  2. Load and preprocess the dataset.
  3. Split the data into training and testing sets.
  4. Create a neural network using PyTorch.
  5. Train the neural network.
  6. Evaluate the model on the testing data and report the accuracy.
  7. Print the predicted decisions alongside the real labels.

Here’s a step-by-step implementation in Python using PyTorch:

import torch
import torch.nn as nn
import torch.optim as optim
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.metrics import accuracy_score

# Step 2: Load and preprocess the dataset
data = pd.read_csv('CC_data.csv')

# Assuming that the target column is named 'approved' and all other columns are predictors
X = data.drop('approved', axis=1).values
y = data['approved'].values

# Standardize the data
scaler = StandardScaler()
X = scaler.fit_transform(X)

# Step 3: Split the data into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Step 4: Create a neural network using PyTorch
class NeuralNetwork(nn.Module):
def __init__(self, input_size, hidden_size):
super(NeuralNetwork, self).__init__()
self.fc1 = nn.Linear(input_size, hidden_size)
self.relu = nn.ReLU()
self.fc2 = nn.Linear(hidden_size, 1)
self.sigmoid = nn.Sigmoid()

def forward(self, x):
out = self.fc1(x)
out = self.relu(out)
out = self.fc2(out)
out = self.sigmoid(out)
return out

# Step 5: Train the neural network
input_size = X_train.shape[1]
hidden_size = 64 # Adjust this as needed
model = NeuralNetwork(input_size, hidden_size)
criterion = nn.BCELoss()
optimizer = optim.Adam(model.parameters(), lr=0.001)

num_epochs = 100 # You may need to adjust this
for epoch in range(num_epochs):
inputs = torch.tensor(X_train, dtype=torch.float32)
labels = torch.tensor(y_train, dtype=torch.float32).view(-1, 1)

outputs = model(inputs)
loss = criterion(outputs, labels)

if (epoch + 1) % 10 == 0:
print(f'Epoch [{epoch + 1}/{num_epochs}], Loss: {loss.item()}')

# Step 6: Evaluate the model on the testing data
with torch.no_grad():
test_inputs = torch.tensor(X_test, dtype=torch.float32)
predicted_probabilities = model(test_inputs)
predicted_labels = (predicted_probabilities > 0.5).float().numpy()

accuracy = accuracy_score(y_test, predicted_labels)
print(f'Test Accuracy: {accuracy * 100:.2f}%')

# Step 7: Print the predicted decisions alongside real labels
for i in range(len(X_test)):
print(f'Real: {y_test[i]}, Predicted: {predicted_labels[i][0]}')

Make sure to adjust the hyperparameters like hidden_size, num_epochs, and the architecture of the neural network as needed to achieve at least 80% accuracy on the training data.

Implement a Neural Network using Pytorch





Credit Card Approval. On one of the first lectures, a credit card approval
record with multiple predictors was used as an example to show the use-
fulness of learning from data. Here you will have the chance to create
your own Neural Network based on CC data.csv. The data contains 15
predictors, and one response (approved or denied). You’ll randomly split
your data into training and testing with a 80/20 ratio.
(a) Implement a Neural Network using Pytorch with the following spec-
? Input layer: Number of neurons as number of inputs (15).
? Second layer: fully connected layer with N neurons.
? Set the number of neurons for the second layer N , and the num-
ber of epochs, to obtain an accuracy of at least 80% in the train-
ing data.
(b) Evaluate the model with the testing data, report the accuracy; com-
pute and print the predicted decision for every input of the testing
data (approved or denied) alongside with the real labels.

Place Your Order Here

Our Service Charter

1. Professional & Expert Writers: We only hire the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of master’s and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. We are known for timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: We have put in place a team of experts who answer all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.

Format & Features

Our Advantages

How It Works

1. Fill Order Form
2. Make payment
3. Writing process
4. Download paper

Fill in the order form and submit all your files, including instructions, rubrics, and other information given to you by your instructor.

Once you complete filling the forms, complete your payment. We will get the order and assign it to a writer.

When your order is completed, it’s assigned to an editor for approval. The editor approves the order.

Once approved, we will upload the order to your account for you to download.  You can rate your writer or give your customer review.

What Clients Said


I am very satisfied! thank you for the quick turnaround. I am very satisfied! thank you for the quick turnaround.I am very satisfied! thank you for the quick turnaround.

Mercy M

I am very satisfied! thank you for the quick turnaround. I am very satisfied! thank you for the quick turnaround.I am very satisfied! thank you for the quick turnaround.

Jane L

I am very satisfied! thank you for the quick turnaround. I am very satisfied! thank you for the quick turnaround.I am very satisfied! thank you for the quick turnaround.

Rayan M


We are a freelance academic writing company geared towards provision of high quality academic papers to students worldwide.

Open chat
Scan the code
Can we help you?