Beispiel #1
0
def testBench(request) :
    grab_list = []
    try : 
        print util.parse("apphello", "3.2.1", "0")
        grab_list = util.parse("apphello", "3.2.1", "0")
        grab_list = ["foo", "bar", "baz"]
    except :
        return HttpResponse("No lines found")
    lineString = ""
    for line in grab_list :
        lineString = lineString + line + "<br>"
    #t = loader.get_template('/home/kawaii5/Stationerry/StationerryWeb/StationerryWebApp/templates/stationerry/testbench.html')
    return HttpResponse(lineString)
    def __init__(self, f):
        super().__init__(f)

        f = parse(f)

        self.type = f.get("type")
        self.damage = int(f.get("damage"))
    def __init__(self, f):
        super().__init__(f)

        f = parse(f)

        self.attacks = {}
        for i in f.get("attacks").split("\n"):
            att = attack(i)
            self.attacks[att.getName()] = att
    def __init__(self, f):
        super().__init__(f)

        f = parse(f)

        self.protection = {}
        for i in f.get("protection").split("\n"):
            i = i.split(" ")
            self.protection[i[0]] = int(i[1])

        self.type = f.get("type")
    def __init__(self, f):
        f = parse(f)
        self.name = f.get("name")
        self.desc = f.get("desc")
        self.health = int(f.get("health"))

        self.weapon = weapon(f.get("weapon"))
        self.armor = armorSet()

        for i in ["helm", "chest", "legs", "boots"]:
            if f.get(i, -1) != -1:
                armor.set(armorPiece(f.get(i)))

        #How can drops be given to the player? It's a wierd thing for attack to handle
        #maps a tuple of the range to an item, eg (0,15):sword.
        #usage: get a random number from 0 to 100, if 0 <= x <= 15 drop = sword
        self.drops = {}
        for i in f.get("drops").split("\n"):
            i = i.split(" ")
            dropRange = i[1].split("-")
            self.drops[(dropRange[0], dropRange[1])] = createItem(i[0])
def createItem(f):
    a = {"item": item, "armorPiece": armorPiece, "weapon": weapon}
    b = parse(f)
    return a[b.get("class")](f)
 def __init__(self, f):
     f = parse(f)
     protection = f.get("protection")
     self.name = f.get("name")
     self.value = f.get("value")
Beispiel #8
0
import collections
import matplotlib.pyplot as plt
import data_visualizer as dv
import utilities as ut

features, labels = ut.parse(data_limit=-1)
test_features = ut.parse(path_feature='test_data.csv',
                         path_labels='',
                         data_limit=-1)
#print 'featur number ' +str(len(test_features))

X_test, Y_test, X_train, Y_train = ut.divide_set(features, labels)
#print len(X_test), len(Y_test), len(Y_train)

#print "features \n", features[1:10]
#print "labels \n", labels[1:10]
"""showing the distribution of classes"""
"""counter = collections.Counter(labels)
print(counter.values())
print(counter.keys())
print(counter.most_common(3))

width = 1 / 1.5
plt.bar(counter.keys(), counter.values(), width, color="blue")
plt.show()""" ""
"""classification"""

#Y_pred = ut.do_nn(X_test, Y_test, X_train, Y_train)
#print ut.check(Y_test, Y_pred)
#dv.confusionMatrix(Y_test, Y_pred)
"""logloss classification"""
import utilities as lk
from sklearn import neighbors, datasets
#from sklearn.neighbors import NearestNeighbors
import numpy as np
import data_visualizer as dv
from sklearn.metrics import accuracy_score

n_neighbors = 31
h = .02

X, Y = lk.parse()
X_test, Y_test, X_train, Y_train = lk.divide_set(X, Y)

dv.visualizeLabels(Y)

clf = neighbors.KNeighborsClassifier(n_neighbors)
print 'fitting nearest neighbors'
clf.fit(X_train, Y_train)

print 'predicting'
Y_pred = clf.predict(X_test)

print(accuracy_score(Y_test, Y_pred))
dv.confusionMatrix(Y_test, Y_pred, True)