fandaal: (Default)
ну вот и пригождается этот блог.
жж висит с переменным успехом уже долго..
#classification
import math
class Predmet:
    def __init__():
        return
class Category(Predmet):
    pass
def Proto():#cathegory prototype calculation
    return
def Exemplar(m,n):#n is number of attributes, m is a range of attribute
    import random
    a=[]
    for i in range(n):
        a.append(random.randint(0,m))
    return a
def Distance(d,f):#calculates the distance between 2 exemplars
    dis=0
    for i in range(len(d)-1):
        dlin=(d[i]-f[i])*(d[i]-f[i])
        dis=dis+dlin
    return math.sqrt(dis)
def AverageDis(vid):
    aw=0
    for i in range(len(vid)-1):
        aw=aw+Distance(vid[i],vid[i+1])
    return aw/(len(vid))
        
c=3
cat=[]
klas=[]
while c>0:
    b=Exemplar(5,10)
    print(b)
    c=input()
    c=int(c)
    if c==1:
        cat.append(b)
    if c==2:
            klas.append(b)
print('first category')
print(cat)
print('second category')
print(klas)
print('distances between first category first two objects')
print(Distance(cat[0],cat[1]))
print('Average distances between 1 cat objects')

    

Profile

fandaal: (Default)
fandaal

August 2011

S M T W T F S
 123456
78910111213
14151617181920
21222324252627
28 293031   

Syndicate

RSS Atom

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 26th, 2017 01:55 am
Powered by Dreamwidth Studios