-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIris_dataset
More file actions
31 lines (25 loc) · 920 Bytes
/
Iris_dataset
File metadata and controls
31 lines (25 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# 1. Import Libraries
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score, classification_report
# 2. Load Dataset
iris = load_iris()
X = iris.data
y = iris.target
# 3. Split Data (80% Train, 20% Test)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# 4. Preprocess Data
scaler = StandardScaler()
X_train = scaler.fit_transform(X_train)
X_test = scaler.transform(X_test)
# 5. Build Model
model = LogisticRegression()
model.fit(X_train, y_train)
# 6. Evaluate Model
y_pred = model.predict(X_test)
accuracy = accuracy_score(y_test, y_pred)
print("🔍 Accuracy:", accuracy)
print("\n📄 Classification Report:")
print(classification_report(y_test, y_pred, target_names=iris.target_names))