Posts

What is Set in Python?

 A set is a data structure used to store multiple unique values in a single variable . No Duplicate Values. Example numbers = {10, 20, 30, 40} names = {"Kavi","Arjun","Ashok"} Sets do not store values by index . The items are not ordered , so you cannot access values using position. names = {"kavi","arjun","akash"} print([0]) It does not work because Sets dont have Index numbers. Sets do not allow duplicate values . even if you input duplicate values, output will always have unique values. numbers = {10, 20, 20, 30, 30, 40} print(numbers) Output will contain only unique values . Sets are changeable (mutable) . You can add or remove values . numbers = {10, 20, 30} numbers.add(40) numbers.remove(10) print(numbers)

What is Dictionary in Python?

 A dictionary is a data structure used to store data as key–value pairs . One is Keyword and another is Value for that keyword. Example: person = {"name": "Manoj", "age": 15, "city": "Chennai"} Values in a dictionary are accessed using keys instead of index numbers . person = {"name": "Mohan", "age": 25, "city": "Chennai"} print(person["name"]) It will print the value for the key "name" . Dictionaries are changeable (mutable) . You can update old values with new values using the key. person = {"name": "Raj", "age": 25} person["age"] = 30 print(person) A dictionary can also store different data types in the same structure . person = {"name": "Kavi", "age": 25, "height": 175.5, "is_employee": True}

What is Tuple in python?

 A tuple is a data structure used to store multiple values in a single variable , similar to a list. Example:  numbers = (10, 20, 30, 40) names = ("Kavi","Arjun","Ashok") Values are arranged by index number starting from 0 . You can print a value based on its position / index . names = ("kavi","arjun","akash") print(names[0]) It will print the 0 index value of the names tuple . Tuples are not changeable (immutable) . Once a tuple is created, the values cannot be modified . person_details = ("John", 25, "Europe") You cannot update a value like we do in a list. A tuple can also store different data types like List. person_details = ("John", 25, 76.5, True)

What is List in Python?

 A list is a data structure used to store multiple values in a single variable . Example: numbers = [10, 20, 30, 40] names = ["Kavi","Arjun","Ashok" Values are arranged by index number starting from 0. You can print a value based on its position / index. names = ["kavi","arjun","akash"] print(names[0]) It will print the 0 index value of names list.  Lists are changeable (mutable). You can update the old value with new value in List using index number. person_details = ["John", 25, "Europe"] person_details[1]= 26 print(person_details) Can store different data types in the same list person_details = ["John", 25, 76.5, True]

Gen AI Chat Bot Python Project using Sentence transformer model all-MiniLM-L6-v2

Step 1 – Import libraries needed for text encoding, similarity calculation, and chatbot interface. SentenceTransformer – Converts sentences into numerical vectors so machines can understand the meaning of text. scikit-learn (cosine_similarity) – Calculates similarity between two text vectors to find how closely related they are. NumPy – Used for numerical computing, arrays, matrices, and fast mathematical operations. Pandas – U sed for handling datasets in table format such as reading data, filtering, cleaning, and manipulating rows and columns. ipywidgets – Creates interactive UI elements like text boxes, buttons, sliders, and dropdowns in notebook environments. IPython.display – Displays widgets, HTML, images, and formatted output inside notebooks. Step 2 – Loading the model – SentenceTransformer loads the model "all-MiniLM-L6-v2" which converts sentences into numerical embeddings. Step 3 – Creating product data – A dictionary is created with product names and product de...

Loop based Math Chat Agent in Python

print ( "🤖 Simple AI Chat Agent" ) print ( "Type 'exit' anytime to stop\n" ) #creating empty list to store the chats later chat_history = [] #creating function for mathematical calculations since its a math chat agent def calculations ( expression ):     try :         result = eval (expression)         return f "The answer is {result} "     except :         return "I couldn’t understand that.please use numbers instead of letters" #creating function for storing message, how and what to respond def chatrespond ( usermessage ):     usrmsg = usermessage.lower()     chat_history.append(usermessage)     # Greetings - when user says hello     if "hello" in usrmsg or "hi" in usrmsg:         return "Hello! How can I help you?"     # when user asks How are you     if "how are you" in usrmsg:         retu...

Polynomial Regression Python Code - Loan Default Prediction

Image
Import necessary libraries import pandas import numpy import matplotlib.pyplot from sklearn.linear_model import LinearRegression from sklearn.preprocessing import PolynomialFeatures Importing data into project data = pandas.read_csv('loan_default_rate_dataset.csv') print(data) Assign Input Columns to X variable and Output column to Y Variable x = data[['Credit_Score','Annual_Income','Loan_Amount']] y = data['Loan_Default_Probability'] Importing Polynomial Features to do cross connections, squares in x data. So data will expand and model can learn unpredictable patterns poly = PolynomialFeatures(degree=2) training the X variable using the polynomial feature. So it will do cross connections, squares in x data and learn the complex patterns. x_poly = poly.fit_transform(x) Now, since we learned the complex patterns and expanded the x values into x_poly variable, we can do linear regression from the Polynomial X data and Y data. model = LinearRegres...