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

Anand Kumpatla

Sr Data Scientist @ Doubleslash Software Solutions Pvt Ltd
linkedin profile url

ProjectPro is a unique platform and helps many people in the industry to solve real-life problems with a step-by-step walkthrough of projects. A platform with some fantastic resources to gain... Read More

Relevant Projects

Hands-On Approach to Regression Discontinuity Design Python
In this machine learning project, you will learn to implement Regression Discontinuity Design Example in Python to determine the effect of age on Mortality Rate in Python.

Skip Gram Model Python Implementation for Word Embeddings
Skip-Gram Model word2vec Example -Learn how to implement the skip gram algorithm in NLP for word embeddings on a set of documents.

AWS MLOps Project to Deploy Multiple Linear Regression Model
Build and Deploy a Multiple Linear Regression Model in Python on AWS

Deploy Transformer-BART Model on Paperspace Cloud
In this MLOps Project you will learn how to deploy a Tranaformer BART Model for Abstractive Text Summarization on Paperspace Private Cloud

GCP MLOps Project to Deploy ARIMA Model using uWSGI Flask
Build an end-to-end MLOps Pipeline to deploy a Time Series ARIMA Model on GCP using uWSGI and Flask

Deploy Transformer BART Model for Text summarization on GCP
Learn to Deploy a Machine Learning Model for the Abstractive Text Summarization on Google Cloud Platform (GCP)

Census Income Data Set Project-Predict Adult Census Income
Use the Adult Income dataset to predict whether income exceeds 50K yr based oncensus data.

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.

Learn How to Build a Logistic Regression Model in PyTorch
In this Machine Learning Project, you will learn how to build a simple logistic regression model in PyTorch for customer churn prediction.

Customer Churn Prediction Analysis using Ensemble Techniques
In this machine learning churn project, we implement a churn prediction model in python using ensemble techniques.