Practical 7 Thsem
Practical 7 Thsem
Year : - 4th
Semester:- 7th
Branch: CSE-AIML
Subject: Machine Learning for Data Science
Experiment 1
conquer algorithm.
def max_number(arr):
if len(arr) == 1:
return arr[0]
else:
mid = len(arr) // 2
left_max = max_number(arr[:mid])
right_max = max_number(arr[mid:])
arr = [3, 7, 2, 9, 5, 8, 4, 1, 6]
result = max_number(arr)
randomization in algorithms.
import random
def shuffle_list(input_list):
shuffled_list = input_list[:]
random.shuffle(shuffled_list)
return shuffled_list
original_list = [1, 2, 3, 4, 5]
shuffled_result = shuffle_list(original_list)
randomization in algorithms.
class Graph:
def __init__(self):
self.graph = defaultdict(list)
self.graph[u].append(v)
queue = []
queue.append(start)
visited[start] = True
while queue:
start = queue.pop(0)
print(start, end=" ")
for i in self.graph[start]:
if not visited[i]:
queue.append(i)
visited[i] = True
# Create a graph
graph = Graph()
graph.add_edge(0, 1)
graph.add_edge(0, 2)
graph.add_edge(1, 2)
graph.add_edge(2, 0)
graph.add_edge(2, 3)
graph.add_edge(3, 3)
graph.bfs(2)
Experiment 4
class Node:
self.left = None
self.right = None
self.val = key
class BST:
def __init__(self):
self.root = None
if root is None:
return Node(key)
else:
return root
def search(self, root, key):
return root
# Example usage:
bst = BST()
root = None
bst.insert(root, 30)
bst.insert(root, 20)
bst.insert(root, 40)
bst.insert(root, 70)
bst.insert(root, 60)
bst.insert(root, 80)
else:
c = [-3, -5, -4] # Replace with actual coefficients for each gene
A=[
b = [20, 50] # Replace with actual upper bounds for each constraint
# Bounds for variables (expression of genes)
# Display results
if res.success:
else:
if target == 0:
return True
return False
# Example data
target = 22
if result:
else:
a sample dataset.
X, y = make_classification(n_samples=1000, n_features=10,
n_classes=2, random_state=42)
model = LogisticRegression()
model.fit(X_train, y_train)
y_pred = model.predict(X_test)
# Evaluating the model
print(f"Accuracy: {accuracy:.2f}")
# Classification report
print("Classification Report:")
print(classification_report(y_test, y_pred))
Experiment 8
data = load_iris()
X, y = data.data, data.target
model = LogisticRegression()
# Perform cross-validation
probabilistic model.
data = load_iris()
X, y = data.data, data.target
model = GaussianNB()
model.fit(X_train, y_train)
# Predict on the test data
y_pred = model.predict(X_test)
print(f"Accuracy: {accuracy:.2f}")
# Classification report
print("Classification Report:")
print(classification_report(y_test, y_pred))
Experiment 10
import pandas as pd
data = pd.read_csv('your_dataset.csv')
# Display the first few rows of the dataset to understand its structure
print("Initial Dataset:")
print(data.head())
imputer = SimpleImputer(strategy='mean')
data[numerical_columns] =
imputer.fit_transform(data[numerical_columns])
data['categorical_column'] =
label_encoder.fit_transform(data['categorical_column'])
scaler = StandardScaler()
data[numerical_columns] =
scaler.fit_transform(data[numerical_columns])
data = pd.read_csv('your_dataset.csv')
# Display the first few rows of the dataset to understand its structure
print("Initial Dataset:")
print(data.head())
imputer = SimpleImputer(strategy='mean')
data[numerical_columns] =
imputer.fit_transform(data[numerical_columns])
label_encoder = LabelEncoder()
data['categorical_column'] =
label_encoder.fit_transform(data['categorical_column'])
scaler = StandardScaler()
data[numerical_columns] =
scaler.fit_transform(data[numerical_columns])
data.to_csv('cleaned_dataset.csv', index=False)
Name : - Ayush Nautiyal
Year : - 4th
Semester:- 7th
Branch: CSE-AIML
Subject: Internet and Web Technology
Experiment 1
Describe the CSS, CSS2 with suitable example
CSS (Cascading Style Sheets) and CSS2 (CSS Level 2) are style sheet languages used
to describe the presentation of a document written in markup languages like HTML
and XML. CSS2 is an extension of CSS that introduced several new features and
capabilities. Here's an overview of both:
CSS allows developers to control the style and layout of HTML elements. It defines
how HTML elements should be displayed on a web page
<!DOCTYPE html>
<html>
<head>
<title>My Website</title>
<style>
/* CSS styles */
body {
background-color: #f0f0f0;
color: #333;
margin: 0;
padding: 20px;
}
h1 {
color: #0066cc;
p{
font-size: 16px;
line-height: 1.5;
</style>
</head>
<body>
<h1>Welcome to My Website</h1>
</body>
</html>
CSS2 introduced additional capabilities and expanded the styling options compared
to the original CSS. It added features like positioning, media types, improved
selectors, and more.
<!DOCTYPE html>
<html>
<head>
<title>My Website</title>
<style>
/* CSS2 styles */
div {
padding: 10px;
margin-bottom: 20px;
.highlight {
background-color: yellow;
#footer {
position: fixed;
bottom: 0;
width: 100%;
background-color: #333;
color: #fff;
padding: 10px;
text-align: center;
}
</style>
</head>
<body>
<div>
<h1>Welcome to My Website</h1>
</div>
<div id="footer">
</div>
</body>
</html>
Experiment 2
Describe the chatting components on the
internet.
Certainly! Chatting components on the internet refer to various elements and
technologies that enable communication between users in real-time or near real-
time. These components facilitate different forms of online communication, from
text-based conversations to audio and video interactions. Here are some key
components:
2. Communication Protocols:
Chat Widgets: Live chat functionality integrated into websites for customer support
and engagement.
Chat APIs and SDKs: Development tools and kits provided by various platforms to
integrate chat features into applications.
VoIP (Voice over Internet Protocol): Technologies like Skype, Zoom, and Google
Meet enable voice and video calls over the internet.
WebRTC (Web Real-Time Communication): A free, open-source project that
enables web browsers with real-time communication capabilities via simple APIs.
5. Chatbots and AI Assistants:
Social Media Platforms: Messaging components within social media networks like
Facebook, Twitter, Instagram, and LinkedIn enable communication among users.
8. Notification Systems:
Push Notifications: Alerts sent to users' devices to inform them about new
messages or interactions in chat applications.
These components collectively form the infrastructure and tools for various forms of
online communication, facilitating interactions between individuals, businesses,
teams, and communities on the internet. The advancements in these technologies
continue to shape and redefine how people connect and collaborate online
Experiment 3
Design a calculator using html, Java script & PHP
Language.
<!DOCTYPE html>
<html>
<head>
<title>Simple Calculator</title>
<style>
.calculator {
width: 200px;
padding: 10px;
input[type="button"] {
width: 40px;
height: 40px;
</style>
</head><body>
<div class="calculator">
<br>
<br>
<br>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>Hello, World!</h1>
</body>
</html>
Experiment 5
Create your login webpage for your college
website or
company
Web site.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Login</title>
</head>
<body>
<div class="login-container">
<div class="input-group">
<label for="username">Username</label>
<div class="input-group">
<label for="password">Password</label>
</div>
<button type="submit">Login</button>
</form>
</div>
</body>
</html>
body {
background-color: #f4f4f4;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.login-container {
background-color: #fff;
padding: 20px;
border-radius: 5px;
h2 {
text-align: center;
.input-group {
margin-bottom: 15px;
label {
display: block;
margin-bottom: 5px;
input[type="text"],
input[type="password"] {
width: 100%;
padding: 8px;
border-radius: 3px;
button {
width: 100%;
padding: 10px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 3px;
cursor: pointer;
button:hover {
background-color: #0056b3;
}
Experiment 6
Create the web page with the following
constraints
using HTML,CSS & PHP
(a) An image on the webpage.
(b) A hyperlink to college website
(c) a table of marks of AIML students.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<div class="header">
</div>
<div class="content">
<table>
<thead>
<tr>
<th>Student ID</th>
<th>Student Name</th>
<th>Marks</th>
</tr>
</thead>
<tbody>
<?php
$aiml_students = [
];
echo "<tr>";
echo "<td>$value</td>";
echo "</tr>";
?>
</tbody>
</table>
</div>
</body>
</html>
Experiment 7
Show blinking effect on web page using java
script.
<!DOCTYPE html>
<html>
<head>
<title>Blinking Effect</title>
<style>
.blinking-text {
font-size: 24px;
font-weight: bold;
</style>
</head>
<body>
<script>
function blink() {
setInterval(function() {
blinkText.style.visibility = (blinkText.style.visibility ==
'hidden') ? 'visible' : 'hidden';
</script>
</body>
</html>
Experiment 8
Design a digital clock on your web page using
javascript.
<!DOCTYPE html>
<html>
<head>
<title>Digital Clock</title>
<style>
.clock {
font-size: 36px;
font-weight: bold;
text-align: center;
margin-top: 100px;
}
</style>
</head>
<body>
<div class="clock" id="clock"></div>
<script>
function updateClock() {
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
document.getElementById('clock').innerText =
time;
}
<html>
<head>
<title>Simple Calculator</title>
</head>
<body>
<div class="calculator">
<br>
<button onclick="appendToDisplay('7')">7</button>
<button onclick="appendToDisplay('8')">8</button>
<button onclick="appendToDisplay('9')">9</button>
<button onclick="appendToDisplay('/')">/</button>
<br>
<button onclick="appendToDisplay('4')">4</button>
<button onclick="appendToDisplay('5')">5</button>
<button onclick="appendToDisplay('6')">6</button>
<button onclick="appendToDisplay('*')">*</button>
<br>
<button onclick="appendToDisplay('1')">1</button>
<button onclick="appendToDisplay('2')">2</button>
<button onclick="appendToDisplay('3')">3</button>
<button onclick="appendToDisplay('-')">-</button>
<br>
<button onclick="clearDisplay()">C</button>
<button onclick="appendToDisplay('0')">0</button>
<button onclick="calculate()">=</button>
<button onclick="appendToDisplay('+')">+</button>
</div>
<script>
function appendToDisplay(value) {
document.getElementById('display').value += value;
function clearDisplay() {
document.getElementById('display').value = '';
}
function calculate() {
document.getElementById('display').value = result;
</script>
</body>
</html>
Experiment 10
Design the any four pages of web site of your
college.
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<header>
<nav>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="courses.html">Courses</a></li>
<li><a href="about.html">About</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</nav>
</header>
<main>
<section>
</section>
<section>
<h2>Latest Events</h2>
</section>
</main>
<footer>
</footer>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<header>
</header>
<main>
<section>
<h2>Available Courses</h2>
<ul>
<li>Course 1</li>
<li>Course 2</li>
<li>Course 3</li>
</ul>
</section>
<section>
<h2>Course Details</h2>
</section>
</main>
<footer>
</footer>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<header>
</header>
<main>
<section>
<h2>About Us</h2>
</section>
<section>
<h2>Faculty Members</h2>
</section>
</main>
<footer>
</footer>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>College Name - Contact</title>
</head>
<body>
<header>
</header>
<main>
<section>
<h2>Contact Information</h2>
</section>
<section>
<h2>Get in Touch</h2>
</section>
</main>
</footer>
</body>
</html>