How to import the dataset from CSV file in PyBrain

This recipe helps you import the dataset from CSV file in PyBrain

Recipe Objective - How to import the dataset from a CSV file in PyBrain?

For more related projects -

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

Let's try to import the iris dataset from a CSV file-

# Importing pandas
import pandas as pd

# Importing Classification Data set
from pybrain.datasets import ClassificationDataSet

# Importing iris data from csv file
iris = pd.read_csv("iris.csv")

# Label encoding the target variable
iris['Species'] = iris['Species'].replace({'Iris-setosa':0,'Iris-versicolor':1,'Iris-virginica':2})

# Defining feature variables and target variable
iris = iris.values
X_data = iris[:,0:4]
y_data = iris[:,4]

# 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 the dataset from a CSV file in PyBrain.

What Users are saying..

profile image

Abhinav Agarwal

Graduate Student at Northwestern University
linkedin profile url

I come from Northwestern University, which is ranked 9th in the US. Although the high-quality academics at school taught me all the basics I needed, obtaining practical experience was a challenge.... Read More

Relevant Projects

Build and Deploy Text-2-SQL LLM Using OpenAI and AWS
In this LLM project, you will learn to build a user-friendly web application that leverages Large Language Models (LLMs) to convert natural language queries into optimized SQL commands.

Build and Deploy an AI Resume Analyzer with OpenAI and Azure
In this AI Resume Analyzer project, you will learn to build and deploy AI resume analyzer that helps job seekers assess how effectively their resumes match job descriptions using OpenAI's language models and Azure's cloud infrastructure.

Build Regression Models in Python for House Price Prediction
In this Machine Learning Regression project, you will build and evaluate various regression models in Python for house price prediction.

Learn Object Tracking (SOT, MOT) using OpenCV and Python
Get Started with Object Tracking using OpenCV and Python - Learn to implement Multiple Instance Learning Tracker (MIL) algorithm, Generic Object Tracking Using Regression Networks Tracker (GOTURN) algorithm, Kernelized Correlation Filters Tracker (KCF) algorithm, Tracking, Learning, Detection Tracker (TLD) algorithm for single and multiple object tracking from various video clips.

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 an AI Quiz Generator from Video with OpenAI API
In this LLM project, you will build a model to automate the transcription of video content and generate interactive quizzes using OpenAI’s Whisper and GPT-4o.

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.

BERT Text Classification using DistilBERT and ALBERT Models
This Project Explains how to perform Text Classification using ALBERT and DistilBERT

Learn to Build a Polynomial Regression Model from Scratch
In this Machine Learning Regression project, you will learn to build a polynomial regression model to predict points scored by the sports team.

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)

OSZAR »