This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
x = torch.ones(3) # Input Tensor | |
y = torch.zeros(2) # Expected Output Tensor | |
w = torch.randn(3, 2, requires_grad=True) # Weight matrix | |
b = torch.randn(2 , requires_grad=True) # Bias | |
z = torch.matmul(x, w) + b # Calculated output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import json | |
def readJson(filename,) -> dict: | |
""" | |
Reads a json file and returns a dictionary | |
""" | |
file = open(filename, 'r') | |
data = file.read() | |
file.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from super_gradients.training import models | |
import supervision as sv | |
import torch | |
import cv2 | |
# install the required packages | |
# pip install -q super-gradients==3.1.1 supervision | |
# predict function to predict the image | |
def predict(img, model): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install rembg | |
from PIL import Image | |
from rembg import remove | |
input = Image.open('mahimai.jpeg') | |
output = remove(input) | |
output.save('output.png') | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scipy import stats | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
df = pd.read_csv('your_csv_name') | |
col = df['Grade'] | |
density = stats.gaussian_kde(col) | |
col.plot.density() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author : Mahimai Raja J | |
# Date : 24.01.2023 | |
from sklearn.preprocessing import StandardScaler | |
from sklearn.compose import ColumnTransformer | |
from sklearn.pipeline import Pipeline | |
from sklearn.linear_model import LogisticRegression | |
# Define preprocessing for numeric columns (scale them) | |
feature_columns = [0,1,2,3] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Train the model | |
import numpy as np | |
from sklearn.compose import ColumnTransformer | |
from sklearn.pipeline import Pipeline | |
from sklearn.impute import SimpleImputer | |
from sklearn.preprocessing import StandardScaler, OneHotEncoder | |
from sklearn.linear_model import LinearRegression | |
# Define preprocessing for numeric columns (scale them) |