CCS350 - Knowledge Engineering Lab Manual Record
CCS350 - Knowledge Engineering 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
theengineering 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 basics of Knowledge Engineering.
CO2: Apply methodologies and modelling for Agent Design and Development.
CO3: Design and develop ontologies.
CO4: Apply reasoning with ontologies and rules.
CO5: Understand learning and rule learning.
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 1 1 1 1 - - 1 2 1 2 1 1 1
CO-2 3 2 3 2 2 - - 2 1 2 1 3 3 1
-
CO-3 2 2 3 2 2 - - 3 2 2 2 3 2 3
-
CO-4 2 2 3 1 1 - - - 2 2 2 2 2 1 1
CO-5 2 2 2 1 1 - - - 2 1 1 1 2 1 1
Avg 2.4 1.8 2.4 1.4 1.4 0.2 0 0 2 1.6 1.6 1.6 2.2 1.6 1.4
COURSE OBJECTIVES:
● To understand the basics of Knowledge Engineering.
● To discuss methodologies and modeling for Agent Design and Development.
● To design and develop ontologies.
● To apply reasoning with ontologies and rules.
● To understand learning and rule learning.
LIST OF EXPERIMENTS:
1. Perform operations with Evidence Based Reasoning.
2. Perform Evidence based Analysis.
3. Perform operations on Probability Based Reasoning.
4. Perform Believability Analysis.
5. Implement Rule Learning and refinement.
6. Perform analysis based on learned patterns.
7. Construction of Ontology for a given domain.
TABLE OF CONTENTS
Aim:
Algorithm:
Data Preparation:
• Import the necessary libraries, such as pandas for data handling and Scikit-Learn
for machine learning.
• Load the dataset from a CSV file into a Data Frame (data).
• Split the dataset into features (X) and the target variable (y).
• Further split the data into training and testing sets using the train_test_split
function from Scikit-Learn. Typically, you use about 80% of the data for training
and 20% for testing.
Model Selection:
• Choose a machine learning model suitable for the problem. In this case, a
Random Forest Classifier is selected. Random forests are an ensemble
learning method used for classification tasks.
Model Training:
• Train the selected model (Random Forest Classifier) using the training
data (X_train and y_train) by calling the fit method on the model instance.
Model Evaluation:
• Use the trained model to make predictions (y_pred) on the test data (X_test).
• Calculate the accuracy of the model's predictions by comparing them to the true
labels (y_test). The accuracy score is a common metric for classification tasks and
is calculated using the accuracy_score function from Scikit-Learn.
• Print the accuracy score to evaluate the model's performance.
Inference or Prediction:
• Load new data from a CSV file into a Data Frame (new_data) to make
predictions on unseen data.
• Use the trained model to predict the target variable for the new data and store the
predictions in the predictions variable.
• You can further process or analyze these predictions as needed for your
application.
Program:
import pandas as pd
from sklearn.model_selection import train_test_split
data = pd.read_csv("your_data.csv")
X = data.drop("target_column", axis=1)
y = data["target_column"]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
from sklearn.ensemble import RandomForestClassifier
model = RandomForestClassifier(n_estimators=100, random_state=42)
model.fit(X_train, y_train)
from sklearn.metrics import accuracy_score
y_pred = model.predict(X_test)
accuracy = accuracy_score(y_test, y_pred)
print("Accuracy:", accuracy)
new_data = pd.read_csv("new_data.csv") # Load new evidence-based data
predictions = model.predict(new_data)
Data set:
Output:
Accuracy: 0.85
Result:
Thus the performance of operation with evidence based model had been
successfully implemented and the output is also verified.
EX.NO:2
Aim:
To performance of evidence based Analysis using Python.
Algorithm:
Data Collection:
• Load data from a CSV file (in this case, 'your_data.csv') into a Pandas DataFrame.
The data represents the information you want to analyze.
Data Preprocessing:
• This section is a placeholder for data cleaning, normalization, and transformation.
You would customize this part to suit your specific dataset and analysis needs.
Common preprocessing steps include handling missing values, encoding
categorical data, and scaling numerical features.
EDA (Exploratory Data Analysis):
• Visualize your data using a pairplot created with Seaborn. EDA is essential for
understanding the data's characteristics and relationships between variables.
Hypothesis Testing:
• Conduct a statistical test (t-test in this example) to assess whether there is a
significant difference between two groups (group1 and group2). The result of the
test includes the test statistic and p-value.
Machine Learning:
• Train a linear regression model to predict a target variable using features 'feature1'
and 'feature2'. Evaluate the model's performance on a test set by calculating the
mean squared error (MSE).
Statistical Analysis:
• This section is a placeholder for additional statistical analyses you may need based
on your research or analysis objectives. You should insert specific statistical tests
and analyses here.
Data Visualization:
• Create informative plots and charts to present the data and analysis results
visually. This section is a placeholder for adding the appropriate visualizations for
your analysis.
Reporting and Documentation:
• Document your analysis process and results. Effective documentation is crucial for
sharing your findings and insights with others.
Program:
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
np.random.seed(42)
X = 2 * np.random.rand(100, 1)
y = 4 + 3 * X + np.random.randn(100, 1)
plt.scatter(X, y, alpha=0.5)
plt.title('Generated Data for Linear Regression')
plt.xlabel('X')
plt.ylabel('y')
plt.show()
model = LinearRegression()
model.fit(X, y)
X_new = np.array([[0], [2]])
y_pred = model.predict(X_new)
plt.scatter(X, y, alpha=0.5)
plt.plot(X_new, y_pred, color='red', linewidth=2, label='Linear Regression')
plt.title('Linear Regression Analysis')
plt.xlabel('X')
plt.ylabel('y')
plt.legend()
plt.show()
print(f'Intercept: {model.intercept_[0]}')
print(f'Coefficient: {model.coef_[0][0]}')
Output:
Result:
Thus the performance of evidence based Analysis had been successfully
implemented and the output is also verified.
EX.NO:3
Aim:
To performance operation on probability based reasoning using Python.
Algorithm:
Normal Distribution
• Define the parameters for a normal distribution operation.
• Use the norm.cdf function from scipy.stats to calculate the cumulative
probability.
• Display the result.
Conditional Probability
• Define the probabilities and apply Bayes' theorem to calculate conditional
probability.
• Display the conditional probability result.
Random Sampling
• Define a population and sample size.
• Use the np.random.choice function from numpy to simulate random
sampling.
• Display the random sample.
Program:
import numpy as np
from scipy.stats import binom, norm
n=3
p = 0.5
k=2
probability = binom.pmf(k, n, p)
print(f"Probability of getting exactly {k} heads in {n} coin flips: {probability:.4f}")
z=1
cumulative_probability = norm.cdf(z)
print(f"Cumulative Probability (Z < {z}): {cumulative_probability:.4f}")
P_A = 0.4
P_B_given_A = 0.3
P_A_given_B = (P_B_given_A * P_A) / P_B_given_A
print(f"Conditional Probability P(A|B): {P_A_given_B:.4f}")
population = [1, 2, 3, 4, 5]
sample_size = 3
random_sample = np.random.choice(population, size=sample_size, replace=True)
print(f"Random Sample: {random_sample}")
Output:
Random Sample: [3 5 2]
Result:
Thus the performance of operation on probability based reasoning had been
successfully implemented and the output is also verified.
EX.NO:4
Aim:
To perform Believability Analysis using Python.
Algorithm:
import nltk
from nltk.sentiment.vader
import SentimentIntensityAnalyzer
import requests
from bs4 import BeautifulSoup
nltk.download('vader_lexicon')
sid = SentimentIntensityAnalyzer()
def analyze_believability(text):
sentiment_scores = sid.polarity_scores(text)
believability = 1.0 - sentiment_scores['neg']
return believability
def analyze_source_credibility(url):
try:
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
source_credibility = 0.7
return source_credibility
except Exception as e:
print(f"Error fetching or analyzing the source: {e}")
return None
if name == " main ":
text = "This is a sample text that you want to analyze for believability."
source_url = "https://www.example.com/sample-article"
believability_score = analyze_believability(text)
source_credibility_score = analyze_source_credibility(source_url)
if believability_score is not None and source_credibility_score is not None:
final_believability_score = (believability_score + source_credibility_score) / 2
print(f"Believability Score: {final_believability_score}")
else:
print("Unable to calculate believability due to errors.")
Output:
Result:
Thus the performance of Believability Analysis had been successfully
implemented and the output is also verified.
EX.NO:5
Aim:
To Implement the Rule Learning and Refinement using Python.
Algorithm:
data = load_iris()
X = data.data
y = data.target
clf = DecisionTreeClassifier()
clf.fit(X_train, y_train)
y_pred = clf.predict(X_test)
clf.fit(X_train, y_train)
y_pred = clf.predict(X_test)
refined_accuracy = accuracy_score(y_test, y_pred)
Result:
Thus the Performance of Rule Learning and Refinement had been successfully
implemented and the output is also verified.
EX.NO:6
Aim:
To perform the analysis based on Learned Pattern using Python.
Algorithm:
Data Collection:
Gather and collect the dataset relevant to your analysis. Ensure that the data is
clean, well-structured, and contains the necessary information for pattern discovery.
Data Preprocessing:
Handle missing data by imputing or removing it as appropriate.
Normalize or scale numerical features to ensure they are on a similar scale.
Encode categorical variables into numerical values.
Handle outliers by either removing them or transforming them.
Data Split:
Split the dataset into a training set and a testing/validation set. The training set is
used to learn patterns, and the testing set is used to evaluate the model's performance.
Pattern Learning:
• Choose an appropriate machine learning algorithm, such as decision trees,
random forests, neural networks, or clustering algorithms, depending on the type
of analysis you want to perform.
• Train the selected model on the training data.
Model Evaluation:
Evaluate the model's performance on the testing/validation dataset. Common
evaluation metrics include accuracy, precision, recall, F1-score, and ROC-AUC,
depending on the nature of your analysis (classification, regression, clustering, etc.).
Pattern Interpretation:
• Analyze the patterns learned by the model. This may involve examining
feature importance, decision boundaries, or cluster assignments.
• Visualize the patterns using techniques like heatmaps, scatter plots, or
dimensionality reduction methods.
Iterate:
If the initial analysis does not meet your objectives, consider iterating
through the process, adjusting hyperparameters, trying different algorithms, or
collecting more data.
Deployment:
• If the analysis meets your goals, deploy the model to make predictions or
inform decision-making.
• Create a report or visualization summarizing the analysis, including key
insights, patterns, and recommendations, if applicable.
Program:
import numpy as np
from sklearn.linear_model import LinearRegression
model = LinearRegression()
model.fit(study_hours, exam_scores)
predicted_scores = model.predict(study_hours)
plt.xlabel('Study Hours')
plt.ylabel('Exam Scores')
plt.legend()
plt.show()
Output:
Result:
Thus the Performance of analysis based on Learned Pattern had been successfully
implemented and the output is also verified.
EX.NO:7
Aim:
To perform the construction of ontology for a given domain.
Algorithm:
3. Define Namespace:
Define namespaces for your ontology. Namespaces are used to create URIs for
classes, properties, and individuals.
4. Define Classes:
Define classes in your ontology using RDF triples.
5. Define Properties:
Define properties (attributes or relations) for your classes, if necessary.
6. Define Individual:
Define individuals (instances) and specify their types by adding triples.
7. Specify Relationship:
Establish relationships between individuals and properties.
Result:
Thus the Construction of Ontology for a given domain had been successfully
implemented and the output is also verified.