pythonpython-3.xmachine-learninggoogle-colaboratorytpot

TPOT : Where is te the best pipeline (.py file) exported after fitting when working in COLAB


I'm running the example of MNIST dataset classification provided by TPOT documentation page. I'm doing this by using Google Colab, nonetheless I can't find the code with the best pipeline that is retrieved by tpot after training.

Can you please help me to figure out where this .py file is saved?

from tpot import TPOTClassifier
from sklearn.datasets import load_digits
from sklearn.model_selection import train_test_split

digits = load_digits()
X_train, X_test, y_train, y_test = train_test_split(digits.data, digits.target,
                                                    train_size=0.75, test_size=0.25)

tpot = TPOTClassifier(generations=5, population_size=50, verbosity=2)
tpot.fit(X_train, y_train)
print(tpot.score(X_test, y_test))
tpot.export('tpot_mnist_pipeline.py')

Solution

  • It will be in your working directory.

    I also encountered this problem while running TPOT on virtual machines. For this I committed some code which allows you to also export to string.

    Use:

    print(tpot.export())
    

    and it will print the pipeline code to screen 🙂