Esempio n. 1
0
def menuShow(screen, bg):
    sg1 = Sign(290, 260)
    sg2 = Sign(690, 260)
    pos = (0, 0)
    tr = 1
    but1 = 0
    but2 = 0
    while tr:
        screen.blit(bg, (0, 0))
        sg1.show(screen)
        sg2.show(screen)
        font = pygame.font.SysFont("comicsansms", 40)
        text = font.render("Step by step", True, (100, 100, 255))
        screen.blit(text, (290 + (300 - text.get_width()) // 2, 260 + (200 - text.get_height()) // 2))
        text = font.render("User case", True, (100, 100, 255))
        screen.blit(text, (690 + (300 - text.get_width()) // 2, 260 + (200 - text.get_height()) // 2))
        for event in pygame.event.get():
            if event.type == pygame.MOUSEMOTION:
                pos = event.pos
            elif event.type == pygame.MOUSEBUTTONDOWN:
                pos = event.pos
                if sg1.click(pos) or sg2.click(pos):
                    but1 = sg1.click(pos)
                    but2 = sg2.click(pos)
                    tr = 0
        sg1.update(pos)
        sg2.update(pos)
        pygame.display.update()
        #time.sleep(0.005)
    if but2:
        m, n = inpt(screen, bg)
        algo.main(n, m, screen)
    elif but1:
        algo.main(2, 2, screen)
Esempio n. 2
0
def UploadAction(event=None):
    filez = filedialog.askopenfilenames(parent=r,title='Choose a file')
    files_data = r.tk.splitlist(filez)
    result = main(files_data)

    import operator
    sorted_d = dict(sorted(result.items(), key=operator.itemgetter(1),reverse=True))

    top_10 = list(sorted_d.keys())[0:10]

    re_insert = dict()
    list_value = list()
    predict_values = list()
        
    for i in top_10:
        list_value.append(i)
        predict_values.append(float(sorted_d[i]))
        re_insert['Algorithms'] = list_value
        re_insert['Accuracy'] = predict_values
    print(re_insert)
    df1 = DataFrame(re_insert,columns=['Algorithms','Accuracy'])

    figure1 = plt.Figure(figsize=(30,15), dpi=100)
    ax1 = figure1.add_subplot(111)
    ax1.set_title('Best algorithms for your model')
    bar1 = FigureCanvasTkAgg(figure1, r)
    bar1.get_tk_widget().pack(side=tk.LEFT, fill=tk.BOTH)
    df1 = df1[['Algorithms','Accuracy']].groupby('Algorithms').sum()
    df1.plot(kind='bar', legend=True, ax=ax1)
Esempio n. 3
0
    def post(self):
        urlLinks = self.request.get("urllink")
        tag = self.request.get("tag")
        img = urlLinks
        displaygray = self.request.get("grayz")

        #if db.GqlQuery('SELECT * FROM CC WHERE tag = tag'):
        #    dictionary = exists[0].colorcode
        #    totalpx = exists[0].totalpx
        #    dominant = exists[0].dominant

        dictionary, totalpx, dominant, displaygray = main(img, displaygray)
        data_input = CC(tag=tag,
                        colorcode=str(dictionary),
                        dominant=str(dominant),
                        totalpx=totalpx,
                        confidence=50.0)
        data_input.put()

        q = db.GqlQuery('SELECT * FROM CC ORDER BY tag')

        queryDict = {}
        counter = 0
        for n in q:
            queryDict[counter] = ast.literal_eval(n.colorcode)
            counter += 1

        self.render("front.html",
                    dictionary=dictionary,
                    totalpx=totalpx,
                    tag=tag,
                    q=q,
                    queryDict=queryDict,
                    displaygray=displaygray)
Esempio n. 4
0
def main():
    ex = algo.main()
    # Need to go step by step, python is exploding
    for inFile, all_res in ex.items():
        with open("analytics_" + inFile + ".csv", 'w') as csvfile:
            writer = csv.DictWriter(
                csvfile,
                fieldnames=[
                    "Algorithme", "Nombre de camions utilisés",
                    "Nombre d'accès aux camions",
                    "Nombre de remplissage des camions",
                    "Moyenne de remplissage d'un camion",
                    "% de camions remplis à 1-10%",
                    "% de camions remplis à 11-20%",
                    "% de camions remplis à 21-30%",
                    "% de camions remplis à 31-40%",
                    "% de camions remplis à 41-50%",
                    "% de camions remplis à 51-60%",
                    "% de camions remplis à 61-70%",
                    "% de camions remplis à 71-80%",
                    "% de camions remplis à 81-90%",
                    "% de camions remplis à 91-100%"
                ])
            writer.writeheader()
            for res in all_res:
                row = {}
                row["Algorithme"] = res[0]
                bins = res[1]
                row["Nombre de camions utilisés"] = len(bins)
                row["Nombre d'accès aux camions"] = bins.bin_access
                row["Nombre de remplissage des camions"] = bins.bin_change
                row["Moyenne de remplissage d'un camion"] = round(
                    100 * sum(bins) / (len(bins) * bins.bin_size))
                for i in range(0, 100, 10):
                    m_min = i + 1
                    m_max = i + 10
                    row["% de camions remplis à {0}-{1}%".format(
                        m_min, m_max)] = round(
                            100 * len(
                                list(
                                    filter(
                                        lambda bin: m_min <= 100 * bin / bins.
                                        bin_size <= m_max, bins))) / len(bins),
                            2)
                writer.writerow(row)
Esempio n. 5
0
    def get(self):
        img = "images/sample3.png"
        default_tag = "COLOR OF THE DAY"
        displaygray = "false"

        dictionary, totalpx, dominant, displaygray = main(img, displaygray)

        q = db.GqlQuery('SELECT * FROM CC ORDER BY tag')
        counter = 0
        queryDict = {}
        for n in q:
            queryDict[counter] = ast.literal_eval(n.colorcode)
            counter += 1

        self.render("front.html",
                    dictionary=dictionary,
                    totalpx=totalpx,
                    q=q,
                    tag=default_tag,
                    queryDict=queryDict)
Esempio n. 6
0
                                  pagenos,
                                  maxpages=maxpages,
                                  password=password,
                                  caching=caching,
                                  check_extractable=True):
        page.rotate = (page.rotate + rotation) % 360
        interpreter.process_page(page)
    fp.close()
    device.close()
    outfp.close()
    return


if __name__ == '__main__':
    #x=int(input("Enter the number of pdf files to be converted :"))
    #for i in range(x):
    #    pdf=raw_input("\nPlease enter the name of the pdf files : \n")
    #   main(pdf,i+1)
    #   algo.main('pdf'+str(i+1))

    x = sys.argv[1:]
    for i in range(len(x)):
        main(x[i], i + 1)
        results = algo.main('pdf' + str(i + 1))

        # Results is a List of Lists
        #TODO Convert Results into a CSV for Analysis in Excel
        with open('excel' + str(i + 1) + '.csv', 'wb') as myfile:
            wr = csv.writer(myfile, quoting=csv.QUOTE_ALL)
            wr.writerows(results)
Esempio n. 7
0
limit=datetime.datetime(1, 1, 1, 0, 0, 1)
original=0
final=0
saved_distance=0
end=False
counter=0
while(end==False):
    print("processing " + str(counter+1) + "th pool")
    counter=counter+1
    end,limit,trip_details_dictionary=dataprovider.get_trip_details(limit)
    limit=limit+datetime.timedelta(0,3)
    pool1=trip_details_dictionary[1]
    pool2=trip_details_dictionary[2]
    pool3=trip_details_dictionary[3]
    pool4=trip_details_dictionary[4]
    initial,total,saved,total_distance_after_merging=algo.main(pool1,pool2,pool3,pool4,2)
    original=original+initial
    final=final+total
    saved_distance=saved_distance+saved
    print(saved_distance)
    print(original-final)

average_original=original/counter
average_final=final/counter
average_saved=saved_distance/counter
total_saved_trips=original-final
print("Total number of trips without ride sharing" + str(original))
print("Total number of trips with ride sharing" + str(final))
print("Average number of trips merged per pool" + str(int((original-final)/counter)))
print("Total number of trips saved: " + str(total_saved_trips))
print("Average number of trips saved: " + str(int(total_saved_trips/counter)))
Esempio n. 8
0
def resolution():
    idDataSet = str(request.json)
    result = main(idDataSet)
    return str(result)
Esempio n. 9
0
def debug_algo():

    algo.main()

    return jsonify({"success": True})
Esempio n. 10
0
def order_root():

    if request.method == "POST":
        # expected data [priority, time_to_completion, facility_id, equipment_id]
        data = request.get_json()

        # sanitization
        if not data:
            return jsonify({"success": False, "message": "Missing body."}), 400

        if not 'priority' in data or not 'time_to_completion' in data or not 'facility_id' in data or not 'equipment_id' in data:
            return jsonify({
                "success": False,
                "message": "Missing body fields."
            }), 400

        if not isinstance(data['priority'], int) or not isinstance(
                data['time_to_completion'], int) or not isinstance(
                    data['facility_id'], int) or not isinstance(
                        data['equipment_id'], int):
            return jsonify({
                "success": False,
                "message": "Invalid body fields."
            }), 400

        if data['priority'] < 1 or data['priority'] > 5:
            return jsonify({
                "success": False,
                "message": "Priority out of range."
            }), 400

        if data['time_to_completion'] < 1:
            return jsonify({
                "success": False,
                "message": "Time to completion out of range."
            }), 400

        if not Equipment.query.get(data['equipment_id']):
            return jsonify({
                "success": False,
                "message": "Equipment key not found."
            }), 404

        if not Facility.query.get(data['facility_id']):
            return jsonify({
                "success": False,
                "message": "Facility key not found."
            }), 404

        # add to db
        order = Order(data['priority'], data['time_to_completion'],
                      data['facility_id'], data['equipment_id'])
        db.session.add(order)
        db.session.commit()

        # after each call
        algo.main()

        return jsonify(get_dict(order))

    else:
        # get orders
        orders = Order.query.order_by(Order.created_at.desc()).all()

        return jsonify(get_dict_array(orders))
Esempio n. 11
0
def equipment_type_root():

    if request.method == "POST":
        # expected data [name, prob, hour_min, hour_max]
        data = request.get_json()

        # sanitization
        if not data:
            return jsonify({"success": False, "message": "Missing body."}), 400

        if not 'name' in data or not 'prob' in data or not 'hour_min' in data or not 'hour_max' in data:
            return jsonify({
                "success": False,
                "message": "Missing body fields."
            }), 400

        if not isinstance(data['name'], str) or not isinstance(
                data['prob'], (int, float)) or not isinstance(
                    data['hour_min'], int) or not isinstance(
                        data['hour_max'], int):
            return jsonify({
                "success": False,
                "message": "Invalid body fields."
            }), 400

        if len(data['name'].strip()) < 1 or len(data['name']) > 25:
            return jsonify({
                "success": False,
                "message": "Name length out of range."
            }), 400

        if data['prob'] < 0 or data['prob'] > 1:
            return jsonify({
                "success": False,
                "message": "Probability out of range."
            }), 400

        if data['hour_min'] < 1:
            return jsonify({
                "success": False,
                "message": "Minimum hour out of range."
            }), 400

        if data['hour_max'] < 1 or data['hour_max'] < data['hour_min']:
            return jsonify({
                "success": False,
                "message": "Maximum hour out of range."
            }), 400

        # add to db
        e_type = EquipmentType(data['name'], data['prob'], data['hour_min'],
                               data['hour_max'])
        db.session.add(e_type)
        db.session.commit()

        # main algorithm run
        algo.main()

        return jsonify(get_dict(e_type))

    else:
        # get equipments
        equipment_types = EquipmentType.query.all()

        return jsonify(get_dict_array(equipment_types))