ACT or SAT

This code calculates ACT and SAT scores and GPA.

i= int(input("Do you have 1) SAT scores or 2) ACT scores?")) if i==1: Math=int(input("SAT math?")) Criticalreading= int(input("SAT reading")) Writing=int(input("SAT Writing")) X= (2*Math+Criticalreading+Writing)/32 print(X) OverallGPA=float(input("What is your overall GPA?")) MaxGPA=float(input("What is the max GPA")) TranscriptMult=float(input("Transcript Multiplier?")) GPA1=OverallGPA/MaxGPA*100*TranscriptMult print("GPA score:") print(GPA1) elif i==2: English=int(input("ACT English")) Math=int(input("ACT math?")) Reading=int(input("ACT reading")) Science=int(input("ACT science")) Y= (English+2*Math+Reading+Science)/1.8 print(Y) OverallGPA=float(input("What is your overall GPA?")) MaxGPA=float(input("What is the max GPA")) TranscriptMult=float(input("Transcript Multiplier?")) GPA2=OverallGPA/MaxGPA*100*TranscriptMult print("GPA score:") print(GPA2) i= int(input("Do you have 1) SAT scores or 2) ACT scores?")) if i==1: Math=int(input("SAT math?")) Criticalreading= int(input("SAT reading")) Writing=int(input("SAT Writing")) X= (2*Math+Criticalreading+Writing)/32 print(X) OverallGPA=float(input("What is your overall GPA?")) MaxGPA=float(input("What is the max GPA")) TranscriptMult=float(input("Transcript Multiplier?")) GPA1=OverallGPA/MaxGPA*100*TranscriptMult print("GPA score:") print(GPA1) elif i==2: English=int(input("ACT English")) Math=int(input("ACT math?")) Reading=int(input("ACT reading")) Science=int(input("ACT science")) Y= (English+2*Math+Reading+Science)/1.8 print(Y) OverallGPA=float(input("What is your overall GPA?")) MaxGPA=float(input("What is the max GPA")) TranscriptMult=float(input("Transcript Multiplier?")) GPA2=OverallGPA/MaxGPA*100*TranscriptMult print("GPA score:") print(GPA2) Overallscore1=GPA1+X Overallscore2=GPA2+Y print("First applicant overall score:") print(Overallscore1wel) print("Second applicant overall score:") print(Overallscore2) if Overallscore1<Overallscore2: print("The first applicant seems to be better") if Overallscore1>Overallscore2: print("The second applicant seems to be better") if Overallscore1==Overallscore2: print("They are the same in value")

Fractions

this adds,subtracts,multiplies,divides fractions and returns the fraction

class Fraction: '''represents fractions''' def __init__(self,num,denom): self.num=num self.denom=denom '''Fraction(num,denom) -> Fraction creates the fraction object representing num/denom''' if denom == 0: # raise an error if the denominator is zero raise ZeroDivisionError def __str__(self): lst=[] if self.num == 0: return "0" if self.num<0: neg=-self.num for i in range(1,neg+1): if self.num/i==self.num//i and self.denom/i==self.denom//i: lst.append(-1*i) minimum=min(lst) smplfiednum=self.num//minimum smplfieddenom=self.denom//minimum return str(smplfiednum)+'/'+str(smplfieddenom) elif self.num>0: for n in range(1,self.num+1): if self.num/n==self.num//n and self.denom/n==self.denom//n: lst.append(n) maximum=max(lst) smplfiednum=self.num//maximum smplfieddenom=self.denom//maximum return str(smplfiednum)+'/'+str(smplfieddenom) def __float__(self): return self.num/self.denom def add(self, other): newdenom = self.denom*other.denom newnum = (self.num*other.denom)+(other.num*self.denom) #self.denom=newdenom #self.num=newnum return Fraction(newnum, newdenom) def sub(self, other): newdenom = self.denom*other.denom newnum = (self.num*other.denom)-(other.num*self.denom) #self.denom=newdenom #self.num=newnum return Fraction(newnum,newdenom) def mul(self, other): newdenom = self.denom*other.denom newnum = self.num*other.num #self.denom=newdenom #self.num=newnum return Fraction(newnum,newdenom) def div(self, other): newdenom = self.denom*other.num newnum = self.num*other.denom #self.denom=newdenom #self.num=newnum return Fraction(newnum,newdenom) def eq(self,other): if self.denom/other.denom==self.num/other.num: return True else: return False # examples #getting p p = Fraction(3,6) print(p) # should print 1/2 q = Fraction(10,-60) print(q) # should print -1/6 r = Fraction(-24,-48) print(r) # should also print 1/2 x=float(p) print(x) # should print 0.5 ### if implementing "normal" arithmetic methods print(p.add(q)) # should print 1/3, since 1/2 + (-1/6) = 1/3 print(p.sub(q)) # should print 2/3, since 1/2 - (-1/6) = 2/3 print(p.sub(p)) # should print 0/1, since p-p is 0 print(p.mul(q)) # should print -1/12 print(p.div(q)) # should print -3/1 print(p.eq(r)) # should print True print(p.eq(q)) # should print False

Password interpreter

The code checks a password to see if its meeting desired requirements.

def check_upper(input): uppers = 0 upper_list = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z".split() for char in input: if char in upper_list: uppers += 1 if uppers > 0: return True else: return False def check_lower(input): lowers = 0 lower_list = "a b c d e f g h i j k l m n o p q r s t u v w x y z".split() for char in input: if char in lower_list: lowers += 1 if lowers > 0: return True else: return False def check_number(input): numbers = 0 number_list = "1 2 3 4 5 6 7 8 9 0".split() for char in input: if char in number_list: numbers += 1 if numbers > 0: return True else: return False def check_special(input): specials = 0 special_list = "! @ $ % ^ & * ( ) _ - + = { } [ ] | \ , . > < / ? ~ ` \" ' : ;".split() for char in input: if char in special_list: specials += 1 if specials > 0: return True else: return False def check_len(input): if len(input) >= 8: return True else: return False def validate_password(input): check_dict = { 'upper': check_upper(input), 'lower': check_lower(input), 'number': check_number(input), 'special': check_special(input), 'len' : check_len(input) } if check_upper(input) & check_lower(input) & check_number(input) & check_special(input) & check_len(input): return True else: print("Invalid password! Review below and change your password accordingly!") if check_dict['upper'] == False: print("Password needs at least one upper-case character.") if check_dict['lower'] == False: print("Password needs at least one lower-case character.") if check_dict['number'] == False: print("Password needs at least one number.") if check_dict['special'] == False: print("Password needs at least one special character.") if check_dict['len'] == False: print("Password needs to be at least 8 characters in length." ) print while True: password = input("Enter desired password: ") print if validate_password(password): print("Password meets all requirements and may be used.") print print("Exiting program...") print exit(0)

Decision Tree Regression Without Sklearn

Finally finished one split optimization.


#Imports from matplotlib import pyplot as plt from math import sqrt import numpy as np # Data X = np.array([1, 1, 2, 1, 2, 5, 6, 5, 7, 5]) y = np.array([2, 3, 2, 3, 3, 6, 7, 6 , 7, 7]) # Euclidean Distance def distance(x1, x2, y1, y2): return sqrt((x2 - x1)**2+(y2 - y1)**2) # Sum def sum(a): final = 0 for i in a: final += i return final # Calculate standard deviation def deviate(xleft, xright, yleft, yright, centroids): distance1 = [] distance2 = [] lxc, lyc = centroids[0] rxc, ryc = centroids[1] for i in range(0, len(xleft)-1): x = xleft[i] y = yleft[i] d = distance(lxc, x, lyc, y) distance1.append(d) for i in range(0, len(xright)-1): x = xright[i] y = yright[i] d = distance(rxc, x, ryc, y) distance2.append(d) return (np.std(distance1), np.std(distance2)) # Train function def train(X, y, split=2, step=1): split = split + 1 # Splits xleft, xright = X[:split], X[split:] yleft, yright = y[:split], y[split:] # Calculate centroids of each side x1, x2 = sum(xleft)/len(xleft), sum(xright)/len(xright) y1, y2 = sum(yleft)/len(yleft), sum(yright)/len(yright) # plot split plt.plot(np.append(split-1, split-1), np.array([0, 10])) centers = [(x1, y1), (x2, y2)] std = deviate(xleft, xright, yleft, yright, centers) # Plot data plt.scatter(X, y, marker="o") # plot centers plt.scatter(np.array(centers[0][0]), np.array(centers[0][1]), marker="v") plt.scatter(np.array(centers[1][0]), np.array(centers[1][1]), marker="v") plt.show() # Call recursive function "regressor" return _train(np.delete(X, 0), np.delete(y, 0), split+1, opt=(0, split), optdev=std, step=step, initX=X, inity=y) # Recursive function def _train(X, y, split, opt=None, optdev=None, step=None, initX=None, inity=None): if len(X) < split+step: print("DONE WITH RECURSIVE PROCESS") print(f"RESULTS: Optimal Split:{opt}, Optimized Standard Deviation: left:{optdev[0]} right:{optdev[1]}") return (opt, optdev) # Splits xleft, xright = initX[:split], initX[split:] yleft, yright = inity[:split], inity[split:] # Calculate centroids of each side x1, x2 = sum(xleft)/len(xleft), sum(xright)/len(xright) y1, y2 = sum(yleft)/len(yleft), sum(yright)/len(yright) # plot split plt.plot(np.append(split-1, split-1), np.array([0, 10])) centers = [(x1, y1), (x2, y2)] std = deviate(xleft, xright, yleft, yright, centers) # Plot data plt.scatter(initX, inity, marker="o") # plot centers plt.scatter(np.array(centers[0][0]), np.array(centers[0][1]), marker="v") plt.scatter(np.array(centers[1][0]), np.array(centers[1][1]), marker="v") plt.show() # Call recursive function "regressor" return _train(np.delete(X, 0), np.delete(y, 0), split+1, opt=opt, optdev=optdev, step=step, initX=initX, inity=inity) x = train(X, y, split=4)

Decision Tree Regression Without Sklearn

The main purpose of this program is to do decision tree regression without using any machine learning libraries (Keras, Sklearn, etc.) I'm currently in the process of creating the regressor. I'm using a recursive function to act as the regressor for my task.


#Imports from matplotlib import pyplot as plt from math import sqrt import numpy as np # Data X = np.array([1, 1, 2, 1, 2, 5, 6, 5, 7, 5]) y = np.array([2, 3, 2, 3, 3, 6, 7, 6 , 7, 7]) # Euclidean Distance def distance(x1, x2, y1, y2): return sqrt((x2 - x1)**2+(y2 - y1)**2) # Sum def sum(a): final = 0 for i in a: final += i return final # Calculate standard deviation for both sides def deviate(xleft, xright, yleft, yright, centroids): distance1 = [] distance2 = [] lxc, lyc = centroids[0] rxc, ryc = centroids[1] for i in range(0, len(xleft)-1): x = xleft[i] y = yleft[i] d = distance(lxc, x, lyc, y) distance1.append(d) for i in range(0, len(xright)-1): x = xright[i] y = yright[i] d = distance(rxc, x, ryc, y) distance2.append(d) return (np.std(distance1), np.std(distance2)) # Helper function that calculates initial split and calls recersive function def train(X, y, split=2): # Splits xleft, xright = X[:split], X[split:] yleft, yright = y[:split], y[split:] # Calculate centroids of each side x1, x2 = sum(xleft)/len(xleft), sum(xright)/len(xright) y1, y2 = sum(yleft)/len(yleft), sum(yright)/len(yright) # plot split plt.plot(np.append(split-1, split-1), np.array([0, 10])) centers = [(x1, y1), (x2, y2)] std = deviate(xleft, xright, yleft, yright, centers) # Plot data plt.scatter(X, y, marker="o") # plot centers plt.scatter(np.array(centers[0][0]), np.array(centers[0][1]), marker="v") plt.scatter(np.array(centers[1][0]), np.array(centers[1][1]), marker="v") plt.show() # Recursive Function def _train(X, y, split, opt=None, optdev=None): pass train(X, y, split=5)
Akhil Yeleswar Apr 11

nice work!

Sports Clothing Image Recognition

A project I worked on early last year involved taking an image of sports clothing and matching the image to the actual product on Amazon. It would be cool to see if someone could add extra features to this such that the program could retrieve the product from other clothing sites as well and filter for the cheapest ones. The video shows the current status of the project and the github link is here: https://github.com/akhily1/Sports-Apparel-Matching


1 ... 28 29