jeudi 27 mai 2021

Condition in array results

i'm new into python, so, my question is kind simple.

I have a linear Regression, my ypred returns to me a array like this

  yPre2_pred = regressaoPre2.predict(XPre2_test)

  ddf2 = pd.DataFrame({'Realizado': yPre2_test, 'Resultado do modelo': yPre2_pred, 'Variação': 
  yPre2_pred / yPre2_test  -1 })
  r_sq = regressaoPre2.score(xPre2, yPre2)
  r_sqmodelo = regressaoPre2.score(XPre2_test, yPre2_test)

  print(ddf2)

  Realizado  Resultado do modelo  Variação
  43     211.33           279.505979  0.322604
  49     125.84            88.377950 -0.297696
  62      55.57            44.049949 -0.207307
  51      39.68            11.281662 -0.715684
  32     473.58           408.446098 -0.137535
  34     123.92           211.493634  0.706695
  29     441.96           311.487298 -0.295214
  46     317.28           309.504595 -0.024506
  11     122.19           162.888449  0.333075
  2       37.73          -103.208499 -3.735449
  26      40.16            73.811614  0.837939
  60     240.40           184.092869 -0.234223
  4       88.98           -24.397806 -1.274194

I need to " if "resultado modelo" (yPre2_pred) below 40, then add 40 to the results.

How can i get it?

Aucun commentaire:

Enregistrer un commentaire