0% found this document useful (0 votes)
5 views23 pages

Python Libraries

The document provides an overview of Python libraries used for predictive analytics, specifically pandas, matplotlib, and scikit-learn. It outlines their key features, installation instructions, and examples of usage for data manipulation, visualization, and machine learning tasks. The learning outcomes include understanding predictive analytics basics, using these libraries, and gaining hands-on experience in building predictive models.

Uploaded by

crysteljoytan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views23 pages

Python Libraries

The document provides an overview of Python libraries used for predictive analytics, specifically pandas, matplotlib, and scikit-learn. It outlines their key features, installation instructions, and examples of usage for data manipulation, visualization, and machine learning tasks. The learning outcomes include understanding predictive analytics basics, using these libraries, and gaining hands-on experience in building predictive models.

Uploaded by

crysteljoytan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Home

PYTHON
LIBRARIES
Content

Learning Outcomes
1. understood the basics of predictive analytics
and linear regression;
2. learned to use Python libraries like pandas,
matplotlib, and scikit-learn, and
3. gained hands-on experience in building,
training, and evaluating a predictive model.
Content

Python is a collection of pre-


written code, including
Library modules, functions,
classes, and other
resources, that
developers can use in
their Python programs.
Content

➢ is an open-source

Pandas Python library


primarily used for data
manipulation and
analysis.
Content

PANDAS KEY FEATURES:

➢ Data Structures:
✓ Series: A one- ✓ DataFrame: A two-
dimensional labeled dimensional labeled
array capable of data structure with
holding any data columns of potentially
type(integers, different types.
strings, floating-
point numbers, Python
objects, etc.
Content

PANDAS KEY FEATURES:

➢ Data Handling ✓ Data Cleaning and


Capabilities: Preprocessing: It
✓ Data Loading and offers functions for
Saving: Pandas can handling missing data
read and write data (e.g., filling,
from various formats, dropping), removing
including CSV, Excel, duplicates, and
SQL databases, JSON, transforming data
and more. types
Content

PANDAS KEY FEATURES:

✓ Data Analysis and ✓ Time Series


Manipulation: Pandas Functionality: It
enables operation such provides specialized
as filtering, sorting, tools for working
grouping, aggregating, with time-series
merging, joining, and data, including data
reshaping data. range generation,
frequency conversion,
and time-based
indexing.
Content

To install the library:


pip install pandas

To use the library:


import pandas as pd
Content

EXAMPLE
import pandas as pd
data = [Link]({
'Hours_Studied': [2, 4, 6, 8, 10],
'Attendance_Rate': [75, 85, 90, 95, 97],
'Final_Grade': [65, 70, 78, 88, 93]
})
# Display the dataset
print("Dataset:")
print(data)
Content

is a comprehensive and

Matplotlib
widely-used library in
Python for creating
static, animated, and
interactive
visualizations.
Content

MATPLOTLIB KEY FEATURES and


FUNCTIONALITIES:
✓ Diverse Plot Types: ✓ Customization: It
It supports a wide offers extensive
array of plot types, customization options
including line plots, for plots, allowing
scatter plots, bar users to control
charts, histograms, elements such as
pie charts, 3D plots, colors, line styles,
and more markers, labels,
titles, legends, and
axis properties
Content

MATPLOTLIB KEY FEATURES and


FUNCTIONALITIES:
✓ Interactivity: It ✓ Output Formats: It can
supports interactive export visualizations
features, enabling to various file
users to zoom, pan, formats, including PNG,
and update figures in PDF, SVG, and
interactive PostScript
environments.
Content

MATPLOTLIB KEY FEATURES and


FUNCTIONALITIES:
✓ Integration: It
integrates seamlessly
with other popular
Python libraries like
NumPy, and Pandas
Content

To install the library:


pip install matplotlib

To use the library:


import [Link] as plt
Content

EXAMPLE
import [Link] as plt
[Link](figsize=(6,4))
[Link](data['Hours_Studied'],
data['Final_Grade'], color='blue', label='Data
points')
[Link]('Hours Studied')
[Link]('Final Grade')
[Link]('Hours Studied vs Final Grade')
[Link](True)
[Link]()
[Link]()
Content

➢ is an open-source
Python library
widely used for
Scikit-learn machine learning.
(sklearn) ➢ It provides a
comprehensive set of
tools for various
machine learning
tasks.
Content

SCIKIT-LEARN MACHINE LEARNING


TASKS
✓ Classification: ✓ Regression: Algorithms
Algorithms for for predicting
categorizing data continues numerical
into predefined values (e.g., house
classes (e.g., spam price prediction, stock
detection, image market forecasting)
classification)
Content

SCIKIT-LEARN MACHINE LEARNING


TASKS
✓ Clustering: ✓ Dimensionality
Algorithms for Reduction: Techniques
grouping similar data for reducing the number
points together of features in a
without prior dataset while retaining
knowledge of labels important information
(e.g., customer (e.g., Principal
segmentation) Component Analysis PCA)
Content

SCIKIT-LEARN MACHINE LEARNING


TASKS
✓ Model Selection and ✓ Preprocessing:
Evaluation: Tools for Utilities for preparing
choosing the best data for machine
model for a given learning algorithms,
task and assessing such as scaling,
its performance normalization, and
(e.g., cross- handling missing
validation, values.
hyperparameter tuning)
Content

To install the library:


pip install –U scikit-learn

To use the library:


from sklearn.linear_model import LinearRegression
Content

EXAMPLE
from sklearn.linear_model import LinearRegression
# Feature (X) and Target (y)
X = data[['Hours_Studied']] # You can add more
features later
y = data['Final_Grade']

# Initialize and train the model


model = LinearRegression()
[Link](X, y)
Content

EXAMPLE
# 4. Make a prediction
# -----------------------------
hours = 7
predicted_grade = [Link]([[hours]])
print(f"\nPredicted grade for a student who
studied {hours} hours:
{predicted_grade[0]:.2f}")
Content

EXAMPLE
from [Link] import mean_squared_error

# 5. Evaluate the model


# -----------------------------
y_pred = [Link](X)
mse = mean_squared_error(y, y_pred)
print(f"Mean Squared Error: {mse:.2f}")

You might also like