Nexclap

decision tree

https://colab.research.google.com/drive/1HrpTGrh5K6d7OCOIAaF8X66AXw5w8Ofk?usp=share_link
from sklearn.ensemble import RandomForestClassifier rfc = RandomForestClassifier(n_estimators=100) rfc.fit(x_train,y_train)

KNN

This my code for KNN


import operator import math from math import sqrt def distance(x,x1,y,y1): return sqrt((x1-x)**2+(y1-y)**2) def sort(lists): for i in range(0,len(lists)-1): for j in range(1, len(lists)): if(lists[i]>lists[j]): temp=lists[i] lists[i]=lists[j] lists[j]=temp data=[(1, 10, "blue"), (3, 9, "blue"), (4,5, "red"),(3, 0, "blue"), (6, 7, "red"), (5,3, "red"),(3, 2, "blue"), (7, 6, "blue"), (4,2, "red"),(7, 0, "blue"), (2, 7, "blue"), (7,4, "red"),(3, 11, "blue"), (11, 9, "blue"), (1, 14, "blue"), (2, 2, "blue"), (12,8, "red")] x=int(input("What is the point's x coordinate: ")) y=int(input("What is the point's y coordinate: ")) k=int(input("What is the number of points you want to check with:")) print("The data being used is", data) mydict={} mylist=[] colors=[] kvalues=[] temp=0 col=0 for i in data: mydict[i[2]]=distance(x,i[0],y,i[1]) mylist.append(distance(x,i[0],y,i[1])) sort(mylist) for i in range(k): kvalues.append(mylist[i]) for key in mydict: for i in kvalues: if mydict[key]-i==0: colors.append(key) for i in colors: if(i=="blue"): col=col-1 else: col=col+1 if(col>0): print("The color is red") elif(col<0): print("The color is blue") else: print("There is not one single color. There are equal number of red and blue")

dna converter

this is my interpretation of the DNA converter from python1B

from random import randint length = int(input("Enter a length of a DNA: ")) DNA = [] RNA = "" dna = "" a_a = "" amino_acid = [] C_D = ["A","T","C","G"] toRNA = {"A":"U","T":"A","C":"G","G":"C"} amino_acids = {"A":["GCA","GCC","GCG","GCU"],"C":["UGC","UGU"],"D":["GAC","GAU"],"E":["GAA","GAG"],"F":["UUC","UUU"],"G":["GGA","GGC","GGG","GGU"],"H":["CAC","CAU"],"I":["AUA","AUC","AUU"],"K":["AAA","AAG"],"L":["UUA","UUG","CUA","CUC","CUG","CUU"],"M":["AUG"],"N":["AAC","AAU"],"P":["CCA","CCC","CCG","CCU"],"Q":["CAA","CAG"],"R":["AGA","AGG","CGA","CGC","CGG","CGU"],"S":["AGC","AGU","UCA","UCC","UCG","UCU"],"T":["ACA","ACC","ACG","ACU"],"V":["GUA","GUC","GUG","GUU"],"W":["UGG"],"Y":["UAC","UAU"]} # making a DNA for i in range(length): DNA.append(C_D[randint(0,3)]) print(">>> DNA") for i in DNA: dna += i print(">>>> "+dna) # converting the DNA into a RNA. for i in DNA: RNA+=toRNA[i] print(">>> RNA") print(">>>> "+RNA) # converting the RNA to amino acid chain. for i in range(0,len(RNA),3): for item,value in amino_acids.items(): for v in value: if v == RNA[i:i+3]: #print(RNA[i:i+3],v,item) amino_acid.append(item) print(">>> amino_acid") for i in amino_acid: a_a += i print(">>>> "+a_a)
Announcements
  • Test Announcement from Nexclap

    Test message from nexclap - please ignore

    2023-02-13

  • Test message

    Test message from nexclap - please ignore

    2023-02-11

  • Test message

    Test message from nexclap - please ignore

    2023-02-11

  • View all