Professional Documents
Culture Documents
EX.NO:7 B
DATE:
Implement resolution strategies in First-order logic
AIM :
To develop a Python program for implementing resolution in First-order logic.
ALGORITHM:
1. Defines a class Clause that represents a logical clause containing a set of literals.
2. Takes a literal and negates it if it's not already negated (using the "not" prefix).
3. Takes two clauses and attempts to resolve them by finding complementary literals. It generates
resolvents by creating a new clause that includes all literals except for the complementary pair.
4.This function initializes a knowledge base with facts and a hypothesis to prove. It uses the
resolution rule in a loop, attempting to derive new clauses from existing ones until a contradiction
(empty clause) is found or no new clauses can be derived.
5. A list of facts in the knowledge base provided as input.
6. The prove_likes_peanut function aims to prove whether John likes peanuts (("likes", "john",
"peanut")) or not (("not", ("likes", "john", "peanut"))) based on the facts and resolution inference. If
it finds a contradiction (an empty clause), it concludes that John's liking or not liking peanuts is
true, depending on the contradiction found.
PROGRAM:
Class Clause:
Self.literals = set(literals)
Def __repr__(self):
Return f”Clause({self.literals})”
Def negate_literal(literal):
If literal[0] == “not”:
Return literal[1]
Else:
Resolvents = set()
Negated_literal = negate_literal(literal)
If negated_literal in clause2.literals:
Resolvent = Clause(
Resolvents.add(resolvent)
Return resolvents
Def prove_likes_peanut(facts):
Knowledge_base = [
# Hypothesis to be proved
# Resolution loop
While True:
New_clauses = set()
For I in range(len(knowledge_base)):
New_clauses.update(resolvents)
If Clause([]) in new_clauses:
Knowledge_base.extend(new_clauses)
Else:
Facts = [
Result = prove_likes_peanut(facts)
If result:
Else:
RESULT :
The Python program to implement resolution in first order logic was developed and
executed successfully.
EX.NO:10
DATE:
Implementation of policy search in Reinforcement learning
AIM :
To develop a Python program for implementing policy search in Reinforcement Learning.
ALGORITHM:
PROGRAM:
import numpy as np
import gym
class Policy:
def __init__(self, state_size, action_size):
self.weights = np.random.rand(state_size, action_size)
episode_states.append(state)
episode_actions.append(action)
episode_rewards.append(reward)
state = next_state
discounted_rewards = compute_discounted_rewards(episode_rewards)
episode_states = np.vstack(episode_states)
episode_actions = np.array(episode_actions)
total_reward = sum(episode_rewards)
print(f"Episode {episode + 1}/{num_episodes}, Total Reward: {total_reward}")
if __name__ == "__main__":
env = gym.make("CartPole-v1")
state_size = env.observation_space.shape[0]
action_size = env.action_space.n
RESULT :
The Python program to implement policy search in Reinforcement Learning was
EX.NO:
DATE:
PERSONAL BLOG MANAGEMENT
AIM
To create a dynamic and user-centric Personal blogging website using
MODULES
Dashboard Module:
• Personalized Interface:Upon successful login, redirects users to a personalized
dashboard where they can manage their blogging activities.
• Blog Management: Allows users to create new blog posts, providing text editors with
formatting options (e.g., bold, italics, images) to compose rich content. Enables editing,
updating, and deleting existing blog posts.
• Customization Options: Offers settings for users to manage their profiles, change
passwords, upload avatars, set preferences (e.g., theme, language), and manage other
personal information related to their accounts.
RESULT :
AIM:
To study the concepts of Big Data and NoSQL.
BIG DATA:
Big Data in DBMS represents a shift in how organizations handle data. It involves adopting
technologies and strategies that can cope with the challenges posed by the volume, velocity,
variety, and other characteristics of large and diverse datasets. Technologies such as Hadoop,
NoSQL databases, and distributed computing frameworks play a crucial role in addressing
these challenges and unlocking the potential value within Big Data.
• Volume
Regular databases work well with organized information in small amounts but
struggle with the immense data produced today. Big Data, on the other hand, manages
huge volumes, handling all types of data—organized, semi-organized, or
unorganized—using technologies like Hadoop and NoSQL databases.
• Velocity
Velocity in Big Data refers to the speed at which data is generated, processed, and
analyzed in real-time. Technologies like Apache Spark and stream processing
frameworks allow organizations to handle high-velocity data.
• Variety
Regular databases handle organized data but face challenges with messy or partially
organized information. Big Data deals with all types of data—organized, messy, or
partially organized. Databases like MongoDB and Cassandra in the Big Data world
are built to handle these different data types.
• Veracity
Veracity in Big Data refers to the quality and trustworthiness of the data. Data
cleansing and validation processes are crucial in Big Data systems to ensure accurate
and reliable insights.
• Value
The ultimate goal of Big Data is to extract valuable insights from large and diverse
datasets. Technologies like data lakes and advanced analytics tools help organizations
derive meaningful value from their data.
• Scalability
Regular databases can be hard and costly to scale. Increasing power on a single
Roll No:2127220502005 Page |
machine (vertical scaling) has limits. Big Data tech is built for horizontal scalability.
Horizontal scalability is more flexible and can handle increased demand by adding
more machines, making it a preferred approach for large-scale systems.
• Flexibility
Regular databases need a fixed structure called a schema, which can be tough to
change when the data structure evolves. In Big Data, NoSQL databases are common,
offering flexibility without a fixed schema. They handle changes in data structures
seamlessly.
• Distributed Computing
Regular databases might use a single-server setup, restricting their capacity to spread
computing tasks. In Big Data, solutions use distributed computing, managing data
processing and analysis across numerous nodes or clusters. This ensures efficient
resource use.
Case Study
TechTrends is an online e-commerce platform that sells a variety of tech gadgets and
electronic devices. The company has been experiencing significant growth in customer
transactions and data volume.
Challenges:
• Data Volume: Traditional database struggles with growing customer data (purchases,
browsing, reviews).
• Real-time Analytics: TechTrends aims for instant insights into customer behavior for
personalized recommendations and improved marketing.
• Data Variety: Handling diverse data types – structured (profiles, transactions) and
unstructured (reviews, social interactions).
NoSQL:
NoSQL, which stands for "Not Only SQL," is a category of database systems that depart from
the traditional relational database management system (RDBMS) model. NoSQL databases
are designed to handle diverse and dynamic data types, offering flexibility and scalability
beyond what traditional relational databases provide.
A thriving e-commerce platform, dealing with a burgeoning customer base, faces critical data
challenges with its traditional database system. The need for handling diverse data, scalability
concerns, and the aspiration for real-time insights drive the decision to explore advanced
database solutions.
Challenges
• Data Variety: The e-commerce giant manages a wealth of data types, ranging from
customer profiles and purchase history to reviews and clickstream data. The existing
traditional databases struggle to efficiently handle this diverse mix, impacting data
processing speed and adaptability.
• Scalability Issues: As the customer base expands, the traditional database encounters
challenges in scaling horizontally. This leads to performance bottlenecks during peak
times, affecting the user experience and potentially hindering business growth.
• Real-time Analytics: The company recognizes the growing importance of real-time
insights. To stay competitive, they aim to understand customer behavior instantly,
facilitating personalized recommendations and targeted marketing strategies for a
more dynamic and responsive customer experience..
Results
• Efficient Data Handling: The NoSQL database efficiently manages diverse data
types, overcoming the limitations of traditional databases. This ensures smoother data
processing and improved adaptability to evolving data structures.
• Scalability Success: The transition to a scalable cloud infrastructure resolves
horizontal scaling issues. The platform can now seamlessly expand to accommodate
the growing customer base, preventing performance bottlenecks during peak usage.
• Real-time Customer Insights: The implementation of real-time analytics provides
the company with immediate insights into customer behavior. This translates into the
ability to offer personalized recommendations and execute targeted marketing
strategies in real-time, enhancing the overall customer experience.