How to create a dataset using PyBrain

This recipe helps you create a dataset using PyBrain

Recipe Objective - How to create a dataset using PyBrain?

Datasets are data to be given to test, validate and train on networks.
To create a dataset, we need to use the pybrain dataset package: pybrain.datasets.
Pybrain supports dataset classes like SupervisedDataset, SequentialDataset, ClassificationDataSet. We are going to use SupervisedDataset to create our data set. The dataset to use depends on the machine learning task that the user is trying to implement. SupervisedDataset is the simplest, and we will use the same here.

Apply Machine Learning to Demand Forecasting Data Science Problems

For more related projects -

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

Let's try to create an AND truth table. The inputs given are like a two-dimensional array, and we get 1 output. Here the input becomes the size, and the target becomes the output, which is 1. So the inputs that are used for our dataset are 2,1.

# importing supervised dataset
from pybrain.datasets import SupervisedDataSet

# Creating object
supervised_dataset = SupervisedDataSet(2, 1)

# AND table
and_table = [ [(0,0), (0,)], [(0,1), (0,)], [(1,0), (0,)], [(1,1), (1,)], ]

# Adding sample from and_table into supervised_dataset
for input, target in and_table:
  supervised_dataset.addSample(input, target)

print("Input=>\n", supervised_dataset['input'])
print("")
print("Target=>\n", supervised_dataset['target'])

Output -
Input=>
 [[0. 0.]
 [0. 1.]
 [1. 0.]
 [1. 1.]]

Target=>
 [[0.]
 [0.]
 [0.]
 [1.]]

In this way, we can create a dataset using 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

Learn to Build an End-to-End Machine Learning Pipeline - Part 1
In this Machine Learning Project, you will learn how to build an end-to-end machine learning pipeline for predicting truck delays, addressing a major challenge in the logistics industry.

Build a Logistic Regression Model in Python from Scratch
Regression project to implement logistic regression in python from scratch on streaming app data.

NLP Project to Build a Resume Parser in Python using Spacy
Use the popular Spacy NLP python library for OCR and text classification to build a Resume Parser in Python.

Hands-On Approach to Causal Inference in Machine Learning
In this Machine Learning Project, you will learn to implement various causal inference techniques in Python to determine, how effective the sprinkler is in making the grass wet.

Build a Speech-Text Transcriptor with Nvidia Quartznet Model
In this Deep Learning Project, you will leverage transfer learning from Nvidia QuartzNet pre-trained models to develop a speech-to-text transcriptor.

Build CNN for Image Colorization using Deep Transfer Learning
Image Processing Project -Train a model for colorization to make grayscale images colorful using convolutional autoencoders.

Build an Image Classifier for Plant Species Identification
In this machine learning project, we will use binary leaf images and extracted features, including shape, margin, and texture to accurately identify plant species using different benchmark classification techniques.

Build a Review Classification Model using Gated Recurrent Unit
In this Machine Learning project, you will build a classification model in python to classify the reviews of an app on a scale of 1 to 5 using Gated Recurrent Unit.

Machine Learning Project to Forecast Rossmann Store Sales
In this machine learning project you will work on creating a robust prediction model of Rossmann's daily sales using store, promotion, and competitor data.

AWS MLOps Project for ARCH and GARCH Time Series Models
Build and deploy ARCH and GARCH time series forecasting models in Python on AWS .