Skip to content

Instantly share code, notes, and snippets.

View ankitmishra88's full-sized avatar

Ankit Mishra ankitmishra88

  • India
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
p_arr=[]
arr=[[0,True,0] for i in range(1000001)]
def preprocess():
arr[0][1]=False
arr[1][1]=False
arr[2][2]=2
p=2
while(p*p<=1000001):
#print(p,arr[p][1])
#-------pi(r^2)=(n!)^2
import math
fact=[1]
#----------Preprocessing---------------#
def preprocess():
for i in range(100000):
fact.append((fact[i]*(i+1))%1000000007)
def main():
preprocess()
t=int(input())
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import numpy as np
import math
import matplotlib.pyplot as plt
#----------Pegasos Code definition------------------------#
def pegasos(feature_matrix,labels,T):
theta=np.array([0]*feature_matrix.shape[1])
theta_0=0
count=0
L=2 #value for lambda
for i in range(T):
import numpy as np
def perceptron(features,labels):
theta=np.array([0]*len(features[0]))
theta0=0
t=10
count=1
sum_theta=theta
sum_theta_0=theta0
while(t):
t=t-1
import numpy as np
def perceptron(features,labels):
theta=np.array([0]*len(features[0]))
theta0=0
t=10
while(t):
t=t-1
for i in range(len(features)):
if (np.dot(features[i],theta)+theta0)*labels[i]<=0:
#print('mistake')
import numpy as np
import matplotlib.pyplot as plt
def plot(x,y,m,b):
plt.scatter(x,y)
# datapoints
y_pred=[i*m+b for i in x]
plt.plot(x,y) #classifier line
plt.show()