{
  "nbformat_minor": 0,
  "cells": [
    {
      "source": [
        "%matplotlib inline"
      ],
      "execution_count": null,
      "cell_type": "code",
      "outputs": [],
      "metadata": {
        "collapsed": false
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "\n# Parallel Example\n\n\nAn example plot of :class:`feature_selection.HarmonicSearch\n\n"
      ],
      "metadata": {}
    },
    {
      "source": [
        "from feature_selection import BRKGA\nfrom sklearn.datasets import load_breast_cancer\nfrom sklearn.svm import SVC\n\n# It is very necessary to include if __name__ == \"__main__\"\nif __name__ == \"__main__\":\n    dataset = load_breast_cancer()\n    X, y = dataset['data'], dataset['target_names'].take(dataset['target'])\n    \n    # Classifier to be used in the metaheuristic\n    clf = SVC()\n    \n    print(\"Starting Algorithm\")\n    ga =BRKGA(classifier=clf, make_logbook=True, repeat=2, parallel=True,\n                          verbose=True, size_pop=100)\n    \n    # Fit the classifier\n    ga.fit(X, y, normalize=True)\n    \n    print(\"Number of Features Selected: \\n \\t HS: \" , sum(ga.best_mask_)/X.shape[1], \"%\")\n    print(\"Accuracy of the classifier: \\n \\t HS: \", ga.fitness_[0])\n    \n    # Plot the results of each test\n    ga.plot_results()\n\n    print(\"Starting Algorithm\")\n    ga =BRKGA(classifier=clf, make_logbook=True, repeat=2, parallel=False,\n                          verbose=True, size_pop=100)\n    \n    # Fit the classifier\n    ga.fit(X, y, normalize=True)\n    \n    print(\"Number of Features Selected: \\n \\t HS: \" , sum(ga.best_mask_)/X.shape[1], \"%\")\n    print(\"Accuracy of the classifier: \\n \\t HS: \", ga.fitness_[0])\n    \n    # Plot the results of each test\n    ga.plot_results()"
      ],
      "execution_count": null,
      "cell_type": "code",
      "outputs": [],
      "metadata": {
        "collapsed": false
      }
    }
  ],
  "metadata": {
    "language_info": {
      "name": "python",
      "file_extension": ".py",
      "pygments_lexer": "ipython3",
      "nbconvert_exporter": "python",
      "version": "3.5.2",
      "mimetype": "text/x-python",
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      }
    },
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    }
  },
  "nbformat": 4
}