5. Self-supervised Learning: A method where the model generates its own labels from the input data.
Applications of ML:
• Image Recognition: Used in facial recognition systems, object detection, and medical imaging.
• Natural Language Processing (NLP): ML models are used in speech recognition, translation, and
chatbots. Recommendation Systems: ML is used in services like Netflix and Amazon to recommend
movies or products based on past behavior.
• Autonomous Vehicles: ML is essential for self-driving cars to navigate and make decisions in realtime.
• Predictive Analytics: In business, finance, and healthcare, ML helps in predicting trends, customer
behavior, and disease outbreaks.
Challenges in Machine Learning:
• Data Quality: Poor quality data can lead to inaccurate predictions.
• Overfitting: A model that is too complex may perform well on training data but fail to generalize to new
data.
• Interpretability: Some ML models, especially deep learning models, are often referred to as "black
boxes" because it's difficult to interpret how they make decisions.
• Ethical Concerns: The use of ML can lead to biases in decision-making, privacy issues, and fairness
concerns.
Common Algorithms and Techniques
• Linear Regression: A simple algorithm used for predicting continuous values (e.g., predicting house
prices based on features like size and location).
• Logistic Regression: A classification algorithm used to predict binary outcomes (e.g., determining
whether an email is spam or not).
• Decision Trees: A tree-like model used for both classification and regression tasks. It splits the data into
branches based on decision rules.
• K-Means Clustering: An unsupervised algorithm that groups similar data points into clusters.
• Neural Networks: Inspired by the human brain, these models are especially good for complex tasks like
image recognition, speech recognition, and language processing.
9
Program 1:
AIM: Develop a program to create histograms for all numerical features and analyze the distribution
of each feature. Generate box plots for all numerical features and identify any outliers. Use California
Housing dataset.
Source code:
import pandas as pd
import numpy as np
import seaborn as sns
import [Link] as plt
from [Link] import fetch_california_housing
# Step 1: Load the California Housing dataset
data = fetch_california_housing(as_frame=True)
housing_df = [Link]
# Step 2: Create histograms for numerical features
numerical_features = housing_df.select_dtypes(include=[[Link]]).columns
# Plot histograms
[Link](figsize=(15, 10))
for i, feature in enumerate(numerical_features):
[Link](3, 3, i + 1)
[Link](housing_df[feature], kde=True, bins=30, color='blue')
[Link](f'Distribution of {feature}')
plt.tight_layout()
[Link]()
# Step 3: Generate box plots for numerical features
[Link](figsize=(15, 10))
for i, feature in enumerate(numerical_features):
[Link](3, 3, i + 1)
[Link](x=housing_df[feature], color='orange')
[Link](f'Box Plot of {feature}')
plt.tight_layout()
10
[Link]()
# Step 4: Identify outliers using the IQR method
print("Outliers Detection:")
outliers_summary = {}
for feature in numerical_features:
Q1 = housing_df[feature].quantile(0.25)
Q3 = housing_df[feature].quantile(0.75)
IQR = Q3 - Q1
lower_bound = Q1 - 1.5 * IQR
upper_bound = Q3 + 1.5 * IQR
outliers = housing_df[(housing_df[feature] < lower_bound) | (housing_df[feature] > upper_bound)]
outliers_summary[feature] = len(outliers)
print(f"{feature}: {len(outliers)} outliers")
#Print a summary of the dataset
print("\nDataset Summary:")
print(housing_df.describe())
Output:
11
12