Skip to content
Binary file added machine learning/Accuracy using SVM Model.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions machine learning/Data Visualization.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#Through this program, i am plotting the graph for comparison of year wise percentage of usage of bus.

import numpy as np
import matplotlib.pyplot as plt


# creating the dataset
data = {'2015':71, '2016':81, '2017':84,
'2018':79, '2019':85}
courses = list(data.keys())
values = list(data.values())

fig = plt.figure(figsize = (10, 5))

# creating the bar plot
plt.bar(courses, values, color ='maroon',
width = 0.4)

plt.xlabel("Year wise Comparison")
plt.ylabel("Percentage Usage of Buses")
plt.title("Buses Usage Survey of 4 Years")
plt.show()
Binary file added machine learning/Face Original Image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added machine learning/Face_Mask Result Image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 70 additions & 0 deletions machine learning/Face_Mask _Program.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# -*- coding: utf-8 -*-
"""FaceMask Program.ipynb

Automatically generated by Colaboratory.

Original file is located at
https://colab.research.google.com/drive/1nV51hyNEW5c_kN41Z_VruKXOlQMVR7TF

Task - Face Mask Challange By Shubham Jha

Problem - You are provided with some sample images along with this task. These are images extracted from a Celebrity Dataset to be used for segmentation. The task here though, is to crop the original image (named like 'xx.jpg') using it's corresponding mask provided (named like '000xx_skin.png').
For a complete illustration see all cells below.

For this task you should only use 'numpy' for the masking task. Please use standard image processing libraries like opencv, seaborn, matplotlib etc.

Imports and Dependencies
"""

import numpy as np
import pandas as pd
import cv2 as cv
from google.colab.patches import cv2_imshow # for image display
from skimage import io
from PIL import Image
import matplotlib.pylab as plt
import os
from sklearn.datasets import load_sample_images

from PIL import Image
img = plt.imread('/content/FaceMaskData/62.jpg')
plt.imshow(img)
print(img.shape)

img_face = cv2.imread('/content/FaceMaskData/62.jpg')
img_mask = cv2.imread('/content/FaceMaskData/00062_skin.png')
##Resizing images
img_face = cv2.resize(img_face, (400,400), interpolation = cv2.INTER_AREA)
img_mask = cv2.resize(img_mask, (400,400), interpolation = cv2.INTER_AREA)


for h in range(len(img_mask)):
for w in range(len(img_mask)):
if img_mask[h][w][0] == 0:
for i in range(3):
img_face[h][w][i] = 0
else:
continue

plt.imshow(img_face)

from PIL import Image
img = plt.imread('/content/FaceMaskData/5.jpg')
plt.imshow(img)
print(img.shape)

img_face = cv2.imread('/content/FaceMaskData/5.jpg')
img_mask = cv2.imread('/content/FaceMaskData/00005_skin.png')
##Resizing images
img_face = cv2.resize(img_face, (400,400), interpolation = cv2.INTER_AREA)
img_mask = cv2.resize(img_mask, (400,400), interpolation = cv2.INTER_AREA)

for h in range(len(img_mask)):
for w in range(len(img_mask)):
if img_mask[h][w][0] == 0:
for i in range(3):
img_face[h][w][i] = 0
else:
continue

plt.imshow(img_face)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions machine learning/SvmAlgorithm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""Implementation of SVM Algorithm Using Python - By Shubham Jha
"""

from sklearn import svm, datasets
import matplotlib.pyplot as plt
import numpy as np
from sklearn.metrics import accuracy_score
from sklearn.model_selection import train_test_split

iris = datasets.load_iris()

X = iris.data[:, :12] # we will take twelve features
y = iris.target
x_train, x_test, y_train, y_test = train_test_split(X, y, random_state = 0, test_size = 0.25)

clf = svm.SVC(kernel='linear', C=1).fit(x_train, y_train)

import pandas as pd
Iris = pd.read_csv("/content/train_qnU1GcL.csv")
Iris.head(20)

classifier_predictions = clf.predict(x_test)
print(accuracy_score(y_test, classifier_predictions)*100)


#Accuracy of this model is - 97.36842105263158