[go: up one dir, main page]

0% found this document useful (0 votes)
27 views41 pages

Python Prac

Prc

Uploaded by

bivavah108
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views41 pages

Python Prac

Prc

Uploaded by

bivavah108
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

231263107050

EXPERIMENT NO: 1

1) Write a Python Program for checking whether the given number is an even
number or not.

PROGRAM:

def is_even(number):
return number % 2 == 0

try:
num = int(input("Enter a number: "))
if is_even(num):
print(f"{num} is an even number.")
else:
print(f"{num} is not an even number.")
except ValueError:
print("Please enter a valid integer.")

OUTPUT:

2) Write a Python Program to check leap year.

PROGRAM:

def is_leap_year(year):
return (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0)
try:
year = int(input("Enter a year: "))
if is_leap_year(year):
print(f"{year} is a leap year.")
else:
print(f"{year} is not a leap year.")
except ValueError:
print("Please enter a valid integer.")
231263107050

OUTPUT:

3) Write a Python Program to Check Prime Number

PROGRAM:

def is_prime(number):
if number <= 1:
return False
for i in range(2, int(number**0.5) + 1):
if number % i == 0:
return False
return True

try:
num = int(input("Enter a number: "))
if is_prime(num):
print(f"{num} is a prime number.")
else:
print(f"{num} is not a prime number.")
except ValueError:
print("Please enter a valid integer.")

OUTPUT:
231263107050

4) Write a Python program to check whether the given no is Armstrong or not.

PROGRAM:

def is_armstrong(number):
digits = str(number)
num_digits = len(digits)

armstrong_sum = sum(int(digit) ** num_digits for digit in digits)

return armstrong_sum == number

try:
num = int(input("Enter a number: "))
if is_armstrong(num):
print(f"{num} is an Armstrong number.")
else:
print(f"{num} is not an Armstrong number.")
except ValueError:
print("Please enter a valid integer.")

OUTPUT:

5) Write a Python Program to Find HCF.

PROGRAM:

def find_hcf(num1, num2):


while num2:
num1, num2 = num2, num1 % num2
return num1

try:
number1 = int(input("Enter the first number: "))
number2 = int(input("Enter the second number: "))
hcf = find_hcf(number1, number2)
231263107050

print(f"The HCF of {number1} and {number2} is {hcf}.")


except ValueError:
print("Please enter valid integers.")

OUTPUT:

6) Write a Python Program to Find LCM.

PROGRAM:

def find_hcf(num1, num2):


while num2:
num1, num2 = num2, num1 % num2
return num1

def find_lcm(num1, num2):


hcf = find_hcf(num1, num2)
lcm = abs(num1 * num2) // hcf # LCM formula: (num1 * num2) / HCF
return lcm

try:
number1 = int(input("Enter the first number: "))
number2 = int(input("Enter the second number: "))
lcm = find_lcm(number1, number2)
print(f"The LCM of {number1} and {number2} is {lcm}.")
except ValueError:
print("Please enter valid integers.")

OUTPUT:
231263107050

7) Write a Python Program to Add Two Matrices.

PROGRAM:

def add_matrices(matrix1, matrix2):


if len(matrix1) != len(matrix2) or len(matrix1[0]) != len(matrix2[0]):
raise ValueError("Matrices must have the same dimensions.")

result = [[0 for _ in range(len(matrix1[0]))] for _ in range(len(matrix1))]

for i in range(len(matrix1)):
for j in range(len(matrix1[0])):
result[i][j] = matrix1[i][j] + matrix2[i][j]

return result

try:
rows = int(input("Enter the number of rows: "))
cols = int(input("Enter the number of columns: "))

print("Enter the first matrix:")


matrix1 = []
for i in range(rows):
row = list(map(int, input(f"Row {i + 1}: ").split()))
matrix1.append(row)

print("Enter the second matrix:")


matrix2 = []
for i in range(rows):
row = list(map(int, input(f"Row {i + 1}: ").split()))
matrix2.append(row)

result_matrix = add_matrices(matrix1, matrix2)

print("The resulting matrix after addition is:")


for row in result_matrix:
print(row)

except ValueError as e:
print(f"Error: {e}")
231263107050

OUTPUT:

8) Write a Python program to generate list of Fibonacci number up to n Fibonacci


numbers.

PROGRAM:

def generate_fibonacci(n):
fibonacci_list = []
a, b = 0, 1 # Starting values for the Fibonacci sequence
for _ in range(n):
fibonacci_list.append(a)
a, b = b, a + b # Update to the next Fibonacci numbers
return fibonacci_list

try:
n = int(input("Enter the number of Fibonacci numbers to generate: "))
if n < 0:
print("Please enter a non-negative integer.")
else:
fibonacci_numbers = generate_fibonacci(n)
print(f"The first {n} Fibonacci numbers are: {fibonacci_numbers}")
except ValueError:
print("Please enter a valid integer.")
231263107050

OUTPUT:

9) Write a Python program to print all even numbers between 1 to 100 using while
loop.

PROGRAM:

number = 1

print("Even numbers between 1 and 100:")


while number <= 100:
if number % 2 == 0:
print(number)
number += 1 # Increment the number by 1

OUTPUT:
231263107050

10) Write a Python program to calculate factorial of a number

PROGRAM:

def factorial(n):
if n < 0:
return "Factorial is not defined for negative numbers."
elif n == 0 or n == 1:
return 1
else:
result = 1
for i in range(2, n + 1):
result *= i
return result

try:
num = int(input("Enter a number to calculate its factorial: "))
result = factorial(num)
print(f"The factorial of {num} is: {result}")
except ValueError:
print("Please enter a valid integer.")

OUTPUT:

11) Write a Python program takes in a number and finds the sum of digits in a
number.

PROGRAM:

def sum_of_digits(number):
total = 0
while number > 0:
231263107050

digit = number % 10 # Get the last digit


total += digit # Add it to the total
number //= 10 # Remove the last digit
return total

try:
num = int(input("Enter a number: "))
if num < 0:
print("Please enter a non-negative integer.")
else:
result = sum_of_digits(num)
print(f"The sum of digits in {num} is: {result}")
except ValueError:
print("Please enter a valid integer.")

OUTPUT:

12) Write a Python program that takes a number and checks whether it is a
palindrome or not.

PROGRAM:

def is_palindrome(number):
str_num = str(number)
return str_num == str_num[::-1] # Check if the string is the same forwards and
backwards

try:
num = int(input("Enter a number: "))
if is_palindrome(num):
print(f"{num} is a palindrome.")
else:
print(f"{num} is not a palindrome.")
except ValueError:
231263107050

print("Please enter a valid integer.")

OUTPUT:
231263107050

EXPERIMENT NO: 2

1) Write Python program for List:


a. Sum all the items in a list.
b. Multiplies all the items in a list.
c. Get the largest number from a list.
d. Get the smallest number from a list.
e. Reverse a list.
f. Find common items from two lists.
g. Select the even items of a list.

PROGRAM:

def sum_of_list(lst):
return sum(lst)

def multiply_list(lst):
product = 1
for item in lst:
product *= item
return product

def largest_number(lst):
return max(lst)

def smallest_number(lst):
return min(lst)

def reverse_list(lst):
return lst[::-1]

def common_items(list1, list2):


return list(set(list1) & set(list2))

def even_items(lst):
return [item for item in lst if item % 2 == 0]

list1 = [1, 2, 3, 4, 5, 6]
231263107050

list2 = [4, 5, 6, 7, 8, 9]

print("Sum of all items in list1:", sum_of_list(list1))


print("Product of all items in list1:", multiply_list(list1))
print("Largest number in list1:", largest_number(list1))
print("Smallest number in list1:", smallest_number(list1))
print("Reversed list1:", reverse_list(list1))
print("Common items between list1 and list2:", common_items(list1, list2))
print("Even items in list1:", even_items(list1))

OUTPUT:

2) Write Python program for Tuple:


a. Create a tuple and find the minimum and maximum number from it.
b. Find the repeated items of a tuple.
c. Print the number in words for Example: 1234 => One Two Three Four

PROGRAM:

def min_max_tuple(tup):
return min(tup), max(tup)

def repeated_items(tup):
count = {}
for item in tup:
count[item] = count.get(item, 0) + 1
return {item: cnt for item, cnt in count.items() if cnt > 1}

def number_to_words(num):
num_to_word = {
'0': 'Zero', '1': 'One', '2': 'Two', '3': 'Three',
231263107050

'4': 'Four', '5': 'Five', '6': 'Six', '7': 'Seven',


'8': 'Eight', '9': 'Nine'
}
return ' '.join(num_to_word[digit] for digit in str(num))

sample_tuple = (3, 5, 1, 4, 2, 5, 3)

min_val, max_val = min_max_tuple(sample_tuple)


print("Minimum value in the tuple:", min_val)
print("Maximum value in the tuple:", max_val)

repeats = repeated_items(sample_tuple)
print("Repeated items in the tuple:", repeats)

number = 1234
words = number_to_words(number)
print(f"Number {number} in words: {words}")

OUTPUT:

3) Write Python program for Set:


a. Create a set, add member(s) in a set and remove one item from set.
b. Perform following operations on set: intersection of sets, union of sets, set
difference, symmetric difference, clear a set.

PROGRAM:

def create_and_modify_set():
my_set = {1, 2, 3, 4, 5}
print("Initial set:", my_set)
231263107050

my_set.add(6)
my_set.add(7)
print("Set after adding members (6, 7):", my_set)

my_set.remove(4) # Remove 4 from the set


print("Set after removing 4:", my_set)

return my_set

def set_operations(set1, set2):


print("Set 1:", set1)
print("Set 2:", set2)

intersection = set1.intersection(set2)
print("Intersection of Set 1 and Set 2:", intersection)

union = set1.union(set2)
print("Union of Set 1 and Set 2:", union)

difference = set1.difference(set2)
print("Set Difference (Set 1 - Set 2):", difference)

symmetric_difference = set1.symmetric_difference(set2)
print("Symmetric Difference of Set 1 and Set 2:", symmetric_difference)

set1.clear()
print("Set 1 after clearing:", set1)

set1 = create_and_modify_set()

set2 = {4, 5, 6, 7, 8}

set_operations(set1, set2)
231263107050

OUTPUT:

4) Write Python program for Dictionary:


a. Sort (ascending and descending) a dictionary by value.
b. Concatenate following dictionaries to create a new one. Sample Dictionary: i.
dic1 = {1:10, 2:20} ii. dic2 = {3:30, 4:40} iii. dic3 = {5:50,6:60}
c. Print all unique values in a dictionary. Sample Data: [{"V":"S001"}, {"V":
"S002"}, {"VI": "S001"}, {"VI": "S005"}, {"VII":"S005"}, {"V":"S009"},
{"VIII":"S007"}] d. Find the highest 3 values in a dictionary.

PROGRAM:

def sort_dictionary_by_value(d):
sorted_asc = dict(sorted(d.items(), key=lambda item: item[1]))
sorted_desc = dict(sorted(d.items(), key=lambda item: item[1], reverse=True))
return sorted_asc, sorted_desc

def concatenate_dictionaries(*dictionaries):
result = {}
for d in dictionaries:
result.update(d)
return result

def unique_values(data):
values = set()
for entry in data:
values.add(next(iter(entry.values()))) return values

def highest_n_values(d, n=3):


231263107050

return sorted(d.values(), reverse=True)[:n]

sample_dict = {1: 10, 2: 20, 3: 30, 4: 5, 5: 25}

sorted_asc, sorted_desc = sort_dictionary_by_value(sample_dict)


print("Sorted dictionary by value (ascending):", sorted_asc)
print("Sorted dictionary by value (descending):", sorted_desc)

dic1 = {1: 10, 2: 20}


dic2 = {3: 30, 4: 40}
dic3 = {5: 50, 6: 60}
concatenated_dict = concatenate_dictionaries(dic1, dic2, dic3)
print("Concatenated dictionary:", concatenated_dict)

sample_data = [
{"V": "S001"}, {"V": "S002"}, {"VI": "S001"},
{"VI": "S005"}, {"VII": "S005"}, {"V": "S009"},
{"VIII": "S007"}
]
unique_vals = unique_values(sample_data)
print("Unique values in the dictionary:", unique_vals)

highest_values = highest_n_values(sample_dict)
print("Highest 3 values in the dictionary:", highest_values)

OUTPUT:
231263107050

EXPERIMENT NO: 3

1) Write a function find_longest_word() that takes a list of words and


returns the length of the longest one.

PROGRAM:

def find_longest_word(words):

if not words: # check if the list is empty

return 0

longest_word = max(words, key=len) # find the word with the maximum


length

return len(longest_word)

words_list = ['data', 'science', 'artificial', 'intelligence']

print(find_longest_word(words_list)) # Output will be 12

OUTPUT:

2) Write a Python program that counts the number of occurrences of the


character in the given string using function. Provide two
implementations: recursive and iterative.
PROGRAM:
231263107050

Iterative Implementation:

def count_char_iterative(string, char):

count = 0

for c in string:

if c == char:

count += 1

return count

string = "data science and artificial intelligence"

char = 'a'

print(f"Iterative count of '{char}':", count_char_iterative(string, char))

OUTPUT:

Recursive Implementation:

def count_char_recursive(string, char):

if not string: # Base case: if string is empty, return 0

return 0

return (1 if string[0] == char else 0) + count_char_recursive(string[1:], char)

string = "data science and artificial intelligence"

char = 'a'
231263107050

print(f"Recursive count of '{char}':", count_char_recursive(string, char))

OUTPUT:

3) Write a Python program to find reverse of given number using user


defined function.

PROGRAM:

def reverse_number(number):

reversed_num = 0

while number > 0:

digit = number % 10 # Get the last digit of the number

reversed_num = reversed_num * 10 + digit # Append the digit to the


reversed number

number = number // 10 # Remove the last digit from the original number

return reversed_num

num = int(input("Enter a number: "))

print(f"The reverse of {num} is: {reverse_number(num)}")


231263107050

OUTPUT:

4) Write a python program to implement is Palindrome () function to


check given string is palindrome or no.

PROGRAM:

def is_palindrome(string):

string = string.lower()

string = string.replace(" ", "")

return string == string[::-1]

user_input = input("Enter a string: ")

if is_palindrome(user_input):

print(f"'{user_input}' is a palindrome.")

Else:

print(f"'{user_input}' is not a palindrome.")


231263107050

OUTPUT:
231263107050

EXPERIMENT NO: 4

1) Write a Python program to create two matrices and perform addition,


subtraction, multiplication and division operation on matrix.

PROGRAM:

import numpy as np

def matrix_operations(A, B):

print("Matrix A:")

print(A)

print("Matrix B:")

print(B)

addition = A + B

print("\nAddition of matrices:\n", addition)

subtraction = A - B

print("\nSubtraction of matrices:\n", subtraction)

multiplication = A * B

print("\nElement-wise Multiplication of matrices:\n", multiplication)

division = np.divide(A, B) # Use numpy's divide to handle element-wise division


safely

print("\nElement-wise Division of matrices:\n", division)


231263107050

A = np.array([[4, 7], [2, 6]]) # Define the first matrix

B = np.array([[1, 3], [5, 8]]) # Define the second matrix

matrix_operations(A, B)

OUTPUT:

2) Write a Python program to concatenate two strings.

PROGRAM:

def concatenate_strings(string1, string2):

return string1 + string2

str1 = input("Enter the first string: ")

str2 = input("Enter the second string: ")

result = concatenate_strings(str1, str2)


231263107050

print("Concatenated String:", result)

OUTPUT:

3) Write a NumPy program to generate six random integers between 10 and 30.

PROGRAM:

import numpy as np

random_integers = np.random.randint(10, 31, size=6) # 31 is exclusive

print("Six random integers between 10 and 30:", random_integers)

OUTPUT:

4) Demonstrate the advantage of NumPy array over Python list.

a. Memory consumption between Numpy array and lists.

Memory Consumption: NumPy arrays are more memory-efficient. In the example, a


NumPy array consumed significantly less memory than a Python list for the same
number of elements.
231263107050

PROGRAM:

import numpy as np

import sys

python_list = list(range(1000)) # A list of 1000 integers

numpy_array = np.array(range(1000)) # A NumPy array of 1000 integers

python_list_memory = sys.getsizeof(python_list)

numpy_array_memory = numpy_array.nbytes

print("Memory consumption:")

print(f"Python list memory: {python_list_memory} bytes")

print(f"NumPy array memory: {numpy_array_memory} bytes")

b. Time comparison between Numpy array and Python lists.

Time Performance: NumPy operations are much faster than equivalent operations on
Python lists. The example showed that the time taken for an element-wise operation
was substantially lower for NumPy.

PROGRAM:

import numpy as np

import time

size = 10**6

python_list = list(range(size))
231263107050

numpy_array = np.array(range(size))

start_time = time.time()

list_sum = [x + 1 for x in python_list] # Element-wise addition

list_time = time.time() - start_time

start_time = time.time()

array_sum = numpy_array + 1 # Element-wise addition

array_time = time.time() - start_time

print("\nTime comparison:")

print(f"Python list operation time: {list_time:.6f} seconds")

print(f"NumPy array operation time: {array_time:.6f} seconds")


231263107050

EXPERIMENT NO: 5

1) Write a pandas program to convert a pandas module series to python


list and its type.

PROGRAM:

import pandas as pd

data = pd.Series([10, 20, 30, 40, 50])

python_list = data.tolist()

print("Pandas Series:")

print(data)

print("\nConverted Python list:")

print(python_list)

print("\nType of the converted list:", type(python_list))


OUTPUT:
231263107050

2) Write a pandas program to add, subtract, multiple and divide two


pandas series.
PROGRAM:

import pandas as pd

series1 = pd.Series([10, 20, 30, 40])

series2 = pd.Series([1, 2, 3, 4])

print("Series 1:")

print(series1)

print("\nSeries 2:")

print(series2)

addition = series1 + series2

print("\nAddition of Series:")

print(addition)

subtraction = series1 - series2

print("\nSubtraction of Series:")

print(subtraction)

multiplication = series1 * series2

print("\nMultiplication of Series:")

print(multiplication)

division = series1 / series2

print("\nDivision of Series:")
231263107050

print(division)

OUTPUT:

3) Write a pandas program to convert a NumPy array to a pandas series


PROGRAM:

import numpy as np

import pandas as pd

numpy_array = np.array([10, 20, 30, 40, 50])

pandas_series = pd.Series(numpy_array)

print("NumPy Array:")

print(numpy_array)
231263107050

print("\nConverted Pandas Series:")

print(pandas_series)

OUTPUT:
231263107050

EXPERIMENT NO: 6

1) Write a pandas program to change the name 'James' to other name in


name column of the DataFrame.
PROGRAM:

import pandas
as pd data = {
'name': ['James', 'Ahan', 'Bhanu', 'James',
'Charmi'], 'age': [25, 30, 22, 35, 28]
}
df =
pd.DataFrame(data)
print("Original
DataFrame:") print(df)
df['name'] = df['name'].replace('James',
'Janvi') print("\nModified DataFrame:")
print(df)

output:
231263107050

2) Write a pandas program to insert a new column in existing DataFrame.

PROGRAM:

import pandas as pd
data = { 'Name': ['Ahana', 'Bhavi', 'Charmi'], 'Age': [24, 30, 22]
}
df =
pd.DataFrame(data)
print("Original
DataFrame:") print(df)
df['City'] =['surat', 'ahmedabad',
'vadodara'] print("\nDataFrame after
adding 'City' :") print(df)
df.insert(1, 'Country', ['USA', 'USA', 'USA'])
print("\nDataFrame after inserting 'Country' column at position 1:")
print(df)

OUTPUT:
231263107050

3) Write a Pandas program to get list from DataFrame column headers.

PROGRAM:

import pandas
as pd data = {
'Name': ['Ahana', 'Bhavi',
'Charmi'], 'Age': [24, 30, 22],
'City': ['ahmedabad', 'surat', 'vadodara']
}
df = pd.DataFrame(data)
column_headers =
df.columns.tolist()
print("List of column headers:", column_headers)

OUTPUT:
231263107050

EXPERIMENT NO: 7

1.Write a Pandas program to create a time-series with two index labels


and random values. Also print the type of the index.
PROGRAM:

import pandas as pd

import numpy as np

np.random.seed(0)

date_range = pd.date_range(start='2024-01-01', periods=5, freq='D')

random_values = np.random.randn(5) # Generate 5 random numbers

time_series = pd.Series(random_values, index=date_range)

print("Time-Series:")

print(time_series)

print("\nType of the index:")

print(type(time_series.index))
OUTPUT:
231263107050

EXPERIMENT NO: 8

1.Write a Pandas program to count the missing values in a given


DataFrame.
PROGRAM:

import pandas as pd

import numpy as np

data = {

'A': [1, 2, np.nan, 4],

'B': [np.nan, np.nan, 3, 4],

'C': [5, 6, 7, 8],

'D': [np.nan, 10, 11, np.nan]

df = pd.DataFrame(data)

print("Original DataFrame:")

print(df)

missing_values_count = df.isnull().sum()

print("\nCount of missing values in each column:")

print(missing_values_count)
231263107050

OUTPUT:

2) Write a program toFill Missing DataFrame Values with following methods:

Fill Missing DataFrame Values with Column Mean, Median and Mode.

Fill Missing DataFrame Values with a Constant

Forward Fill Missing DataFrame Values

Backward Fill Missing DataFrame Values

Fill Missing DataFrame Values with Interpolation

PROGRAM:

import pandas as pd

import numpy as np
231263107050

data = {

'A': [1, 2, np.nan, 4, 5],

'B': [np.nan, 3, 4, np.nan, 6],

'C': [5, np.nan, np.nan, 8, 9]

df = pd.DataFrame(data)

print("Original DataFrame:")

print(df)

df_mean = df.fillna(df.mean())

print("\nDataFrame after filling missing values with column mean:")

print(df_mean)

df_median = df.fillna(df.median())

print("\nDataFrame after filling missing values with column median:")

print(df_median)

df_mode = df.fillna(df.mode().iloc[0]) # Taking the first mode

print("\nDataFrame after filling missing values with column mode:")

print(df_mode)
231263107050

df_constant = df.fillna(0) # Fill with zero

print("\nDataFrame after filling missing values with a constant (0):")

print(df_constant)

df_ffill = df.fillna(method='ffill')

print("\nDataFrame after forward filling missing values:")

print(df_ffill)

df_bfill = df.fillna(method='bfill')

print("\nDataFrame after backward filling missing values:")

print(df_bfill)

df_interpolated = df.interpolate()

print("\nDataFrame after filling missing values with interpolation:")

print(df_interpolated)

OUTPUT:
231263107050

EXPERIMENT NO: 9

1) Write a pandas program to Write a Python programming to display


chart of the popularity of programming Languages. Sample data:
Programming languages: Java, Python, PHP, JavaScript, C#, C++
Popularity: 22.2, 17.6, 8.8, 8, 7.7, 6.7 The code snippet gives the output
shown in the following screenshot:

a) Bar Chart b) Pie Chart

PROGRAM:

import pandas as pd

import matplotlib.pyplot as plt

languages = ['Java', 'Python', 'PHP', 'JavaScript', 'C#', 'C++']

popularity = [22.2, 17.6, 8.8, 8.0, 7.7, 6.7]

df = pd.DataFrame({'Languages': languages, 'Popularity': popularity})

plt.figure(figsize=(10, 5))

plt.subplot(1, 2, 1)

plt.bar(df['Languages'], df['Popularity'], color='blue')

plt.title('Popularity of Programming Languages')

plt.xlabel('Languages')
231263107050

plt.ylabel('Popularity')

plt.subplot(1, 2, 2)

plt.pie(df['Popularity'], labels=df['Languages'], autopct='%1.1f%%',


colors=['blue', 'orange', 'green', 'red', 'purple', 'brown'])

plt.title('Popularity Share by Programming Language')

plt.tight_layout()

plt.show()

OUTPUT:
231263107050

EXPERIMENT NO: 10

Scikit-learn is one of the most popular and widely-used libraries in Python for data
science and machine learning. It provides a simple, efficient, and flexible interface for a
wide range of machine learning tasks, such as classification, regression, clustering, and
dimensionality reduction. It is built on top of other fundamental scientific Python libraries
like NumPy, SciPy, and Matplotlib.

Key Features of Scikit-learn:

1. Supervised Learning Algorithms: Supports popular algorithms such as linear


regression, decision trees, random forests, k-nearest neighbors (KNN), support
vector machines (SVM), and more.
2. Unsupervised Learning Algorithms: Includes clustering algorithms such as
k-means, DBSCAN, and hierarchical clustering, as well as techniques for
dimensionality reduction like principal component analysis (PCA) and singular
value decomposition (SVD).
3. Model Selection and Evaluation: Provides tools for evaluating models
(cross-validation, train/test split, and scoring metrics), tuning hyperparameters,
and handling overfitting (such as GridSearchCV and RandomizedSearchCV).
4. Data Preprocessing: Includes utilities for transforming data, handling missing
values, scaling features, encoding categorical variables, and generating
polynomial features.
5. Feature Selection: Implements techniques to select the most relevant features for
model training, such as recursive feature elimination (RFE), LASSO, and
variance thresholding.

You might also like