Skip to content

Instantly share code, notes, and snippets.

@neelindresh
neelindresh / GPG_key_config.md
Created October 18, 2022 12:51 — forked from saradindusengupta/GPG_key_config.md
Git Repository-wise configuration Guide for verified signed commit with GPG in GitHub

Git Repository-wise configuration Guide for verified signed commit with GPG in GitHub

1. Generate GPG keys

  1. Download and install the GPG command line tools for your operating system. We generally recommend installing the latest version for your operating system.
  2. Open Git Bash.
  3. Generate a GPG key pair. If you are not on version 2.1.17 or greater then
    1. gpg --default-new-key-algo rsa4096 --gen-key
  4. Enter your user ID information.
  5. Type a secure passphrase. This is a must.
import torch
import pandas as pd
from sklearn.preprocessing import LabelEncoder
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score,f1_score
from pymlpipe.tabular import PyMLPipe
df=pd.read_csv("train.csv")
encoders=["area_code","state","international_plan","voice_mail_plan","churn"]
for i in encoders:
{
"data": [
[
42.0,
120.0,
1.0,
0.0,
0.0,
0.0,
185.7,
with mlp.run():
mlp.register_artifact("churndata.csv",df)
mlp.log_params({
"lr":0.01,
"optimizer":"SGD",
"loss_fuction":"BCEloss"
})
for epoch in range(epochs):
loss_batch=0
for batch in range(1000,5000,1000):
mlp=PyMLPipe()
mlp.set_experiment("Pytorch")
mlp.set_version(0.2)
def validate(model,testx,testy):
prediction=model(testx)
prediction=torch.where(prediction>.5,1,0)
accu=accuracy_score(prediction.detach().numpy(),test_y.unsqueeze(1).detach().numpy())
f1=f1_score(prediction.detach().numpy(),test_y.unsqueeze(1).detach().numpy())
return {"accuracy":accu,"f1":f1}
model=Model(len(trainx.columns))
optimizer=torch.optim.SGD(model.parameters(),lr=0.001)
criterion=torch.nn.BCELoss()
class Model(torch.nn.Module):
def __init__(self,col_size):
super().__init__()
# using sequencial
self.seq=torch.nn.Sequential(
torch.nn.Linear(col_size,15),
torch.nn.ReLU(),
torch.nn.Linear(15,10),
torch.nn.ReLU(),
torch.nn.Linear(10,1)
train_x,test_x,train_y,test_y=train_test_split(trainx,trainy)
train_x=torch.from_numpy(train_x.values)
train_x=train_x.type(torch.FloatTensor)
train_y=torch.from_numpy(train_y.values)
train_y=train_y.type(torch.FloatTensor)
test_x=torch.from_numpy(test_x.values)
test_x=test_x.type(torch.FloatTensor)
test_y=torch.from_numpy(test_y.values)
df=pd.read_csv("train.csv")
encoders=["area_code","state","international_plan","voice_mail_plan","churn"]
for i in encoders:
le=LabelEncoder()
df[i]=le.fit_transform(df[i])
trainy=df["churn"]
trainx=df[['state', 'account_length', 'area_code', 'international_plan',