PAL Codes
PAL Codes
Title: Predict the performance of cricket team using historical day in MS-Excel.
Name : Abhishek Pawar
Roll.no : 40
Batch :T2
5 40 1 5 64 0
6 52 1 6 72 1
7 75 1 7 88 1
8 82 2 8 95 1
9 90 2 9 99 1
10 100 2 10 112 2
11 120 2 11 130 2
12 135 3 12 140 3
13 140 3 13 145 3
14 145 4 14 153 4
15 155 4 15 160 4
16 160 4 16 162 5
17 163 5 17 166 5
18 167 5 18 179 5
19 168 5 19 171 5
20 170 6 20 6
200
180
160
140
120
SCORES
100
80
60
40
20
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
OVERS OF MATCH
250
200
150
SCORES
100
50
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
OVERS OF MATCH
200
180
160
140
120
SCORES
100
80
60
40
20
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
OVERS OF MATCH
200
180
160
140
120
SCORES
100
80
60
40
20
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
OVERS OF MATCH
import numpy as np
import matplotlib.pyplot as plt
# Sample data points
x = np.array([2, 4, 6, 8]) # Independent variable (Hours Studied)
y = np.array([3, 7, 5, 10]) # Dependent variable (Exam Score)
# Perform linear regression using NumPy's polyfit (degree 1 for linear
regression)
m, c = np.polyfit(x, y, 1)
# Print the results
print(f"Slope (m): {m}")
print(f"Intercept (c): {c}")
# Predict y values using the regression line
y_pred = m * x + c
# Print the original data points and the predicted values
print("\nOriginal and Predicted Values:")
for xi, yi, y_pred_val in zip(x, y, y_pred):
print(f"x: {xi}, y (original): {yi}, y (predicted): {y_pred_val}")
# Plotting the data points and the regression line
plt.scatter(x, y, color='blue', label='Original Data') # Plot original data points
plt.plot(x, y_pred, color='red', label='Regression Line') # Plot the regression
line
plt.xlabel('X values (Hours Studied)')
plt.ylabel('Y values (Exam Score)')
plt.title('Linear Regression: Predicted vs Original')
plt.legend()
plt.grid(True)
plt.show()
output:
Slope (m): 0.9500000000000001
Intercept (c): 1.4999999999999998
Original and Predicted Values:
x: 2, y (original): 3, y (predicted): 3.4
x: 4, y (original): 7, y (predicted): 5.3
x: 6, y (original): 5, y (predicted): 7.2
x: 8, y (original): 10, y (predicted): 9.1
Practical 4
Title: Using Chi-Square analysis to predict the hypothesis.
Name : Abhishek Pawar
Roll.no : 40
Batch :T2
import numpy as np
# Import necessary library
from scipy.stats import chi2_contingency
# Observed data in contingency table format
observed = [[20, 15, 25], # Male preferences
[10, 25, 15]] # Female preferences
# Perform the chi-square test
chi2_stat, p_val, dof, expected = chi2_contingency(observed)
OUTPUT:
Chi-Square Statistic: 7.48611111111111
p-value: 0.023681631925797347
Degrees of Freedom: 2
Expected Frequencies:
[[16.36363636 21.81818182 21.81818182]
[13.63636364 18.18181818 18.18181818]]
Reject the null hypothesis: There is a significant association.
Practical 5
Title: Predict the email spam or ham (not spam) using classification algorithm.
Name : Abhishek Pawar
Roll.no : 40
Batch :T2
OUTPUT:
Accuracy: 0.75
Confusion Matrix:
[[2 0]
[1 1]]
Classification Report:
precision recall f1-score support
accuracy 0.75 4
macro avg 0.83 0.75 0.73 4
weighted avg 0.83 0.75 0.73 4
Practical 6
OUTPUT:
Requirement already satisfied: textblob in /usr/local/lib/python3.10/dist-
packages (0.17.1)
Requirement already satisfied: nltk>=3.1 in /usr/local/lib/python3.10/dist-
packages (from textblob) (3.9.1)
Requirement already satisfied: click in /usr/local/lib/python3.10/dist-packages
(from nltk>=3.1->textblob) (8.1.7)
Requirement already satisfied: joblib in /usr/local/lib/python3.10/dist-packages
(from nltk>=3.1->textblob) (1.4.2)
Requirement already satisfied: regex>=2021.8.3 in
/usr/local/lib/python3.10/dist-packages (from nltk>=3.1->textblob) (2024.9.11)
Requirement already satisfied: tqdm in /usr/local/lib/python3.10/dist-packages
(from nltk>=3.1->textblob) (4.66.6)
Review: 'I love this product! It's amazing.'
Predicted Sentiment: Positive
Review: 'The service was terrible and very disappointing.'
Predicted Sentiment: Negative
Review: 'It was okay, nothing special but not bad either.'
Predicted Sentiment: Positive
Practical 8
Title: Predict the future energy consumption for household or industry
based on past data.
Name : Abhishek Pawar
Roll.no : 40
Batch :T2
# Predict future consumption (for example, predicting for the next 2 months)
future_months = np.array([11, 12]).reshape(-1, 1)
predictions = model.predict(future_months)