Entering edit mode

5 months ago

probioquestioner
•
0

Hello.

I am using Practical Statistics for Data Scientists (50+Essential Concepts Using R and Python). I am studying about RandomForest.

```
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import warnings
warnings.filterwarnings('ignore')
from sklearn.datasets import load_iris, load_boston
from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor
predictors = ['borrower_score', 'payment_inc_ratio']
outcome = 'outcome'
loan3000 = '/practical-statistics-for-data-scientists-master/data/loan3000.csv'
X = loan3000[predictors]
y = loan3000[outcome]
rf = RandomForestClassifier(n_estimators=500, random_state=1, oob_score=True)
rf.fit(X, y)
```

In `X = loan3000[predictors]`

part, `TypeError: string indices must be integers`

error appears.

How can I solve it?

Thanks for reading.