1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] How can I print the ndarray compelete information?

Discussão em 'Python' iniciado por Stack, Setembro 13, 2024.

  1. Stack

    Stack Membro Participativo

    I have been trying to match the output but I'm not getting the column names I got from df which I put into the statmodels.

    import pandas
    import statsmodels.api as statmodel
    df = pandas.read_csv('fastfood.csv')

    df = df[['total_fat', 'sat_fat', 'cholesterol', 'sodium','calories']]
    X = df[['total_fat', 'sat_fat', 'cholesterol', 'sodium']].values
    Y = df[['calories']].values
    X = statmodel.add_constant(X)
    model = statmodel.OLS(Y, X).fit()

    print(model.mse_total.round(2))
    print(model.rsquared.round(2))
    print(model.params.round(2))
    print(model.pvalues.round(2))


    Output I got:

    79770.18
    0.9
    [71.73 9.1 0.6 0.21 0.16]
    [0. 0. 0.64 0.07 0. ]


    Output I need:

    79770.18
    0.9
    -{0,}71.73
    total_fat 9.10
    sat_fat . ..0.60
    cholesterol 0.21
    sodium... ...0.16
    dtype: float64
    {0,}0.00
    total_fat 0.00
    sat_fat. ..0.64
    cholesterol...0.07
    sodium .. ..0.00
    dtype: float64

    Continue reading...

Compartilhe esta Página