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
| # Build the recommendation model using ALS on the training data | |
| als = ALS(maxIter=5, regParam=0.01, userCol="userId", itemCol="movieId", ratingCol="rating") | |
| model = als.fit(training) |
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 | |
| from pyspark.sql import SparkSession | |
| spark = SparkSession.builder.appName('recnn').getOrCreate() | |
| #Display the first Row of Dataframe | |
| data.head() | |
| data.describe().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
| import pandas as pd | |
| from pyspark.sql import SparkSession | |
| spark = SparkSession.builder.appName('recnn').getOrCreate() |
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 numpy as np | |
| import cv2 | |
| import matplotlib.pyplot as plt | |
| denis = cv2.imread('../DATA/Denis_Mukwege.jpg',0) | |
| ##OpenCV comes with these pre-trained cascade files | |
| face_cascade = cv2.CascadeClassifier('../DATA/haarcascades/haarcascade_frontalface_default.xml') | |
| def detect_face(img): | |
| face_img = img.copy() |
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 cv2 | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| img = cv2.imread('../DATA/internal_external.png',0) | |
| image, contours, hierarchy = cv2.findContours(img, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_SIMPLE) | |
| # Draw External Contours | |
| # Set up empty array | |
| external_contours = np.zeros(image.shape) |
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 the required libraries | |
| import numpy as np | |
| import cv2 | |
| import matplotlib.pyplot as plt | |
| %matplotlib inline | |
| def display_img(img): | |
| fig = plt.figure(figsize=(12,10)) | |
| ax = fig.add_subplot(111) | |
| ax.imshow(img,cmap='gray') | |
| #read the image |
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 cv2 | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| def load_img(): | |
| img = cv2.imread('../DATA/bricks.jpg').astype(np.float32) / 255 | |
| img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) | |
| return img | |
| def display_img(img): | |
| fig = plt.figure(figsize=(12,10)) |
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 cv2 | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| def load_img(): | |
| img = cv2.imread('../DATA/bricks.jpg').astype(np.float32) / 255 | |
| img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) | |
| return img | |
| def display_img(img): | |
| fig = plt.figure(figsize=(12,10)) |
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 cv2 | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| %matplotlib inline | |
| #here 0 means that the image is loaded in gray scale format | |
| gray_image = cv2.imread('../DATA/Nadia_Murad.jpg',0) | |
| ret,thresh_binary = cv2.threshold(gray_image,127,255,cv2.THRESH_BINARY) | |
| ret,thresh_binary_inv = cv2.threshold(gray_image,127,255,cv2.THRESH_BINARY_INV) |
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 numpy as np | |
| import cv2 | |
| import matplotlib.pyplot as plt | |
| img1 = cv2.imread('../DATA/dog_backpack.png') | |
| img1 = cv2.cvtColor(img1, cv2.COLOR_BGR2RGB) | |
| plt.imshow(img1) | |
| img1.shape | |
| x_offset=934-600 | |
| y_offset=1401-600 |