The AI Ecosystem

Meet the core libraries that make up the Python data and machine-learning stack.

The Python AI world is built as layers. Each library does one job well and builds on the ones below it.

LibraryJob
numpyFast numerical arrays — the foundation of everything.
pandasTables of data (DataFrames): load, clean and reshape.
matplotlib / seabornCharts and plots to explore data.
scikit-learnClassic machine learning: regression, classification, clustering.
tensorflow / pytorchDeep learning with neural networks.

A typical project moves down this list: load with pandas, compute with numpy, visualise with matplotlib, model with scikit-learn.

Example

Example · python
# The typical import block at the top of a notebook
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split

print('Imported the core data-science stack')

When to use it

  • A data analyst loads a CSV with pandas, computes correlations with numpy, and plots the heatmap with seaborn in a single workflow.
  • An ML engineer uses scikit-learn for feature engineering and model selection, then switches to PyTorch only for the final deep-learning layer.
  • A team standardises on the numpy-pandas-matplotlib-scikit-learn stack so every member speaks the same library language in code reviews.

More examples

Library version snapshot

Prints every major AI-stack library name and version in one loop, giving a quick health-check of the installed ecosystem.

Example · python
import numpy, pandas, matplotlib, sklearn, seaborn

for lib in [numpy, pandas, matplotlib, sklearn, seaborn]:
    print(lib.__name__, lib.__version__)

Layer handoff: pandas to numpy

Extracts a pandas column into a numpy array and applies a fast vectorised mean, illustrating how the two library layers hand off work.

Example · python
import pandas as pd
import numpy as np

df = pd.DataFrame({'sales': [100, 200, 150], 'cost': [80, 130, 90]})
profit = np.array(df['sales'] - df['cost'])
print(profit.mean())

Full stack: load, compute, plot, model

Chains all four ecosystem layers: pandas loads, numpy backs the arrays, scikit-learn fits, and matplotlib visualises the regression line.

Example · python
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression

df = pd.read_csv('house_prices.csv')
X = df[['sqft']].values
y = df['price'].values
model = LinearRegression().fit(X, y)
plt.scatter(X, y, alpha=0.4)
plt.plot(X, model.predict(X), color='red')

Discussion

  • Be the first to comment on this lesson.