Skip to content

Instantly share code, notes, and snippets.

View samyumobi's full-sized avatar
🍇
__/\__ Namaste ! Vanakam

Samyuktha samyumobi

🍇
__/\__ Namaste ! Vanakam
View GitHub Profile
@samyumobi
samyumobi / dog_classifier.ipynb
Created March 15, 2021 02:37
Dog_Classifier.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@samyumobi
samyumobi / Logistic regression.py
Created October 5, 2021 11:57
Sklearn Logistic regression code snippet
from sklearn.datasets import load_iris
from sklearn.linear_model import LogisticRegression
X, y = load_iris()
clf = LogisticRegression(random_state = 0).fit(X,y)
clf.predict(X[:2,:])
clf.predict_proba(X[:2,:])
clf.score(X,y)
from sklearn.model_selection import train_test_split
# Creating the training and testing data
X_train, X_test, Y_train, Y_test = train_test_split(X, y, test_size=0.33)
# Initializing an logistic regression object
clf = LogisticRegression()
# Fit the model to training and test sets
clf.fit(X_train,Y_train)
### Hyper parameter tuning Logistic Regression model
from sklearn.model_selection import GridSearchCV
from sklearn import linear_model
from sklearn.pipeline import make_pipeline
lr = linear_model.LogisticRegression(solver ='lbfgs', penalty = 'l2')
# Use gridsearch CV to search for the bes parameter
# Scaling the data
from sklearn.preprocessing import StandardScaler
from sklearn.pipeline import Pipeline
po = [('scaler',StandardScaler()),('logistic_reg',LogisticRegression(C=10))]
p = Pipeline(po)
lr4 = p.fit(X_train, Y_train)
print("Scaled Accuracy score : ",100*lr4.score(X_test,Y_test),"% \n")
# Logistic Regression coefficients
import sys, cv2
import matplotlib.pyplot as plt
## Load the image
f = sys.argv[1]
img = cv2.imread('/a.jpeg')
## display the image
plt.imshow(img)
plt.show()
## Load the image
f3 = sys.argv[1]
img3 = img
## convert image to grayscale and display img
img3_gray = cv2.cvtColor(img3, cv2.COLOR_BGR2GRAY)
cv2_imshow(img3_gray)
## histogram equalization of color images
img3c = cv2.cvtColor(img3,cv2.COLOR_BGR2YUV)
## equalize the pixels across y channel and display
img3c[:,:,0] = cv2.equalizeHist(img3c[:,:,0])
from google.colab.patches import cv2_imshow
## load new image and convert to gray scale
f2 = sys.argv[1]
img2 = cv2.imread('/iPhone_camera_1615895489376.webp',cv2.IMREAD_GRAYSCALE)
## ht, width of image
h, w = img2.shape
## horizontal edge detection
sobel_h = cv2.Sobel(img2, cv2.CV_64F, 1, 0, ksize = 5)
## Vertical edge detection
@samyumobi
samyumobi / car-damage-detection-colab.ipynb
Created January 5, 2022 06:20
car-damage-detection-colab.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.