How to import datasets using sklearn in PyBrain

This recipe helps you import datasets using sklearn in PyBrain

Recipe Objective - How to import datasets using sklearn in PyBrain?

ScikitLearn provides clean data sets that you can use when creating ML models. Datasets can be found in sklearn.datasets.

For more related projects -

https://www.projectpro.io/projects/data-science-projects/neural-network-projects
https://www.projectpro.io/projects/data-science-projects/keras-deep-learning-projects

Let's try to import the iris dataset using sklearn in pybrain-

# Importing datasets from sklearn library
from sklearn import datasets

# Importing Classification Data set
from pybrain.datasets import ClassificationDataSet

# Loading iris dataset from sklearn datasets
iris = datasets.load_iris()

# Defining feature variables and target variable
X_data = iris.data
y_data = iris.target

# Creating classification dataset model by defining 4 inputs, 1 output and 3 classes.
classification_dataset = ClassificationDataSet(4, 1, nb_classes=3)

# Adding data to classification dataset
for i in range(len(X_data)):
  classification_dataset.addSample(X_data[i], y_data[i])

# Data loaded into classification dataset from sklearn datasets
print(classification_dataset)

Output -
input: dim(254, 4)
[[5.1 3.5 1.4 0.2]
 [4.9 3.  1.4 0.2]
 [4.7 3.2 1.3 0.2]
 [4.6 3.1 1.5 0.2]
 .
 .
 .
 .
 [2]
 [2]]

class: dim(0, 1)
[]

In this way, we can import datasets using sklearn in PyBrain.

What Users are saying..

profile image

Ed Godalle

Director Data Analytics at EY / EY Tech
linkedin profile url

I am the Director of Data Analytics with over 10+ years of IT experience. I have a background in SQL, Python, and Big Data working with Accenture, IBM, and Infosys. I am looking to enhance my skills... Read More

Relevant Projects

FEAST Feature Store Example for Scaling Machine Learning
FEAST Feature Store Example- Learn to use FEAST Feature Store to manage, store, and discover features for customer churn prediction machine learning project.

Build a Hybrid Recommender System in Python using LightFM
In this Recommender System project, you will build a hybrid recommender system in Python using LightFM .

Deploying Machine Learning Models with Flask for Beginners
In this MLOps on GCP project you will learn to deploy a sales forecasting ML Model using Flask.

Medical Image Segmentation Deep Learning Project
In this deep learning project, you will learn to implement Unet++ models for medical image segmentation to detect and classify colorectal polyps.

Time Series Python Project using Greykite and Neural Prophet
In this time series project, you will forecast Walmart sales over time using the powerful, fast, and flexible time series forecasting library Greykite that helps automate time series problems.

Build a Multi Class Image Classification Model Python using CNN
This project explains How to build a Sequential Model that can perform Multi Class Image Classification in Python using CNN

Build a Autoregressive and Moving Average Time Series Model
In this time series project, you will learn to build Autoregressive and Moving Average Time Series Models to forecast future readings, optimize performance, and harness the power of predictive analytics for sensor data.

Build Deep Autoencoders Model for Anomaly Detection in Python
In this deep learning project , you will build and deploy a deep autoencoders model using Flask.

Recommender System Machine Learning Project for Beginners-3
Content Based Recommender System Project - Building a Content-Based Product Recommender App with Streamlit

Ola Bike Rides Request Demand Forecast
Given big data at taxi service (ride-hailing) i.e. OLA, you will learn multi-step time series forecasting and clustering with Mini-Batch K-means Algorithm on geospatial data to predict future ride requests for a particular region at a given time.