Deleted:[python]sklearn.ensemble.RandomForestClassifier(TypeError: string indices must be integers)
0
1
Entering edit mode
5 months ago

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.

TypeError python offtopic • 395 views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 1666 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6