salut les amis j'ai du mal a faire marcher ce code
merci d'avanceCode:
1
2
3
4
5
6
7
8 res =[] pes =[] for ele in tableau: res.append(ele) while j < len(res): pes = ''.join(format(ord(i), 'b') for i in res[j]) j=j+1
Version imprimable
salut les amis j'ai du mal a faire marcher ce code
merci d'avanceCode:
1
2
3
4
5
6
7
8 res =[] pes =[] for ele in tableau: res.append(ele) while j < len(res): pes = ''.join(format(ord(i), 'b') for i in res[j]) j=j+1
Un code qui ne marche pas, c'est juste poubelle (surtout lorsqu'il est illisible) et on repart au charbon en lançant l'interpréteur Python pour "tester" comment convertir un string en binaire:
Code:
1
2
3
4 >>> s = 'hi there' >>> ' '.join('{0:08b}'.format(ord(x), 'b') for x in s) '01101000 01101001 00100000 01110100 01101000 01100101 01110010 01100101' >>>
- W
bonjour les amis j'ai un jeu de donnée et j'aimerais avec un perceptron predire un mots voici le code
X est un dataframe compose d'un id et de string dont la cle est testCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14 for i in X.index : res.append(str(X["test"][i])) for ele in res : tes = ' '.join('{0:08b}'.format(ord(x), 'b') for x in ele) y_test = 'test' y_testconvert = [' '.join('{0:08b}'.format(ord(x), 'b') for x in y_test)] print(y_testconvert) y = (X["test"] == y_testconvert) par_clf = Perceptron() par_clf.fit(X,y) y_pred = par_clf.predict(bytes(X["test"], 'utf-8'))
merci d'avance