Lab 14 112
Lab 14 112
Section “C”
Lab report
#14
Submitted To:
Sir Abdullah shehroz
Submitted By:
Aliza Wajid
20-cs-112
Code 1:
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import multivariate_normal
# Set parameters
mean = [0, 0]
cov_matrix = [[1, 0.8], [0.8, 1]]
num_samples = 1000
labels = ['Variable A', 'Variable B']
# Create subplots
fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(15, 5))
# Show plots
plt.tight_layout()
plt.show()
Code 2:
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm
# Set parameters
mean = [0, 0]
std_dev = [1, 1]
correlation = 0.7
size = 1000
labels = ['Variable A', 'Variable B']
# Create subplots
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 5))
# Show plots
plt.tight_layout()
plt.show()
Code 3:
import numpy as np
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error
# Calculate and print the mean squared error on the test data
mse = mean_squared_error(y_test, y_pred)
print(f'Mean Squared Error on Test Data: {mse:.2f}')