{
  "id": 5076,
  "title": "getting the feature importance from the pipeline - newbie",
  "url": "/competitions/cause-effect-pairs/discussion/5076",
  "author_name": "",
  "post_date": "2013-07-12T05:37:18.600Z",
  "votes": null,
  "comment_count": 2,
  "views": 1334,
  "content": "<p>I never used Python before this competition.</p>\r\n<p></p>\r\n<p>I started with the Basic Python Benchmark code and added the following to the second pipeline step(classify):</p>\r\n<p><span class=\"x_Apple-tab-span\"></span>compute_importances=True,</p>\r\n<p>How to I access the results?</p>\r\n<p>After&nbsp;<span class=\"x_Apple-tab-span\"> </span>classifier.fit(train, target.Target), I tried:</p>\r\n<p>importances = classifier.get_params(classify__feature_importances_)</p>\r\n<p>That gives the error:</p>\r\n<p>NameError: global name 'classify__feature_importances_' is not defined.</p>\r\n<p></p>\r\n<p>Any help would be greatly appreciated.</p>\r\n<p>Brian</p>",
  "messages": [
    {
      "id": "27048",
      "postDate": "07/12/2013 05:37:18",
      "content": "<p>I never used Python before this competition.</p>\r\n<p></p>\r\n<p>I started with the Basic Python Benchmark code and added the following to the second pipeline step(classify):</p>\r\n<p><span class=\"x_Apple-tab-span\"></span>compute_importances=True,</p>\r\n<p>How to I access the results?</p>\r\n<p>After&nbsp;<span class=\"x_Apple-tab-span\"> </span>classifier.fit(train, target.Target), I tried:</p>\r\n<p>importances = classifier.get_params(classify__feature_importances_)</p>\r\n<p>That gives the error:</p>\r\n<p>NameError: global name 'classify__feature_importances_' is not defined.</p>\r\n<p></p>\r\n<p>Any help would be greatly appreciated.</p>\r\n<p>Brian</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "27050",
      "postDate": "07/12/2013 07:05:34",
      "content": "<p>Brian,</p>\r\n<p>I perform the following code to get the importances.</p>\r\n<p>[code]classifier = load_model()</p>\r\n<p># [-1] is the index of last step in pipeline</p>\r\n<p>labeldummy, randomfrst = classifier.steps[-1]&nbsp;</p>\r\n<p>myimportances = randomfrst.feature_importances_[/code]</p>\r\n<p></p>\r\n<p>Good luck</p>\r\n<p></p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "27057",
      "postDate": "07/12/2013 12:44:48",
      "content": "<p>ty!</p>",
      "rawMarkdown": "",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 27050,
      "author_name": "bram278806",
      "author_url": "",
      "post_date": "07/12/2013 07:05:34",
      "content": "<p>Brian,</p>\r\n<p>I perform the following code to get the importances.</p>\r\n<p>[code]classifier = load_model()</p>\r\n<p># [-1] is the index of last step in pipeline</p>\r\n<p>labeldummy, randomfrst = classifier.steps[-1]&nbsp;</p>\r\n<p>myimportances = randomfrst.feature_importances_[/code]</p>\r\n<p></p>\r\n<p>Good luck</p>\r\n<p></p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 27057,
      "author_name": "briantrewlee",
      "author_url": "",
      "post_date": "07/12/2013 12:44:48",
      "content": "<p>ty!</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "27048": "",
    "27050": "",
    "27057": ""
  },
  "source": "meta"
}