{ "info": { "author": "Despoina Paschalidou , Angelos Katharopoulos ", "author_email": "paschalidoud@gmail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Scientific/Engineering" ], "description": "Local feature aggregation\n=========================\n\nThis is a library that implements methods to aggregate local features\n(mainly for multimedia) into a single global feature that can be used\neasily with any classifier.\n\nDependencies\n------------\n\nThe library depends on **scikit-learn** and all the feature aggregation\nmethods extend the scikit-learn BaseEstimator class.\n\nExample\n-------\n\n.. code:: python\n\n import numpy as np\n from feature_aggregation import BagOfWords, FisherVectors\n\n X = np.random.rand(1000, 2)\n bow = BagOfWords(10)\n fv = FisherVectors(10)\n\n bow.fit(X)\n fv.fit(X)\n\n G1 = bow.transform(np.random.rand(10, 100, 2))\n G2 = fv.transform([\n np.random.rand(int(np.random.rand()*100), 2) for _ in range(10)\n ])\n\nA more complex example using OpenCV to extract dense SIFT and then\ntransform them using Bag Of Words and train an SVM with chi square\nadditive kernel.\n\n.. code:: python\n\n import numpy as np\n import cv2\n from sklearn.datasets import fetch_olivetti_faces\n from sklearn.kernel_approximation import AdditiveChi2Sampler\n from sklearn.metrics import classification_report\n from sklearn.pipeline import Pipeline\n from sklearn.svm import LinearSVC\n\n from feature_aggregation import BagOfWords\n\n def sift(*args, **kwargs):\n try:\n return cv2.xfeatures2d.SIFT_create(*args, **kwargs)\n except:\n return cv2.SIFT()\n\n def dsift(img, step=5):\n keypoints = [\n cv2.KeyPoint(x, y, step)\n for y in range(0, img.shape[0], step)\n for x in range(0, img.shape[1], step)\n ]\n features = sift().compute(img, keypoints)[1]\n features /= features.sum(axis=1).reshape(-1, 1)\n return features\n\n # Generate dense SIFT features\n faces = fetch_olivetti_faces()\n features = [\n dsift((x.reshape(64, 64, 1)*255).astype(np.uint8))\n for x in faces.data\n ]\n\n # Aggregate those features with bag of words using online training\n bow = BagOfWords(100)\n for i in range(2):\n for j in range(0, len(features), 10):\n bow.partial_fit(features[j:j+10])\n faces_bow = bow.transform(features)\n\n # Split in training and test set\n train = np.arange(len(features))\n np.random.shuffle(train)\n test = train[200:]\n train = train[:200]\n\n # Train and evaluate\n svm = Pipeline([(\"chi2\", AdditiveChi2Sampler()), (\"svm\", LinearSVC(C=10))])\n svm.fit(faces_bow[train], faces.target[train])\n print(classification_report(faces.target[test], svm.predict(faces_bow[test])))\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "feature-aggregation", "package_url": "https://pypi.org/project/feature-aggregation/", "platform": "", "project_url": "https://pypi.org/project/feature-aggregation/", "project_urls": null, "release_url": "https://pypi.org/project/feature-aggregation/0.3/", "requires_dist": [ "scikit-learn" ], "requires_python": "", "summary": "Aggregate local features into global features", "version": "0.3" }, "last_serial": 2646406, "releases": { "0.1.1": [ { "comment_text": "", "digests": { "md5": "66adf5ec3cb3f4dba0a5dcf4ddcff5be", "sha256": "c866576e044bc2eb2dfd4e05cfe2781a393d8a183c4602d197a78e4d6c12abaf" }, "downloads": -1, "filename": "feature_aggregation-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "66adf5ec3cb3f4dba0a5dcf4ddcff5be", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10546, "upload_time": "2016-12-15T01:48:48", "url": "https://files.pythonhosted.org/packages/20/f0/dd56e251f62e5a0f8a3d04496de6847059a44deb6e51a566091104c7f7a6/feature_aggregation-0.1.1-py2.py3-none-any.whl" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "fe1b4c973ae4289bd68d31692ed57b12", "sha256": "4cc88c59538b1f24c49efa5091c99f8621e4c5f468cccf9863e542e4c812488d" }, "downloads": -1, "filename": "feature_aggregation-0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "fe1b4c973ae4289bd68d31692ed57b12", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9487, "upload_time": "2016-12-16T10:11:04", "url": "https://files.pythonhosted.org/packages/e3/98/757ace8ef5971c544758c6841bd5ccd7a83f364f183ae21bb998ba59d7ca/feature_aggregation-0.2-py2.py3-none-any.whl" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "232b1731d0de41c9742f2b1b627b179c", "sha256": "9edd66f946dffdf6c4ae3942e13fb5fa8c464efd6525a777d879c241dddd7e07" }, "downloads": -1, "filename": "feature_aggregation-0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "232b1731d0de41c9742f2b1b627b179c", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 13160, "upload_time": "2017-02-16T09:39:38", "url": "https://files.pythonhosted.org/packages/21/51/317a3238ba37c30763177651fb9751f3f545abe021e446ed1e9b5cdc57f5/feature_aggregation-0.3-py2.py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "232b1731d0de41c9742f2b1b627b179c", "sha256": "9edd66f946dffdf6c4ae3942e13fb5fa8c464efd6525a777d879c241dddd7e07" }, "downloads": -1, "filename": "feature_aggregation-0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "232b1731d0de41c9742f2b1b627b179c", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 13160, "upload_time": "2017-02-16T09:39:38", "url": "https://files.pythonhosted.org/packages/21/51/317a3238ba37c30763177651fb9751f3f545abe021e446ed1e9b5cdc57f5/feature_aggregation-0.3-py2.py3-none-any.whl" } ] }