# Making Predictions with Logistic Regression in PyTorch
# https://machinelearningmastery.com/making-predictions-with-logistic-regression-in-pytorch/

# In this tutorial, we’ll focus on making predictions with logistic regression. We’ll learn how some of the useful packages in the PyTorch library can help easily create a logistic regression model. Particularly, we’ll learn:

# How to make predictions with logistic regression in PyTorch.
# The logistic function and its implementation on tensors.
# How to build a logistic regression model with nn.Sequential.
# How to build a custom module for logistic regression.


import torch
torch.manual_seed(42)

# build custom module for logistic regression
class LogisticRegression(torch.nn.Module):    
    # build the constructor
    def __init__(self, n_inputs):
        super(LogisticRegression, self).__init__()
        self.linear = torch.nn.Linear(n_inputs, 1)

    # make predictions
    def forward(self, x):
        y_pred = torch.sigmoid(self.linear(x))
        return y_pred

x = torch.tensor([[1], [2], [3], [4]], dtype=torch.float32)
log_regr_cus = LogisticRegression(1)
y_pred = log_regr_cus(x)
print("here is model prediction: ", y_pred)

