Here is the code I am running about TPOTRegressor.
from tpot import TPOTRegressor
from sklearn.datasets import load_boston
from sklearn.model_selection import train_test_split
housing = sklearn.datasets.load_boston()
X_train, X_test, y_train, y_test = train_test_split(housing.data, housing.target,
train_size=0.75, test_size=0.25, random_state=42)
tpot = TPOTRegressor(generations=5, population_size=50, verbosity=2, random_state=42)
tpot.fit(X_train, y_train)
print(tpot.score(X_test, y_test))
Now I am getting this error:
NameError Traceback (most recent call last)
<ipython-input-16-a52aaaaedc24> in <module>
8
9 tpot = TPOTRegressor(generations=5, population_size=50, verbosity=2, random_state=42)
---> 10 tpot.fit(X_train, y_train)
11 print(tpot.score(X_test, y_test))
~\anaconda3\lib\site-packages\tpot\base.py in fit(self, features, target, sample_weight, groups)
637 features, target = self._check_dataset(features, target, sample_weight)
638
--> 639 self._init_pretest(features, target)
640
641 # Randomly collect a subsample of training samples for pipeline optimization process.
~\anaconda3\lib\site-packages\tpot\tpot.py in _init_pretest(self, features, target)
65
66 """
---> 67 self.pretest_X, _, self.pretest_y, _ = train_test_split(X, y, random_state=self.random_state,
68 test_size=None, train_size=min(50,int(0.9*features.shape[0])))
NameError: name 'X' is not defined
For some reason the code returns this NameError which says X is not defined.