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 pandas as pd | |
| import numpy as np | |
| from sklearn.model_selection import train_test_split | |
| from sklearn.linear_model import LinearRegression | |
| from sklearn.preprocessing import OneHotEncoder | |
| from sklearn.compose import make_column_transformer | |
| from sklearn.pipeline import make_pipeline | |
| from sklearn.metrics import r2_score |
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 airflow.models import DAG | |
| from airflow.contrib.sensors.file_sensor import FileSensor | |
| from airflow.operators.bash_operator import BashOperator | |
| from airflow.operators.python_operator import PythonOperator | |
| from airflow.operators.python_operator import BranchPythonOperator | |
| from airflow.operators.dummy_operator import DummyOperator | |
| from airflow.operators.email_operator import EmailOperator | |
| from dags.process import process_data | |
| from datetime import datetime, timedelta |
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 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 |
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
| 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
| # 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
| ### 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 |
NewerOlder