Simple API for UCI Machine Learning Dataset Repository (search, download, analyze)

Overview

A simple API for working with University of California, Irvine (UCI) Machine Learning (ML) repository

License: MIT GitHub issues GitHub forks GitHub stars PRs Welcome Github commits

Header

Table of Contents

  1. Introduction
  2. About Page of the repository
  3. Navigating the portal can be challenging and time consuming
  4. Introducing UCIML Python code base
  5. Required packages/Dependencies
  6. How to run it
  7. Features and functions currently supported
  8. Example (search and download a particular dataset)
  9. Example (search for datasets with a particular keyword)
  10. If want to bypass the simple API and play with the low-level functions

Introduction

UCI machine learning dataset repository is something of a legend in the field of machine learning pedagogy. It is a 'go-to-shop' for beginners and advanced learners alike. This codebase is an attempt to present a simple and intuitive API for UCI ML portal, using which users can easily look up a dataset description, search for a particular dataset they are interested, and even download datasets categorized by size or machine learning task.

About Page of the repository

The UCI Machine Learning Repository is a collection of databases, domain theories, and data generators that are used by the machine learning community for the empirical analysis of machine learning algorithms. The archive was created as an ftp archive in 1987 by David Aha and fellow graduate students at UC Irvine. Since that time, it has been widely used by students, educators, and researchers all over the world as a primary source of machine learning data sets. As an indication of the impact of the archive, it has been cited over 1000 times, making it one of the top 100 most cited "papers" in all of computer science. The current version of the web site was designed in 2007 by Arthur Asuncion and David Newman, and this project is in collaboration with Rexa.info at the University of Massachusetts Amherst. Funding support from the National Science Foundation is gratefully acknowledged.

UCI ML Logo

But navigating the portal can be challenging and time consuming...

UCI ML portal is a wonderful gift to ML practioners. That said, navigating the portal can be bit frustrating and time consuming as there is no simple intuitive API or download link for the dataset you are interested in. You have to hop around multiple pages to go to the raw dataset page that you are looking for. Also, if you are interested in particular type of ML task (regression or classification for example) and want to download all datasets corresponding to that task, there is no simple command to accomplish such.

Introducing UCIML Python code base

This is a MIT-licensed Open-source Python 3.6 codebase which offers functions and methods to allow an user play with the UCI ML datasets in an interactive manner. Download/clone/fork the codebase from my Github page here.

Required packages/Dependencies

Only three widely used Python packages are required to run this code. For easy installation of these supporting packages, setup.bash and setup.bat files are included in my repo. Just execute them in your Linux/Windows shell and you are ready!

How to run it?

Make sure you are connected to Internet:-) Then, just download/clone the Gitgub repo, make sure to have the supporting packages installed.

git clone https://github.com/tirthajyoti/UCI-ML-API.git {your_local_directory}

Then go to the your_local_directory where you have cloned the Git and run the following command at your terminal.

python Main.py

A menu will open up allowing you to perform various tasks. Here is a screenshot of the menu,

Menu

Features and functions currently supported

Following features are currently implemented...

  • Building a local database of name, description, and URL of datasets by crawling the entire portal
  • Building a local database of name, size, machine learning task of datasets by crawling the entire portal
  • Search and download a particular dataset
  • Download first few datasets
  • Print names of all datasets
  • Print short descriptions of all datasets
  • Search for one-liner description and webpage link (for more info) of a dataset
  • Download datasets based on their size
  • Download datasets based on the machine learning task associated with them

Example (search and download a particular dataset)

For example if you want to download the famous dataset Iris, just choose the option 3 from the menu, enter the name of the local database stored (to make the search faster) and voila! You will have the Iris dataset downloaded and stored in a folder called 'Iris' in your directory!

Iris download example

Example (search for datasets with a particular keyword)

If you search using a keyword by choosing option 7, then you will get back short one-liner abstracts about all the datasets whose name match your search string (even partially). You will also get the associated web page link for each of these results, so that you can go and explore them more if you want. Below screenshot shows an example of searching with the term Cancer.

Search example with a keyword

If want to bypass the simple API and play with the low-level functions

In case you want to bypass the simple user API and play with the low-level functions, you are welcome to do so. Here is the rundown on them. First, import the necessary packages,

from UCI_ML_Functions import *
import pandas as pd

read_dataset_table(): Reads the table of datasets from the url: "https://archive.ics.uci.edu/ml/datasets.html" and process it further to clean and categorize.

clean_dataset_table(): Accepts the raw dataset table (a DataFrame object) and returns a cleaned up version removing entries with unknown number of samples and attributes. Also rationalizes the 'Default task' category column indicating the main machine learning task associated with the datasets.

build_local_table(filename=None,msg_flag=True): Reads through the UCI ML portal and builds a local table with information such as name, size, ML task, data type.

  • filename: Optional filename that can be chosen by the user. If not chosen, a default name ('UCI table.csv') will be selected by the program.
  • msg_flag: Controls verbosity.

build_dataset_list(): Scrapes through the UCI ML datasets page and builds a list of all datasets.

build_dataset_dictionary(): Scrapes through the UCI ML datasets page and builds a dictionary of all datasets with names and description. Also stores the unique identifier corresponding to the dataset. This identifier string is needed by the downloader function to download the data file. Generic name won't work.

build_full_dataframe(): Builds a DataFrame with all information together including the url link for downloading the data.

build_local_database(filename=None,msg_flag=True): Reads through the UCI ML portal and builds a local database with information such as: name, abstract, data page URL.

  • filename: Optional filename that can be chosen by the user. If not chosen, a default name ('UCI database.csv') will be selected by the program.
  • msg_flag: Controls verbosity.

return_abstract(name,local_database=None,msg_flag=False): Returns one-liner description (and webpage link for further information) of a particular dataset by searching the given name.

  • local_database: Name of the database (CSV file) stored locally i.e. in the same directory, which contains information about all the datasets on UCI ML repo.
  • msg_flag: Controls verbosity.

describe_all_dataset(msg_flag=False): Calls the build_dataset_dictionary function and prints description of all datasets from that.

print_all_datasets_names(msg_flag=False): Calls the build_dataset_dictionary function and prints names of all datasets from that.

extract_url_dataset(dataset,msg_flag=False): Given a dataset identifier this function extracts the URL for the page where the actual raw data resides.

download_dataset_url(url,directory,msg_flag=False,download_flag=True): Download all the files from the links in the given url.

  • msg_flag: Controls verbosity.
  • download_flag: Default is True. If set to False, only creates the directories but does not initiate download (for testing purpose).

download_datasets(num=10,local_database=None,msg_flag=True,download_flag=True): Downloads datasets and puts them in a local directory named after the dataset. By default downloads first 10 datasets only. User can choose the number of dataets to be downloaded.

  • msg_flag: Controls verbosity.
  • download_flag: Default is True. If set to False, only creates the directories but does not initiate download (for testing purpose).

download_dataset_name(name,local_database=None,msg_flag=True,download_flag=True): Downloads a particular dataset by searching the given name.

  • local_database: Name of the database (CSV file) stored locally i.e. in the same directory, which contains information about all the datasets on UCI ML repo.
  • msg_flag: Controls verbosity.
  • download_flag: Default is True. If set to False, only creates the directories but does not initiate download (for testing purpose).

download_datasets_size(size='Small',local_database=None,local_table=None,msg_flag=False,download_flag=True): Downloads all datasets which satisfy the 'size' criteria.

  • size: Size of the dataset which user wants to download. Could be any of the following: 'Small', 'Medium', 'Large','Extra Large'.
  • local_database: Name of the database (CSV file) stored locally i.e. in the same directory, which contains name and URL information about all the datasets on UCI ML repo.
  • local_table: Name of the database (CSV file) stored locally i.e. in the same directory, which contains features information about all the datasets on UCI ML repo i.e. number of samples, type of machine learning task to be performed with the dataset.
  • msg_flag: Controls verbosity.
  • download_flag: Default is True. If set to False, only creates the directories but does not initiate download (for testing purpose).

download_datasets_task(task='Classification',local_database=None,local_table=None,msg_flag=False,download_flag=True): Downloads all datasets which match the ML task criteria as eneterd by the user.

  • task: Machine learning task for which user wants to download the datasets. Could be any of the following:

'Classification', 'Recommender Systems', 'Regression', 'Other/Unknown', 'Clustering', 'Causal Discovery'.

  • local_database: Name of the database (CSV file) stored locally i.e. in the same directory, which contains name and URL information about all the datasets on UCI ML repo.
  • local_table: Name of the database (CSV file) stored locally i.e. in the same directory, which contains features information about all the datasets on UCI ML repo i.e. number of samples, type of machine learning task to be performed with the dataset.
  • msg_flag: Controls verbosity.
  • download_flag: Default is True. If set to False, only creates the directories but does not initiate download (for testing purpose).

So, give it a try and put a star to my Github repo if you like it.

Feedbacks and suggestions for improvements are most welcome at [email protected]

Comments
  • Some code fixes

    Some code fixes

    To run the code, I had to make some fixes:

    • UCI_ML_Functions.py line 29: df = df.iloc[1:nrows:2][[0,1,2,3,4,5,6]] When I download the table the columns are indexed 0 to 6.
    • Line 209: url="https://archive.ics.uci.edu/ml/datasets.php?format=&task=&att=&area=&numAtt=&numIns=&type=&sort=nameUp&view=list", (datasets.php instead of .html).
    • Line 520: local_directory = cwd + "/" + str(directory) (/ instead of \\).

    The following is not necessary, but nice:

    • Choice.py line 117: print(f"OK, downloading all datasets of {task} task. This will take some time...") In this context it should not be filtered according to size but the task.

    Thank you for sharing your code!

    opened by pfetsch 1
  • setup.py?

    setup.py?

    Great work putting this out there! :smile: It takes courage to release your project as open source.

    I'm wondering if you'd like some guidance with making this an installable setup package, complete with a command-line executable, which can be deployed to PyPI and conda? Doing so would make this package accessible through idiomatic channels, rather than through github.

    opened by ericmjl 1
  • Multiple fixes to get the tool working in 2022

    Multiple fixes to get the tool working in 2022

    In the process of getting the tool working I needed to make several changes.

    • Change '.html' to '.php' in path to UCI repository. The URL was probably updated in the past years and got out of sync
    • Function read_dataset_table was skipping every other row and the first two columns in the parsed table from HTML. This was no longer valid for the current format of the table
    • Path concatenation was not multiplatform and download of dataset was crashing on MacOS
    opened by janbrab 0
  • KeyError: '[8, 7] not in index' when selecting option 2

    KeyError: '[8, 7] not in index' when selecting option 2

    I'm not sure whether other people experience the same issue, but when trying to build the local database on the basis of classification task/size etc (option 2), I receive an error that the 7,8 is not in the index. Have been trying to look for a workaround, but haven't been successful yet.

    opened by MeilinaR 0
  • AttributeError: 'int' object has no attribute 'keys'

    AttributeError: 'int' object has no attribute 'keys'

    Hi I tried to print all the datasets to see which I wanted to download but I got an issue with the print_all_datastes_names() functions, apparently the url for the uci dataset is returing server error and then here is giving an int instead of the dictionary. Is there a link to the UCI dataset that I can replace in the script?

    Traceback (most recent call last): File "Main.py", line 29, in execute_choice() File "/home/lucassoares/Desktop/projects/tmp_files/UCI-ML-API/Choice.py", line 66, in execute_choice print_all_datasets_names() File "/home/lucassoares/Desktop/projects/tmp_files/UCI-ML-API/UCI_ML_Functions.py", line 426, in print_all_datasets_names for key in dict1.keys():

    opened by EnkrateiaLucca 1
  • Could not open the UCI ML portal successfully

    Could not open the UCI ML portal successfully

    When I run: from UCI_ML_Functions import * import pandas as pd download_datasets_task(task='Classification', download_flag=False)

    I encounter the error: Could not open the UCI ML portal successfully.

    Could you please tell me what's wrong?

    opened by ZhangTP1996 1
Owner
Tirthajyoti Sarkar
Data Sc/Engineering manager , Industry 4.0, edge-computing, semiconductor technologist, Author, Python pkgs - pydbgen, MLR, and doepy,
Tirthajyoti Sarkar
Using machine learning to predict and analyze high and low reader engagement for New York Times articles posted to Facebook.

How The New York Times can increase Engagement on Facebook Using machine learning to understand characteristics of news content that garners "high" Fa

Jessica Miles 0 Sep 16, 2021
Machine Learning From Scratch. Bare bones NumPy implementations of machine learning models and algorithms with a focus on accessibility. Aims to cover everything from linear regression to deep learning.

Machine Learning From Scratch About Python implementations of some of the fundamental Machine Learning models and algorithms from scratch. The purpose

Erik Linder-Norén 21.8k Jan 9, 2023
Vowpal Wabbit is a machine learning system which pushes the frontier of machine learning with techniques such as online, hashing, allreduce, reductions, learning2search, active, and interactive learning.

This is the Vowpal Wabbit fast online learning code. Why Vowpal Wabbit? Vowpal Wabbit is a machine learning system which pushes the frontier of machin

Vowpal Wabbit 8.1k Jan 6, 2023
Python script to download the celebA-HQ dataset from google drive

download-celebA-HQ Python script to download and create the celebA-HQ dataset. WARNING from the author. I believe this script is broken since a few mo

null 133 Dec 21, 2022
Model search is a framework that implements AutoML algorithms for model architecture search at scale

Model search (MS) is a framework that implements AutoML algorithms for model architecture search at scale. It aims to help researchers speed up their exploration process for finding the right model architecture for their classification problems (i.e., DNNs with different types of layers).

Google 3.2k Dec 31, 2022
This repo contains the code and data used in the paper "Wizard of Search Engine: Access to Information Through Conversations with Search Engines"

Wizard of Search Engine: Access to Information Through Conversations with Search Engines by Pengjie Ren, Zhongkun Liu, Xiaomeng Song, Hongtao Tian, Zh

null 19 Oct 27, 2022
Deep Text Search is an AI-powered multilingual text search and recommendation engine with state-of-the-art transformer-based multilingual text embedding (50+ languages).

Deep Text Search - AI Based Text Search & Recommendation System Deep Text Search is an AI-powered multilingual text search and recommendation engine w

null 19 Sep 29, 2022
Densely Connected Search Space for More Flexible Neural Architecture Search (CVPR2020)

DenseNAS The code of the CVPR2020 paper Densely Connected Search Space for More Flexible Neural Architecture Search. Neural architecture search (NAS)

Jamin Fong 291 Nov 18, 2022
Ἀνατομή is a PyTorch library to analyze representation of neural networks

Ἀνατομή is a PyTorch library to analyze representation of neural networks

Ryuichiro Hataya 50 Dec 5, 2022
A tool to analyze leveraged liquidity mining and find optimal option combination for hedging.

LP-Option-Hedging Description A Python program to analyze leveraged liquidity farming/mining and find the optimal option combination for hedging imper

Aureliano 18 Dec 19, 2022
A program that can analyze videos according to the weights you select

MaskMonitor A program that can analyze videos according to the weights you select 下載 訓練完的 weight檔案 執行 MaskDetection.py 內部可更改 輸入來源(鏡頭, 影片, 圖片) 以及輸出條件(人

Patrick_star 1 Nov 7, 2021
TUPÃ was developed to analyze electric field properties in molecular simulations

TUPÃ: Electric field analyses for molecular simulations What is TUPÃ? TUPÃ (pronounced as tu-pan) is a python algorithm that employs MDAnalysis engine

Marcelo D. Polêto 10 Jul 17, 2022
A fast, dataset-agnostic, deep visual search engine for digital art history

imgs.ai imgs.ai is a fast, dataset-agnostic, deep visual search engine for digital art history based on neural network embeddings. It utilizes modern

Fabian Offert 5 Dec 14, 2022
A Python Automated Machine Learning tool that optimizes machine learning pipelines using genetic programming.

Master status: Development status: Package information: TPOT stands for Tree-based Pipeline Optimization Tool. Consider TPOT your Data Science Assista

Epistasis Lab at UPenn 8.9k Dec 30, 2022
Scripts of Machine Learning Algorithms from Scratch. Implementations of machine learning models and algorithms using nothing but NumPy with a focus on accessibility. Aims to cover everything from basic to advance.

Algo-ScriptML Python implementations of some of the fundamental Machine Learning models and algorithms from scratch. The goal of this project is not t

Algo Phantoms 81 Nov 26, 2022
This is a Machine Learning Based Hand Detector Project, It Uses Machine Learning Models and Modules Like Mediapipe, Developed By Google!

Machine Learning Hand Detector This is a Machine Learning Based Hand Detector Project, It Uses Machine Learning Models and Modules Like Mediapipe, Dev

Popstar Idhant 3 Feb 25, 2022
Reference implementation of code generation projects from Facebook AI Research. General toolkit to apply machine learning to code, from dataset creation to model training and evaluation. Comes with pretrained models.

This repository is a toolkit to do machine learning for programming languages. It implements tokenization, dataset preprocessing, model training and m

Facebook Research 408 Jan 1, 2023