Ccs337 - Cognitive Science Laboratory Lab Manual Record
Ccs337 - Cognitive Science Laboratory Lab Manual Record
PETER'S
COLLEGE OF ENGINEERING & TECHNOLOGY
(An Autonomous Institution)
RECORD NOTEBOOK
NAME :
REG.NO :
BRANCH :
YEAR/SEM :
2024-2025
St. PETER'S
COLLEGE OF ENGINEERING & TECHNOLOGY
(An Autonomous Institution)
Bonafide Certificate
NAME………………………………………………………………………..………………….
YEAR………………………………………..SEMESTER…………..……………………......
BRANCH……………………………………………………...………..………….....................
Certified that this bonafide record work done by the above student of the
during the year 2024 – 2025.
INSTITUTION VISION
To emerge as an Institution of Excellence by providing High Quality Education in Engineering,
Technology and Management to contribute for the economic as well as societal growth of our Nation.
INSTITUTION MISSION
• To impart strong fundamental and Value-Based Academic knowledge in various Engineering,
Technology and Management disciplines to nurture creativity.
• To promote innovative Research and Development activities by collaborating with Industries,
R&D organizations and other statutory bodies.
• To provide conducive learning environment and training so as to empower the students with
dynamic skill development for employability.
• To foster Entrepreneurial spirit amongst the students for making a positive impact on remark able
community development.
DEPARTMENT OF INFORMATION TECHNOLOGY
VISION
To emerge as a center of academic excellence to meet the industrial needs of the competitive
world with IT technocrats and researchers for the social and economic growth of the country in the
areaof Information Technology
MISSION
• To provide quality education to the students to attain new heights in IT industry and research
• To create employable students at national/international level by training them with adequate
skills
• To produce good citizens with high personal and professional ethics to serve both the IT
industry and society.
• Demonstrate technical competence with analytical and critical thinking to understand and meet the
diversified requirements of industry, academia and research.
• Exhibit technical leadership, team skills and entrepreneurship skills to provide business solutionsto
real world problems.
• Work in multi-disciplinary industries with social and environmental responsibility, work ethics and
adaptability to address complex engineering and social problems
• Pursue lifelong learning, use cutting edge technologies and involve in applied research to design
Optimal solutions.
2. Problem analysis: Identify, formulate, review research literature, and analyze complex engineering
problems reaching substantiated conclusions using first principles of mathematics, natural sciences,
and engineering sciences.
3. Design/development of solutions: Design solutions for complex engineering problems and design
system components or processes that meet the specified needs with appropriate consideration for the
public health and safety, and the cultural, societal, and environmental considerations
4. Conduct investigations of complex problems: Use research-based knowledge and research methods
including design of experiments, analysis and interpretation of data, and synthesis of the information
to provide valid conclusions.
5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modeling to complex engineering activities withan
understanding of the limitations.
6. The engineer and society: Apply reasoning informed by the contextual knowledge to assess societal,
health, safety, legal and cultural issues and the consequent responsibilities relevant to the professional
engineering practice.
7. Environment and sustainability: Understand the impact of the professional engineering solutions in
societal and environmental contexts, and demonstrate the knowledge of, and need B.TECH.
INFORMATION TECHNOLOGY 2 for sustainable development.
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of
the engineering practice.
9. Individual and team work: Function effectively as an individual, and as a member or leader in diverse
teams, and in multidisciplinary settings.
10. Communication: Communicate effectively on complex engineering activities with the engineering
community and with society at large, such as, being able to comprehend and write effective reports
and design documentation, make effective presentations, and give and receive clear instructions.
11. Project management and finance: Demonstrate knowledge and understanding of the engineering and
management principles and apply these to one’s own work, as a member and leader in a team, to
manage projects and in multidisciplinary environments
12. Life-long learning: Recognize the need for, and have the preparation and ability to engage in
independent and life-long learning in the broadest context of technological change
• Have proficiency in programming skills to design, develop and apply appropriate techniques, to
solve complex engineering problems.
• Have knowledge to build, automate and manage business solutions using cutting edge technologies.
COURSE OUTCOMES:
CO1:Understand the underlying theory behind cognition.
CO2:Connect to the cognition elements computationally.
CO3:Implement mathematical functions through WebPPL.
CO4:Develop applications using cognitive inference model.
CO5:Develop applications using cognitive learning model.
PO’s PSO’s
COs PO PO PO PO- PO- PO- PO- PO- PO- PO- PO- PO- PSO PSO PSO
-1 -2 -3 4 5 6 7 8 9 10 11 12 -1 -2 -3
CO- 1 3 1 3 2 2 - - - 1 1 2 2 1 2 2
CO-2 2 2 1 1 2 - - 3 2 3 1 2 3 2
-
CO-3 1 3 1 3 3 - - 1 3 1 3 3 1 2
-
CO-4 2 1 1 2 2 - - - 1 2 3 1 3 3 1
CO-5 1 2 3 2 2 - - - 1 2 2 2 2 2 1
Avg 1.8 1.8 1.8 2 2.4 - - - 1.4 2 2.2 1.8 2.2 2.2 1.6
COURSE OBJECTIVES:
• To know the theoretical background of cognition.
• To understand the link between cognition and computational intelligence.
• To explore probabilistic programming language.
• To study the computational inference models of cognition.
• To study the computational learning models of cognition.
LIST OF EXPERIMENTS:
1. Demonstration of Mathematical functions using WebPPL.
2. Implementation of reasoning algorithms.
3. Developing an Application system using generative model.
4. Developing an Application using conditional inference learning model.
5. Application development using hierarchical model.
6. Application development using Mixture model.
TABLE OF CONTENTS
Aim:
Algorithm:
• Use built-in WebPPL Math functions to compute exponentiation, square roots, logarithms, and
trigonometric values.
• Store the results in appropriate variables.
• Use the flip function in WebPPL to simulate a fair coin toss (with a 0.5 probability for heads or
tails).
• Use the display() function to print the results of all computations and probabilistic outcomes.
Program:
// 2. Exponentiation
var power = Math.pow(2, 3); // 2^3
display("2 to the power of 3: " + power);
// 3. Square Root
var sqrt = Math.sqrt(16); // √16
display("Square root of 16: " + sqrt);
// 4. Trigonometric Functions
var sinVal = Math.sin(Math.PI / 2); // Sin(90 degrees)
var cosVal = Math.cos(0); // Cos(0 degrees)
display("Sin(90 degrees): " + sinVal);
display("Cos(0 degrees): " + cosVal);
// 5. Logarithm
var logVal = Math.log(10); // Natural log of 10
display("Natural Log of 10: " + logVal);
// 6. Random Numbers
var randomNumber = Math.random(); // Random number between 0 and 1
display("Random Number: " + randomNumber);
Result:
Thus the demonstration of mathematical functions using WebPPL had been
successfully implemented and the output is also verified.
EX.NO:2
Aim:
To Implement the reasoning algorithms.
Algorithm:
1. Define Facts:
2. Store all parent-child relationships in a dictionary using tuples.
3. Key: Relationship type (e.g., "parent").
4. Value: A list of tuples representing relationships.
5. Create the find_siblings Function:
6. Input: The name of a person.
7. Logic:
8. Iterate through all parent-child pairs in the family dictionary.
9. Check for children with the same parent but different names.
10. Collect such children as siblings.
11. Output: A set of sibling names.
12. Create the find_grandparents Function:
13. Input: The name of a person.
14. Logic:
15. Iterate through all parent-child pairs to find the person's parent.
16. Use the parent’s name to find their parent (grandparent).
17. Collect such grandparents.
18. Output: A set of grandparent names.
19. Process the Queries:
20. Query for a specific person’s siblings by calling the find_siblings function.
21. Query for a specific person’s grandparents by calling the find_grandparents function.
22. Display Results:
23. Print the results of the queries for siblings and grandparents.
Program:
# Facts
family = {
"parent": [
("John", "Mary"),
("John", "Peter"),
("Susan", "Mary"),
("Susan", "Peter"),
("Mary", "James"),
("Mary", "Sophia"),
]
}
query2 = "James"
grandparents_of_query2 = find_grandparents(query2)
print(f"Grandparents of {query2}: {grandparents_of_query2}")
Output:
Result:
Thus the Implementation of reasoning algorithms had been successfully
implemented and the output is also verified.
EX.NO:3
Aim:
To develop an application system using generative model.
Algorithm:
2. Set Up Client: Initialize the chat client to handle input and output.
3. Define Function: Create a function to process user input and generate responses.
client= Client()
def generate_writing_prompt(user_input):
response=client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": user_input}],
)
returnresponse.choices[0].message.content
interface=gr.Interface(
fn=generate_writing_prompt,
inputs=gr.Textbox(lines=3, placeholder="Enter a genre, tone, or initial plot point..."),
outputs="text",
title="Creative Writing Assistant ",
description="Unleash your creativity! Get inspired with unique story ideas, prompts, and plot
twists.",
theme="huggingface",
examples=[
["A story about a lost civilization discovering technology."],
["Compose a poem about the changing seasons."],
["A suspense thriller set in an abandoned mansion."],
]
)
Result:
Thus the development of an application system using generative system
had been successfully implemented and the output is also verified.
EX.NO:4
Aim:
To Develop an application using conditional inference learning model.
Algorithm:
3. Splitting: At each step, split the dataset based on the feature that best separates the data
according to some criteria (e.g., Gini impurity, entropy).
4. Recursion: Recursively split the data until the stopping criteria are met (e.g., a leaf node with
a pure class or a maximum tree depth).
5. Output: A trained model (decision tree) that can predict class labels based on input features.
Program:
# Create and train the Decision Tree Classifier (a basic conditional inference model)
clf = DecisionTreeClassifier(random_state=42)
clf.fit(X_train, y_train)
# Calculate accuracy
accuracy = accuracy_score(y_test, y_pred)
print(f"Model Accuracy: {accuracy * 100:.2f}%")
plt.figure(figsize=(12, 8))
plot_tree(clf, filled=True, feature_names=data.feature_names, class_names=data.target_names)
plt.show()
Output:
Result:
Thus the Development of an application using conditional inference learning
model had been successfully implemented and the output is also verified.
EX.NO:5
Aim:
Algorithm:
1. Company name, department names, employee names and positions, and sub-department
structure.
2. Initialization
3. Create the company, departments, and employees.
4. Data Addition
5. Add employees to departments.
6. Add sub-departments to departments.
7. Display Hierarchy
8. Print the company name.
9. Print the departments, their employees, and any sub-departments.
10. Output
11. Display the hierarchical structure of the company, showing relationships between
def __repr__(self):
return f"Employee(name={self.name}, position={self.position})"
def __repr__(self):
return f"Department(name={self.name}, employees={len(self.employees)},
sub_departments={len(self.sub_departments)})"
def display_hierarchy(self):
print(f"Company: {self.name}")
self._display_departments(self.departments, indent=2)
def _display_departments(self, departments, indent):
for department in departments:
print(" " * indent + f"Department: {department.name}")
for employee in department.employees:
print(" " * (indent + 2) + f"Employee: {employee.name}, Position:
{employee.position}")
if department.sub_departments:
self._display_departments(department.sub_departments, indent + 2)
# Create a company
my_company = Company("Tech Innovators")
# Create departments
sales_department = Department("Sales")
hr_department = Department("Human Resources")
Result:
Thus the Application development using hierarchical model had been
successfullyimplemented and the output is also verified.
EX.NO:6
Aim:
Algorithm:
1. Generate Data
2. Use make_blobs from sklearn.datasets to generate synthetic data points with multiple clusters.
4. Fit a Gaussian Mixture model to the generated data to identify the underlying Gaussian
components in the data.
6. Use the trained GMM to predict the cluster labels of the data points.
9. For each Gaussian component, compute the covariance, eigenvalues, and eigenvectors, and
plot an ellipse representing the component.
11. Display the scatter plot with ellipses showing the Gaussian distributions for each component.
Program:
import numpy as np
import matplotlib.pyplot as plt
from sklearn.mixture import GaussianMixture
from sklearn.datasets import make_blobs
# Step 1: Generate synthetic data (3 clusters)
X, _ = make_blobs(n_samples=500, centers=3, random_state=42)
plt.show()
Output:
Result:
Thus the Development of an application using mixture model had been
successfully implemented and the output is also verified.