You are on page 1of 10

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 matplotlib.pyplot as plt

np.random.seed(42)

X = 2 * np.random.rand(100, 1)

y = 4 + 3 * X + np.random.randn(100, 1)

X_bias = np.c_[np.ones((100, 1)), X]

theta_with_bias = np.linalg.inv(X_bias.T @ X_bias) @ X_bias.T @ y

print("Intercept (bias):", theta_with_bias[0][0])

print("Slope:", theta_with_bias[1][0])

plt.scatter(X, y)

plt.plot(X, X_bias @ theta_with_bias, color='red', linewidth=3)

plt.title("Linear Regression with Bias")

plt.xlabel("X")

plt.ylabel("y")

plt.show()

OUTPUT

Intercept (bias): 4.21509615754675

Slope: 2.7701133864384806
6.Experiment 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 matplotlib.pyplot as plt

np.random.seed(42)

X = 2 * np.random.rand(100, 1)

y = 4 + 3 * X + np.random.randn(100, 1)

X_bias = np.c_[np.ones((100, 1)), X]

theta_without_bias = np.linalg.inv(X.T @ X) @ X.T @ y

print("Slope:", theta_without_bias[0][0])

plt.scatter(X, y)

plt.plot(X, X @ theta_without_bias, color='blue', linewidth=3)

plt.title("Linear Regression without Bias")

plt.xlabel("X")

plt.ylabel("y")

plt.show()

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 matplotlib.pyplot as plt

import seaborn as sns

from sklearn.linear_model import LinearRegression

np.random.seed(42)

X = 2 * np.random.rand(100, 1)

y = 4 + 3 * X + 1.5 * np.random.randn(100, 1)

plt.scatter(X, y)

plt.title('Scatter Plot of X vs Y')

plt.xlabel('X')

plt.ylabel('Y')

plt.show()

correlation_coefficient = np.corrcoef(X.flatten(), y.flatten())[0, 1]

print(f'Correlation Coefficient: {correlation_coefficient}')

sns.jointplot(x=X.flatten(), y=y.flatten(), kind='scatter')


plt.show()

model = LinearRegression().fit(X, y)

intercept, slope = model.intercept_[0], model.coef_[0][0]

print(f'Regression Equation: y = {intercept:.2f} + {slope:.2f} * x')

plt.scatter(X, y)

plt.plot(X, model.predict(X), color='red', linewidth=3)

plt.title('Linear Regression: Scatter Plot with Regression Line')

plt.xlabel('X')

plt.ylabel('Y')

plt.show()

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):

self.location = (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}).")

self.location = (x, y, z)

else:

print("Drone cannot move while not flying.")


drone = AutonomousDrone()

drone.take_off()

drone.move_to(10, 5, 2)

drone.land()

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")

time.sleep(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

1.Access 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):

self.resources = resources

def request_treatment(self, patient, treatment):

if self.resources >= 1:

print(f"Patient {patient} requests {treatment}.")

print("Treatment approved.")

self.resources -= 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

1.Define 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):

self.name = name

self.is_active = False

self.safety_mode = False

def power_on(self):

print(f"{self.name} powering on.")

self.is_active = True

def power_off(self):

print(f"{self.name} powering off.")

self.is_active = False
def enable_safety_mode(self):

print(f"{self.name} safety mode enabled.")

self.safety_mode = True

def disable_safety_mode(self):

print(f"{self.name} 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.

You might also like