{"action":"created","comment":{"url":"https://api.github.com/repos/rhiever/tpot/pulls/comments/47559812","id":47559812,"diff_hunk":"@@ -724,41 +724,17 @@ def decision_tree(input_df, max_features, max_depth):\n         if max_depth < 1:\n             max_depth = None\n \n-        # If there are no features left (i.e., only 'class', 'group', and 'guess' remain in the DF), then there is nothing to do\n-        if len(input_df.columns) == 3:\n-            return input_df\n-        \n-        input_df = input_df.copy()\n-\n-        training_features = input_df.loc[input_df['group'] == 'training'].drop(['class', 'group', 'guess'], axis=1).values\n-        training_classes = input_df.loc[input_df['group'] == 'training', 'class'].values\n-\n-        dtc = DecisionTreeClassifier(max_features=max_features,\n-                                     max_depth=max_depth,\n-                                     random_state=42)\n-\n-        dtc.fit(training_features, training_classes)\n-\n-        all_features = input_df.drop(['class', 'group', 'guess'], axis=1).values\n-        input_df.loc[:, 'guess'] = dtc.predict(all_features)\n-\n-        # Also store the guesses as a synthetic feature\n-        sf_hash = '-'.join(sorted(input_df.columns.values))\n-        sf_hash += 'DT-{}-{}'.format(max_features, max_depth)\n-        sf_identifier = 'SyntheticFeature-{}'.format(hashlib.sha224(sf_hash.encode('UTF-8')).hexdigest())\n-        input_df.loc[:, sf_identifier] = input_df['guess'].values\n-\n-        return input_df\n+        return TPOT._train_model_and_predict(input_df, DecisionTreeClassifier, max_features=max_features, max_depth=max_depth, random_state=42)\n \n     @staticmethod\n-    def random_forest(input_df, num_trees, max_features):\n+    def random_forest(input_df, n_estimators, max_features):\n         \"\"\"Fits a random forest classifier\n \n         Parameters\n         ----------\n         input_df: pandas.DataFrame {n_samples, n_features+['class', 'group', 'guess']}\n             Input DataFrame for fitting the random forest\n-        num_trees: int\n+        n_estimators: int","path":"tpot/tpot.py","position":41,"original_position":41,"commit_id":"42574b125521562e8410858114f17c7056356c7d","original_commit_id":"42574b125521562e8410858114f17c7056356c7d","user":{"login":"rhiever","id":1719223,"avatar_url":"https://avatars.githubusercontent.com/u/1719223?v=3","gravatar_id":"","url":"https://api.github.com/users/rhiever","html_url":"https://github.com/rhiever","followers_url":"https://api.github.com/users/rhiever/followers","following_url":"https://api.github.com/users/rhiever/following{/other_user}","gists_url":"https://api.github.com/users/rhiever/gists{/gist_id}","starred_url":"https://api.github.com/users/rhiever/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rhiever/subscriptions","organizations_url":"https://api.github.com/users/rhiever/orgs","repos_url":"https://api.github.com/users/rhiever/repos","events_url":"https://api.github.com/users/rhiever/events{/privacy}","received_events_url":"https://api.github.com/users/rhiever/received_events","type":"User","site_admin":false},"body":"Fine with me. :+1: ","created_at":"2015-12-14T21:23:33Z","updated_at":"2015-12-14T21:23:33Z","html_url":"https://github.com/rhiever/tpot/pull/57#discussion_r47559812","pull_request_url":"https://api.github.com/repos/rhiever/tpot/pulls/57","_links":{"self":{"href":"https://api.github.com/repos/rhiever/tpot/pulls/comments/47559812"},"html":{"href":"https://github.com/rhiever/tpot/pull/57#discussion_r47559812"},"pull_request":{"href":"https://api.github.com/repos/rhiever/tpot/pulls/57"}}},"pull_request":{"url":"https://api.github.com/repos/rhiever/tpot/pulls/57","id":53515410,"html_url":"https://github.com/rhiever/tpot/pull/57","diff_url":"https://github.com/rhiever/tpot/pull/57.diff","patch_url":"https://github.com/rhiever/tpot/pull/57.patch","issue_url":"https://api.github.com/repos/rhiever/tpot/issues/57","number":57,"state":"open","locked":false,"title":"Abstract function for the classifier pipeline operators","user":{"login":"bartleyn","id":3230070,"avatar_url":"https://avatars.githubusercontent.com/u/3230070?v=3","gravatar_id":"","url":"https://api.github.com/users/bartleyn","html_url":"https://github.com/bartleyn","followers_url":"https://api.github.com/users/bartleyn/followers","following_url":"https://api.github.com/users/bartleyn/following{/other_user}","gists_url":"https://api.github.com/users/bartleyn/gists{/gist_id}","starred_url":"https://api.github.com/users/bartleyn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bartleyn/subscriptions","organizations_url":"https://api.github.com/users/bartleyn/orgs","repos_url":"https://api.github.com/users/bartleyn/repos","events_url":"https://api.github.com/users/bartleyn/events{/privacy}","received_events_url":"https://api.github.com/users/bartleyn/received_events","type":"User","site_admin":false},"body":"Per #43 , this abstracts the shared code between static models into a static method that each model can call. In addition, I built a test for testing all the static models / this new abstract method indirectly, and tweaked the num_trees parameter in random_forest to n_estimators to facilitate testing. \r\n\r\nPotential improvements:\r\n1) Maybe it's just me, but It feels a little odd to call a static function from another static function. Does it make sense to move this method (and perhaps some others) to a utility function module? Either way, is it faster to call this abstract method as a static method inside the class, a class method inside the class, or something else?\r\n2) Is there a more appropriate name for the method?\r\n3) Is there a better place to do the input validation (i.e. if there are only three columns in the input_df)  than within this nested function call? ","created_at":"2015-12-14T00:50:35Z","updated_at":"2015-12-14T21:23:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"31b5d1d5e41e6f5e1a3000b924c6c3e42f278316","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rhiever/tpot/pulls/57/commits","review_comments_url":"https://api.github.com/repos/rhiever/tpot/pulls/57/comments","review_comment_url":"https://api.github.com/repos/rhiever/tpot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rhiever/tpot/issues/57/comments","statuses_url":"https://api.github.com/repos/rhiever/tpot/statuses/42574b125521562e8410858114f17c7056356c7d","head":{"label":"bartleyn:master","ref":"master","sha":"42574b125521562e8410858114f17c7056356c7d","user":{"login":"bartleyn","id":3230070,"avatar_url":"https://avatars.githubusercontent.com/u/3230070?v=3","gravatar_id":"","url":"https://api.github.com/users/bartleyn","html_url":"https://github.com/bartleyn","followers_url":"https://api.github.com/users/bartleyn/followers","following_url":"https://api.github.com/users/bartleyn/following{/other_user}","gists_url":"https://api.github.com/users/bartleyn/gists{/gist_id}","starred_url":"https://api.github.com/users/bartleyn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bartleyn/subscriptions","organizations_url":"https://api.github.com/users/bartleyn/orgs","repos_url":"https://api.github.com/users/bartleyn/repos","events_url":"https://api.github.com/users/bartleyn/events{/privacy}","received_events_url":"https://api.github.com/users/bartleyn/received_events","type":"User","site_admin":false},"repo":{"id":46537463,"name":"tpot","full_name":"bartleyn/tpot","owner":{"login":"bartleyn","id":3230070,"avatar_url":"https://avatars.githubusercontent.com/u/3230070?v=3","gravatar_id":"","url":"https://api.github.com/users/bartleyn","html_url":"https://github.com/bartleyn","followers_url":"https://api.github.com/users/bartleyn/followers","following_url":"https://api.github.com/users/bartleyn/following{/other_user}","gists_url":"https://api.github.com/users/bartleyn/gists{/gist_id}","starred_url":"https://api.github.com/users/bartleyn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bartleyn/subscriptions","organizations_url":"https://api.github.com/users/bartleyn/orgs","repos_url":"https://api.github.com/users/bartleyn/repos","events_url":"https://api.github.com/users/bartleyn/events{/privacy}","received_events_url":"https://api.github.com/users/bartleyn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bartleyn/tpot","description":"A Python tool that automatically creates and optimizes Machine Learning pipelines using genetic programming.","fork":true,"url":"https://api.github.com/repos/bartleyn/tpot","forks_url":"https://api.github.com/repos/bartleyn/tpot/forks","keys_url":"https://api.github.com/repos/bartleyn/tpot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bartleyn/tpot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bartleyn/tpot/teams","hooks_url":"https://api.github.com/repos/bartleyn/tpot/hooks","issue_events_url":"https://api.github.com/repos/bartleyn/tpot/issues/events{/number}","events_url":"https://api.github.com/repos/bartleyn/tpot/events","assignees_url":"https://api.github.com/repos/bartleyn/tpot/assignees{/user}","branches_url":"https://api.github.com/repos/bartleyn/tpot/branches{/branch}","tags_url":"https://api.github.com/repos/bartleyn/tpot/tags","blobs_url":"https://api.github.com/repos/bartleyn/tpot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bartleyn/tpot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bartleyn/tpot/git/refs{/sha}","trees_url":"https://api.github.com/repos/bartleyn/tpot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bartleyn/tpot/statuses/{sha}","languages_url":"https://api.github.com/repos/bartleyn/tpot/languages","stargazers_url":"https://api.github.com/repos/bartleyn/tpot/stargazers","contributors_url":"https://api.github.com/repos/bartleyn/tpot/contributors","subscribers_url":"https://api.github.com/repos/bartleyn/tpot/subscribers","subscription_url":"https://api.github.com/repos/bartleyn/tpot/subscription","commits_url":"https://api.github.com/repos/bartleyn/tpot/commits{/sha}","git_commits_url":"https://api.github.com/repos/bartleyn/tpot/git/commits{/sha}","comments_url":"https://api.github.com/repos/bartleyn/tpot/comments{/number}","issue_comment_url":"https://api.github.com/repos/bartleyn/tpot/issues/comments{/number}","contents_url":"https://api.github.com/repos/bartleyn/tpot/contents/{+path}","compare_url":"https://api.github.com/repos/bartleyn/tpot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bartleyn/tpot/merges","archive_url":"https://api.github.com/repos/bartleyn/tpot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bartleyn/tpot/downloads","issues_url":"https://api.github.com/repos/bartleyn/tpot/issues{/number}","pulls_url":"https://api.github.com/repos/bartleyn/tpot/pulls{/number}","milestones_url":"https://api.github.com/repos/bartleyn/tpot/milestones{/number}","notifications_url":"https://api.github.com/repos/bartleyn/tpot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bartleyn/tpot/labels{/name}","releases_url":"https://api.github.com/repos/bartleyn/tpot/releases{/id}","created_at":"2015-11-20T03:42:29Z","updated_at":"2015-11-20T03:42:30Z","pushed_at":"2015-12-14T00:42:55Z","git_url":"git://github.com/bartleyn/tpot.git","ssh_url":"git@github.com:bartleyn/tpot.git","clone_url":"https://github.com/bartleyn/tpot.git","svn_url":"https://github.com/bartleyn/tpot","homepage":"http://www.randalolson.com/2015/11/15/introducing-tpot-the-data-science-assistant/","size":597,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rhiever:master","ref":"master","sha":"81b3f762eb6a1a026bf7270be33b60ddd934f631","user":{"login":"rhiever","id":1719223,"avatar_url":"https://avatars.githubusercontent.com/u/1719223?v=3","gravatar_id":"","url":"https://api.github.com/users/rhiever","html_url":"https://github.com/rhiever","followers_url":"https://api.github.com/users/rhiever/followers","following_url":"https://api.github.com/users/rhiever/following{/other_user}","gists_url":"https://api.github.com/users/rhiever/gists{/gist_id}","starred_url":"https://api.github.com/users/rhiever/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rhiever/subscriptions","organizations_url":"https://api.github.com/users/rhiever/orgs","repos_url":"https://api.github.com/users/rhiever/repos","events_url":"https://api.github.com/users/rhiever/events{/privacy}","received_events_url":"https://api.github.com/users/rhiever/received_events","type":"User","site_admin":false},"repo":{"id":45495679,"name":"tpot","full_name":"rhiever/tpot","owner":{"login":"rhiever","id":1719223,"avatar_url":"https://avatars.githubusercontent.com/u/1719223?v=3","gravatar_id":"","url":"https://api.github.com/users/rhiever","html_url":"https://github.com/rhiever","followers_url":"https://api.github.com/users/rhiever/followers","following_url":"https://api.github.com/users/rhiever/following{/other_user}","gists_url":"https://api.github.com/users/rhiever/gists{/gist_id}","starred_url":"https://api.github.com/users/rhiever/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rhiever/subscriptions","organizations_url":"https://api.github.com/users/rhiever/orgs","repos_url":"https://api.github.com/users/rhiever/repos","events_url":"https://api.github.com/users/rhiever/events{/privacy}","received_events_url":"https://api.github.com/users/rhiever/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rhiever/tpot","description":"A Python tool that automatically creates and optimizes Machine Learning pipelines using genetic programming.","fork":false,"url":"https://api.github.com/repos/rhiever/tpot","forks_url":"https://api.github.com/repos/rhiever/tpot/forks","keys_url":"https://api.github.com/repos/rhiever/tpot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rhiever/tpot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rhiever/tpot/teams","hooks_url":"https://api.github.com/repos/rhiever/tpot/hooks","issue_events_url":"https://api.github.com/repos/rhiever/tpot/issues/events{/number}","events_url":"https://api.github.com/repos/rhiever/tpot/events","assignees_url":"https://api.github.com/repos/rhiever/tpot/assignees{/user}","branches_url":"https://api.github.com/repos/rhiever/tpot/branches{/branch}","tags_url":"https://api.github.com/repos/rhiever/tpot/tags","blobs_url":"https://api.github.com/repos/rhiever/tpot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rhiever/tpot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rhiever/tpot/git/refs{/sha}","trees_url":"https://api.github.com/repos/rhiever/tpot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rhiever/tpot/statuses/{sha}","languages_url":"https://api.github.com/repos/rhiever/tpot/languages","stargazers_url":"https://api.github.com/repos/rhiever/tpot/stargazers","contributors_url":"https://api.github.com/repos/rhiever/tpot/contributors","subscribers_url":"https://api.github.com/repos/rhiever/tpot/subscribers","subscription_url":"https://api.github.com/repos/rhiever/tpot/subscription","commits_url":"https://api.github.com/repos/rhiever/tpot/commits{/sha}","git_commits_url":"https://api.github.com/repos/rhiever/tpot/git/commits{/sha}","comments_url":"https://api.github.com/repos/rhiever/tpot/comments{/number}","issue_comment_url":"https://api.github.com/repos/rhiever/tpot/issues/comments{/number}","contents_url":"https://api.github.com/repos/rhiever/tpot/contents/{+path}","compare_url":"https://api.github.com/repos/rhiever/tpot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rhiever/tpot/merges","archive_url":"https://api.github.com/repos/rhiever/tpot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rhiever/tpot/downloads","issues_url":"https://api.github.com/repos/rhiever/tpot/issues{/number}","pulls_url":"https://api.github.com/repos/rhiever/tpot/pulls{/number}","milestones_url":"https://api.github.com/repos/rhiever/tpot/milestones{/number}","notifications_url":"https://api.github.com/repos/rhiever/tpot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rhiever/tpot/labels{/name}","releases_url":"https://api.github.com/repos/rhiever/tpot/releases{/id}","created_at":"2015-11-03T21:08:40Z","updated_at":"2015-12-14T03:04:46Z","pushed_at":"2015-12-14T00:50:37Z","git_url":"git://github.com/rhiever/tpot.git","ssh_url":"git@github.com:rhiever/tpot.git","clone_url":"https://github.com/rhiever/tpot.git","svn_url":"https://github.com/rhiever/tpot","homepage":"http://www.randalolson.com/2015/11/15/introducing-tpot-the-data-science-assistant/","size":956,"stargazers_count":431,"watchers_count":431,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":38,"mirror_url":null,"open_issues_count":14,"forks":38,"open_issues":14,"watchers":431,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rhiever/tpot/pulls/57"},"html":{"href":"https://github.com/rhiever/tpot/pull/57"},"issue":{"href":"https://api.github.com/repos/rhiever/tpot/issues/57"},"comments":{"href":"https://api.github.com/repos/rhiever/tpot/issues/57/comments"},"review_comments":{"href":"https://api.github.com/repos/rhiever/tpot/pulls/57/comments"},"review_comment":{"href":"https://api.github.com/repos/rhiever/tpot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rhiever/tpot/pulls/57/commits"},"statuses":{"href":"https://api.github.com/repos/rhiever/tpot/statuses/42574b125521562e8410858114f17c7056356c7d"}}}}