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


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

Re: Difficulté pour développer une fonction

From Felix <slad@keemail.me>
Newsgroups fr.comp.lang.python
Subject Re: Difficulté pour développer une fonction
Date 2020-03-11 22:35 +0100
Organization A noiseless patient Spider
Message-ID <r4bljs$oi1$1@dont-email.me> (permalink)
References <GO2dnfS3rO3qy8LDnZ2dnUU798zNnZ2d@giganews.com>

Show all headers | View raw


Bonjour,

Il serait intéressant d'avoir une visibilité sur le contenu des 
dataframes. On se doute du début manquant de ton code, mais ce serait 
plus confortable si tu pouvais le corriger :)

Merci, en espérant pouvoir t'aider davantage.

Le 04/03/2020 à 08:19, heevy a écrit :
> 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 | NextPrevious 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