Chapter 4Artificial Intelligence~1 min read
Python for AI — NumPy आणि Pandas
AI साठी Essential Python Libraries
Python हे AI/ML साठी most popular language आहे कारण NumPy, Pandas, Matplotlib, Scikit-learn, TensorFlow, PyTorch — सगळे Python libraries आहेत. AI करण्यापूर्वी हे libraries शिकणे आवश्यक आहे.
Setup
bash
pip install numpy pandas matplotlib scikit-learn tensorflow
# किंवा Anaconda distribution — सगळं built-in असतं
# Google Colab — free GPU, no setup needed!NumPy — Numerical Computing
NumPy basics
python
import numpy as np
# Array बनवा
arr = np.array([1, 2, 3, 4, 5])
matrix = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
# Shape बघा
print(arr.shape) # (5,)
print(matrix.shape) # (3, 3)
# Operations — element-wise (Python list पेक्षा 100x fast)
print(arr * 2) # [2, 4, 6, 8, 10]
print(arr + arr) # [2, 4, 6, 8, 10]
print(np.sum(arr)) # 15
print(np.mean(arr)) # 3.0
print(np.std(arr)) # standard deviation
# Random data (ML साठी)
X = np.random.randn(100, 5) # 100 samples, 5 features
y = np.random.randint(0, 2, 100) # 100 binary labelsPandas — Data Manipulation
Pandas basics
python
import pandas as pd
# CSV load करा
df = pd.read_csv('students.csv')
# Data बघा
print(df.head()) # पहिले 5 rows
print(df.shape) # (rows, columns)
print(df.info()) # dtypes, null counts
print(df.describe()) # statistics
# Column select
ages = df['age']
subset = df[['name', 'grade']]
# Filter
high_scorers = df[df['score'] > 80]
mumbai = df[df['city'] == 'Mumbai']
# Missing values handle करा
df['age'].fillna(df['age'].mean(), inplace=True) # mean ने fill
df.dropna(inplace=True) # rows with NaN drop
# New column
df['score_category'] = df['score'].apply(lambda x: 'High' if x > 80 else 'Low')
# Save
df.to_csv('cleaned_data.csv', index=False)💡
Google Colab (colab.research.google.com) वापरा — free GPU/TPU, NumPy/Pandas/TF pre-installed, Jupyter notebook interface. AI experiments साठी perfect!
✅ Key Points — लक्षात ठेवा
- ▸NumPy: fast numerical arrays, matrix operations
- ▸Pandas: CSV/data loading, cleaning, manipulation
- ▸Google Colab: free GPU, no setup
- ▸df.info(), df.describe() — data explore करायला
- ▸Missing values: fillna() किंवा dropna()
0/11 chapters पूर्ण