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.
This file contains hidden or 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 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) |
This file contains hidden or 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 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) |
This file contains hidden or 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
| ### 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 |
This file contains hidden or 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
| # 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 |
This file contains hidden or 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 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() |
This file contains hidden or 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
| ## 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]) |
This file contains hidden or 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 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 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OlderNewer