Skip to content

Instantly share code, notes, and snippets.

View kareem1925's full-sized avatar

Kareem H. El-Safty kareem1925

View GitHub Profile
@kareem1925
kareem1925 / plot_2_layers_quantum_classifier.py
Last active February 15, 2020 13:40
simple implementation of circuit-centeric quantum classifier using qiskit
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit import *
import numpy as np
qc = QuantumCircuit(3,1)
weights = np.random.rand(18)
# First layer
qc.u3(weights[0],weights[1],weights[2],0)
qc.u3(weights[3],weights[4],weights[5],1)
qc.u3(weights[6],weights[7],weights[8],2)
@kareem1925
kareem1925 / plot_2_layers_quantum_classifier.py
Created February 15, 2020 13:13
simple implementation of circuit-centeric quantum classifier using qiskit
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit import *
import numpy as np
weights = np.random.rand(18)
# First layer
qc.u3(weights[0],weights[1],weights[2],0)
qc.u3(weights[3],weights[4],weights[5],1)
qc.u3(weights[6],weights[7],weights[8],2)
qc.cnot(0,1)
@kareem1925
kareem1925 / plot_linear_svm.py
Last active February 15, 2020 08:11
plotting decision boundary of linear classifier
import numpy as np
import matplotlib.pyplot as plt
from sklearn import svm
X = np.array([[-1,-2],[2,6],[-1.5,-2.8],[4,4],[-1,-9.6], [9,11]])
y = [0,1,0,1,0,1]
clf = svm.SVC(kernel='linear', C = 1.0,tol=1e-12,random_state=5)
@kareem1925
kareem1925 / brightness.py
Created February 4, 2019 20:24 — forked from kmohrf/brightness.py
Calculate Image brightness with Python Pillow
import sys
from PIL import Image
def calculate_brightness(image):
greyscale_image = image.convert('L')
histogram = greyscale_image.histogram()
pixels = sum(histogram)
brightness = scale = len(histogram)