-4

I'm using the following code and I get an indentation Error, how can I fix this?

from sklearn.linear_model import LogisticRegression

def classification_model(model, data, predictors, outcome):

outcome_var = 'LoanAmount'

model = DecisionTreeClassifier()

predictor_var = ['Credit_History','Gender','Married','Education']

classification_model(model, df,predictor_var,outcome_var)

*File "", line 3 outcome_var = 'LoanAmount'

        ^ IndentationError: expected an indented block*
desertnaut
  • 57,590
  • 26
  • 140
  • 166

1 Answers1

0

In python the scope is defined using indentation

you have a function defined with def classification_model(model, data, predictors, outcome): so this function needs some statements. The outcome_var='LoanAmount' statement needs to be indented to include it in the function, and all other statements that belong to this function must follow the same indentation

For example:

def function_with_no_statements():
    pass

print("Here")

def print_something(something):
    print(something)

print("Here 2")

print_something("Here 3")

If you run the above example you will see that the print("Here") statment is not in any function, also print("Here 2"), if you call the print_something function it will print whatever you sent it (in other words execute the indented statement

  • 1
    There is nothing needing indenting, `outcome_var` is one of the variables passed in as a parameter. – Sayse Oct 11 '18 at 13:06