0 votes
1 view
in Data Science by (4.7k points)

I tried to fix the error but I could not and I don't know where I'm going wrong can anyone please help. below is my code

my previous error was indentation error

import pandas as pd 

import numpy as np

import xgboost as xgb

import sklearn as s 

import matplotlib 

import tensorflow as tf 

from sklearn.linear_model import LogisticRegression

from sklearn.svm import SVC

from IPython.display import display 

df = pd.read_csv("C:/Users/patel/Desktop/tap.csv")

from IPython.display import display

X_all = df.drop(['FTR'],1)

y_all = df['FTR']

# Standardising the data.

from sklearn.preprocessing import scale

#Center to the mean and component wise scale to unit variance.

cols = [['FTHG','FTAG','HTHG','HTAG']]

for col in cols:

    X_all[col] = scale(X_all[col])

X_all.HM1 = X_all.HM1.astype('str')

X_all.HM2 = X_all.HM2.astype('str')

X_all.HM3 = X_all.HM3.astype('str')

X_all.AM1 = X_all.AM1.astype('str')

X_all.AM2 = X_all.AM2.astype('str')

X_all.AM3 = X_all.AM3.astype('str')

def preprocess_features(X):

    output = pd.DataFrame(index = X.index)

    for col, col_df in X.iteritems():

             if col_df.dtype == object:

                col_df = pd.get_dummies(col_df, prefix = col)

    output = output.join(col_df)

    return output

X_all = preprocess_features(X_all)

print "Processed feature columns ({} total features):\n{}".format(len(X_all.columns), list(X_all.columns))

print "\nFeature values:"

display (X_all)

1 Answer

0 votes
by (9.8k points)
edited ago by

If you are using Python 3 then, Inside the print function parentheses are missing. Kindly following code which will work.

print("Processed feature columns ({} total features):\n{}".format(len(X_all.columns), list(X_all.columns)))

Improve your knowledge in data science from scratch using Data science online courses 

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...