5. Experiment the regression model with bias while approximating real life problems using UCI repository.
AIM
To experiment the regression model with model with bias while approximating real life problems using UCI repository.
ALGORITHM
Step1:Start the program.
Step2:Import all the required packages.
Step3: Generate random data for the feature ‘X’ and the target variable ‘y’ with a linear relationship and some noise.
Step4: Create a bias term by adding a column
Step5: Print Parameters
Step6: Display the plot showing the data points and the fitted linear regression line.
Step7: Stop the program.
PROGRAM
import numpy as np
import [Link] as plt
[Link](42)
X = 2 * [Link](100, 1)
y = 4 + 3 * X + [Link](100, 1)
X_bias = np.c_[[Link]((100, 1)), X]
theta_with_bias = [Link](X_bias.T @ X_bias) @ X_bias.T @ y
print("Intercept (bias):", theta_with_bias[0][0])
print("Slope:", theta_with_bias[1][0])
[Link](X, y)
[Link](X, X_bias @ theta_with_bias, color='red', linewidth=3)
[Link]("Linear Regression with Bias")
[Link]("X")
[Link]("y")
[Link]()
OUTPUT
Intercept (bias): 4.21509615754675
Slope: 2.7701133864384806
[Link] the regression model without bias while approximating real life problems using UCI repository
AIM
To experiment the regression model with model without bias while approximating real life problems using UCI
repository.
ALGORITHM
Step1: Stop the program.
Step2: Import all the necessary packages.
Step3: Generate a random number
Step4: Calculate linear regression without bias
Step5: Print parameter without bias
Step6: Create the scatter plot for the linear regression without bias
Step7: Stop the program
PROGRAM
import numpy as np
import [Link] as plt
[Link](42)
X = 2 * [Link](100, 1)
y = 4 + 3 * X + [Link](100, 1)
X_bias = np.c_[[Link]((100, 1)), X]
theta_without_bias = [Link](X.T @ X) @ X.T @ y
print("Slope:", theta_without_bias[0][0])
[Link](X, y)
[Link](X, X @ theta_without_bias, color='blue', linewidth=3)
[Link]("Linear Regression without Bias")
[Link]("X")
[Link]("y")
[Link]()
OUTPUT
Slope: 5.980275533687616
4. Demonstrate the analyses the 2 variable linear regression model
AIM
To demonstrate the analysis the 2 variable linear regression model.
ALGORITHM
Step1: Start the program
Step2: Import all the necessary packages required
Step3: Generate random data for the feature ‘X’ and the target variable ‘y’ with a linear relationship.
Step4: Visualize the relationship between ‘X’ and ‘y’.
Step5: Compute the correlation coefficient between ‘X’ and ‘y’.
Step6: Create a Linear Regression model and fit it using the generated data.
Step7: Plot the scatter plot with regression line.
Step8: Stop the program.
PROGRAM
import numpy as np
import [Link] as plt
import seaborn as sns
from sklearn.linear_model import LinearRegression
[Link](42)
X = 2 * [Link](100, 1)
y = 4 + 3 * X + 1.5 * [Link](100, 1)
[Link](X, y)
[Link]('Scatter Plot of X vs Y')
[Link]('X')
[Link]('Y')
[Link]()
correlation_coefficient = [Link]([Link](), [Link]())[0, 1]
print(f'Correlation Coefficient: {correlation_coefficient}')
[Link](x=[Link](), y=[Link](), kind='scatter')
[Link]()
model = LinearRegression().fit(X, y)
intercept, slope = model.intercept_[0], model.coef_[0][0]
print(f'Regression Equation: y = {intercept:.2f} + {slope:.2f} * x')
[Link](X, y)
[Link](X, [Link](X), color='red', linewidth=3)
[Link]('Linear Regression: Scatter Plot with Regression Line')
[Link]('X')
[Link]('Y')
[Link]()
OUTPUT
15. Experiment the ethical challenges while implementing a mobile robot using AI
AIM
To experiment the ethical challenges while implementing a mobile robot using AI.
ETHICAL CONSIDERATION
Ethical Considerations:
1. Privacy Concerns:
• Drones equipped with cameras can invade privacy. Ensure proper consent, adhere to privacy laws,
and implement features like geofencing to prevent drones from entering private spaces.
2. Safety Measures:
• Implement safety features to prevent collisions and injuries. Use obstacle detection systems and
follow airspace regulations to avoid accidents.
3. Data Security:
• Protect data collected by drones. Encrypt communication channels and storage to prevent
unauthorized access to sensitive information.
ALGORITHM
Step1: Start the program
Step2: Define the autonomous drone class
Step3: Define a method to take off and check the status if the drone is already flying.
Step4: Define a method land to simulate the landing.
Step5: Define a function’move to’ to simulate the drone to move to a particular location
Step6: Test the drone operation.
Step7: Stop the program.
PROGRAM
class AutonomousDrone:
def __init__(self):
[Link] = (0, 0, 0) # (x, y, z) coordinates
self.is_flying = False
def take_off(self):
if not self.is_flying:
print("Drone taking off.")
self.is_flying = True
else:
print("Drone is already flying.")
def land(self):
if self.is_flying:
print("Drone landing.")
self.is_flying = False
else:
print("Drone is not flying.")
def move_to(self, x, y, z):
if self.is_flying:
print(f"Drone moving to ({x}, {y}, {z}).")
[Link] = (x, y, z)
else:
print("Drone cannot move while not flying.")
drone = AutonomousDrone()
drone.take_off()
drone.move_to(10, 5, 2)
[Link]()
OUTPUT
Drone taking off.
Drone moving to (10, 5, 2).
Drone landing.
17. Experiment the Identification of ethical issues while building a Humanoid robot
AIM
To experiment the identification of ethical issues while building a humanoid robot.
ETHICAL CONSIDERATION:
1. Security Measures:
• Safeguard the humanoid robot against hacking or unauthorized access. Ensure robust cybersecurity
measures to protect user data and prevent misuse.
2. Task Appropriateness:
• Define ethical guidelines for the types of tasks the humanoid robot can perform. Avoid tasks that may
violate ethical standards or pose risks to users.
3. Informed Consent:
• Obtain informed consent from users before collecting personal data or performing tasks. Clearly
communicate the capabilities and limitations of the humanoid robot.
ALGORITHM
Step1: Start the program
Step2: Define the humanoid robot class
Step3: Define a method ‘power_on’ which simulates the robot to on state.
Step4: Define a method ‘power_off’ which simulates the robot to off state.
Step5: Define a function ‘perform_task that simulates the humanoid robot to perform certain tasks.
Step6: Test the robot’s performance.
Step7: Stop the program.
PROGRAM
import time
class HumanoidRobot:
def __init__(self):
self.power_level = 100
self.is_active = False
def power_on(self):
if not self.is_active:
print("Humanoid robot powering on.")
self.is_active = True
else:
print("Humanoid robot is already active.")
def power_off(self):
if self.is_active:
print("Humanoid robot powering off.")
self.is_active = False
else:
print("Humanoid robot is not active.")
def perform_task(self, task):
if self.is_active:
print(f"Humanoid robot performing task: {task}")
self.power_level -= 10
print(f"Power level remaining: {self.power_level}%")
else:
print("Humanoid robot cannot perform tasks while inactive.")
# Example Usage
robot = HumanoidRobot()
robot.power_on()
robot.perform_task("Assist with household chores")
[Link](2) # Simulating the passage of time
robot.power_off()
OUTPUT
Humanoid robot powering on.
Humanoid robot performing task: Assist with household chores
Power level remaining: 90%
Humanoid robot powering off.
1. Experiment the major medical ethical challenges facing the public and healthcare providers in India
AIM
To experiment the major medical ethical challenges facing the public and healthcare providers in India.
ETHICAL CONSIDERATION
[Link] to Healthcare:
• Challenge: There is a significant disparity in healthcare access between urban and rural areas. Rural
populations often face challenges in accessing quality healthcare services due to inadequate
infrastructure and a shortage of healthcare professionals.
2. Informed Consent:
• Challenge: Obtaining informed consent from patients, especially in rural areas and among those with
low health literacy, can be challenging. Patients may not fully understand the implications of medical
procedures or treatments.
3. Doctor-Patient Relationship:
• Challenge: Building and maintaining a trusting doctor-patient relationship can be challenging,
especially in a system where doctors are sometimes overburdened with large patient loads. Effective
communication and empathy may be compromised.
ALGORITHM
Step1: Start the program
Step2: Define HealthcareSystem class
Step3: Define a method named ‘request_treatment’ that simulates a patient requesting a specific treatment.
Step4: Test the HealthcareSystem
Step5: Stop the program
PROGRAM
class HealthcareSystem:
def __init__(self, resources):
[Link] = resources
def request_treatment(self, patient, treatment):
if [Link] >= 1:
print(f"Patient {patient} requests {treatment}.")
print("Treatment approved.")
[Link] -= 1
else:
print("Insufficient resources. Treatment denied.")
# Example Usage
healthcare_system = HealthcareSystem(resources=5)
healthcare_system.request_treatment("John Doe", "X-ray")
healthcare_system.request_treatment("Jane Smith", "MRI")
OUTPUT
Patient John Doe requests X-ray.
Treatment approved.
Patient Jane Smith requests MRI.
Treatment approved.
10. Experiment the Identification of ethical issues while building a Robot.
AIM
To experiment the identification of ethical issues while building a robot.
ETHICAL CONSIDERATION
[Link] the Robot's Purpose and Scope:
• Clearly define the purpose and scope of the robot's functionality. This includes understanding the
tasks it will perform and the environments in which it will operate.
2. Identify Potential Safety Hazards:
• List potential safety hazards associated with the robot's design, operation, and interaction with users.
Consider physical safety, collision avoidance, and emergency shutdown procedures.
3. Evaluate Data Privacy Concerns:
• Assess how the robot collects, stores, and processes data. Identify potential privacy concerns related
to data security, user information, and surveillance capabilities.
4. Consider Human-Robot Interaction:
• Evaluate how the robot interacts with humans. Consider issues related to transparency, explainability,
and the potential for bias or discrimination in decision-making algorithms.
ALGORITHM
Step1: Start the program
Step2: Define the robot class
Step3: Define methods power_on and power_off to simulate the robot's activation and deactivation.
Step4: Define methods enable_safety_mode and disable_safety_mode to simulate the activation and deactivation of
safety mode.
Step5: Test the robot functions.
Step6: Stop the program.
PROGRAM
class Robot:
def __init__(self, name):
[Link] = name
self.is_active = False
self.safety_mode = False
def power_on(self):
print(f"{[Link]} powering on.")
self.is_active = True
def power_off(self):
print(f"{[Link]} powering off.")
self.is_active = False
def enable_safety_mode(self):
print(f"{[Link]} safety mode enabled.")
self.safety_mode = True
def disable_safety_mode(self):
print(f"{[Link]} safety mode disabled.")
self.safety_mode = False
robot = Robot(name="RoboBot")
robot.power_on()
robot.enable_safety_mode()
robot.disable_safety_mode()
robot.power_off()
OUTPUT
RoboBot powering on.
RoboBot safety mode enabled.
RoboBot safety mode disabled.
RoboBot powering off.