Professional Documents
Culture Documents
National University of Technology UA 34 LAB AI OEL 1
National University of Technology UA 34 LAB AI OEL 1
Umar Aurangzeb
34
AI lab OEL 1
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.model_selection import train_test_split
from sklearn.linear_model import Ridge
from sklearn.metrics import mean_squared_error, r2_score
from sklearn.preprocessing import StandardScaler
X = df[independent_features]
y = df[dependent_feature]
# Inverse transform the scaled predictions to get them back to the original scale
y_pred_original_scale = scaler_y.inverse_transform(y_pred.reshape(-1,
1)).flatten()
# Calculate R2
r2 = r2_score(y_test, y_pred)
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score, precision_score, recall_score,
classification_report
# Drop rows with missing values for simplicity (you may want to handle missing
values differently)
df = df.dropna()
print(f'Accuracy: {accuracy:.2f}')
print(f'Precision: {precision:.2f}')
print(f'Recall: {recall:.2f}')
Output