Book Image

Artificial Intelligence with Python

Book Image

Artificial Intelligence with Python

Overview of this book

Artificial Intelligence is becoming increasingly relevant in the modern world. By harnessing the power of algorithms, you can create apps which intelligently interact with the world around you, building intelligent recommender systems, automatic speech recognition systems and more. Starting with AI basics you'll move on to learn how to develop building blocks using data mining techniques. Discover how to make informed decisions about which algorithms to use, and how to apply them to real-world scenarios. This practical book covers a range of topics including predictive analytics and deep learning.
Table of Contents (23 chapters)
Artificial Intelligence with Python
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Operating on time-series data


Pandas allows us to operate on time-series data efficiently and perform various operations like filtering and addition. You can simply set some conditions and Pandas will filter the dataset and return the right subset. You can add two time-series variables as well. This allows us to build various applications quickly without having to reinvent the wheel.

Create a new Python file and import the following packages:

import numpy as np 
import pandas as pd 
import matplotlib.pyplot as plt 
 
from timeseries import read_data  

Define the input filename:

# Input filename 
input_file = 'data_2D.txt' 

Load the third and fourth columns into separate variables:

# Load data 
x1 = read_data(input_file, 2) 
x2 = read_data(input_file, 3) 

Create a Pandas dataframe object by naming the two dimensions:

# Create pandas dataframe for slicing 
data = pd.DataFrame({'dim1': x1, 'dim2': x2}) 

Plot the data by specifying the start...