def test_generate_import_code():
 tpot_obj = TPOTClassifier()
 pipeline = creator.Individual.from_string('DecisionTreeClassifier(SelectKBest(input_matrix, 7), 0.5)', tpot_obj._pset)
 expected_code = "import numpy as np\n\nfrom sklearn.ensemble import VotingClassifier\nfrom sklearn.feature_selection import SelectKBest, f_classif\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.pipeline import make_pipeline, make_union\nfrom sklearn.preprocessing import FunctionTransformer\nfrom sklearn.tree import DecisionTreeClassifier\n\n# NOTE: Make sure that the class is labeled 'class' in the data file\ntpot_data = np.recfromcsv('PATH/TO/DATA/FILE', delimiter='COLUMN_SEPARATOR', dtype=np.float64)\nfeatures = np.delete(tpot_data.view(np.float64).reshape(tpot_data.size, -1), tpot_data.dtype.names.index('class'), axis=1)\ntraining_features, testing_features, training_classes, testing_classes = \\\n    train_test_split(features, tpot_data['class'], random_state=42)\n"
 assert (expected_code == generate_import_code(pipeline))

def test_generate_import_code ( ) : tpot_obj = TPOTClassifier ( ) pipeline = creator . Individual . from_string ( 'DecisionTreeClassifier(SelectKBest(input_matrix, 7), 0.5)' , tpot_obj . _pset ) expected_code = "import numpy as np\n\nfrom sklearn.ensemble import VotingClassifier\nfrom sklearn.feature_selection import SelectKBest, f_classif\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.pipeline import make_pipeline, make_union\nfrom sklearn.preprocessing import FunctionTransformer\nfrom sklearn.tree import DecisionTreeClassifier\n\n# NOTE: Make sure that the class is labeled 'class' in the data file\ntpot_data = np.recfromcsv('PATH/TO/DATA/FILE', delimiter='COLUMN_SEPARATOR', dtype=np.float64)\nfeatures = np.delete(tpot_data.view(np.float64).reshape(tpot_data.size, -1), tpot_data.dtype.names.index('class'), axis=1)\ntraining_features, testing_features, training_classes, testing_classes = \\\n    train_test_split(features, tpot_data['class'], random_state=42)\n" assert ( expected_code == generate_import_code ( pipeline ) )
assert that generate_import_code() returns the correct set of dependancies for a given pipeline .