Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > fr.comp.lang.python > #3286

Difficulté pour développer une fonction

Newsgroups fr.comp.lang.python
Subject Difficulté pour développer une fonction
From heevy <nospam_petitlore@yahoo.fr.invalid>
Organization !No_Organization!
Message-ID <GO2dnfS3rO3qy8LDnZ2dnUU798zNnZ2d@giganews.com> (permalink)
Date 2020-03-04 01:19 -0600

Show all headers | View raw


Bonjour,

Je dois développer une fonction permettant de trier un type d'objet pour savoir
s'ils sont vrai ou faux. Ma fonction doit pouvoir lire un fichier et déterminer
si les objets sont vrai ou faux.

Voici mon code, pourriez vous m'aider?

illet=pd.read_csv("notes.csv")
b2 =pd.read_csv("example.csv")


feature_names = ["diagonal", "height_left","height_right",
"margin_low","margin_up", "length" ]
    
X1 = billet[feature_names]
y1 = billet["is_genuine"]
    
model = sm.OLS(y1, X1)
results = model.fit()

X2 = b2[feature_names]

b2['résultats'] = results.predict(X2).values
b2['statut'] = np.where(b2['résultats']>=0.5, 'vrai', 'faux')

b2.drop(columns=["diagonal","height_left","height_right","margin_low","margin_up","length"],axis=1,inplace=True)


#nourrir le modèle
logreg = LogisticRegression()
logreg.fit(X1,y1)

import random
from random import*
y=choices(y1, k=5)

#prévision
y_pred = logreg.predict(X2)



#graphique répartition vrai/faux billet
b2["statut"].value_counts(normalize=True).plot(kind='pie', autopct =lambda x:
str(round(x, 2)) + '%' )


#fonction

def lire(nom):  
    
    return pd.read_csv(nom)
lire ("example.csv")

feature_names = ["diagonal", "height_left","height_right",
"margin_low","margin_up", "length" ]
    
X1 = billet[feature_names]
y1 = billet["is_genuine"]
    
model = sm.OLS(y1, X1)
results = model.fit()

X2 = nom[feature_names]

nom['résultats'] = results.predict(X2).values
nom['statut'] = np.where(nom['résultats']>=0.5, 'vrai', 'faux')

nom.drop(columns=["diagonal","height_left","height_right","margin_low","margin_up","length"],axis=1,inplace=True)


#nourrir le modèle
logreg = LogisticRegression()
logreg.fit(X1,y1)

import random
from random import*
y=choices(y1, k=5)

#prévision
y_pred = logreg.predict(X2)



#graphique répartition vrai/faux billet
nom["statut"].value_counts(normalize=True).plot(kind='pie', autopct =lambda x:
str(round(x, 2)) + '%' )

Back to fr.comp.lang.python | Previous | NextNext in thread | Find similar


Thread

Difficulté pour développer une fonction heevy <nospam_petitlore@yahoo.fr.invalid> - 2020-03-04 01:19 -0600
  Re: Difficulté pour développer une fonction Nicolas <nicolasp@aaton.com> - 2020-03-10 08:32 +0100
  Re: Difficulté pour développer une fonction Felix <slad@keemail.me> - 2020-03-11 22:35 +0100

csiph-web