-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtraining.py
More file actions
29 lines (28 loc) · 1.27 KB
/
training.py
File metadata and controls
29 lines (28 loc) · 1.27 KB
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
import pandas as pd
import numpy as np
import tensorflow as tf
from sklearn.preprocessing import LabelEncoder,StandardScaler
from sklearn.model_selection import train_test_split
data = pd.read_csv(r"C:\Users\Avina\Downloads\Placement.csv")
print(data.head())
X = data[["CGPA", "Internships"]]
le = LabelEncoder()
y = le.fit_transform(data["Placed"])
print(data['Placed'].value_counts())
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X)
X_train, X_test, y_train, y_test = train_test_split(X_scaled,y, test_size=0.2, random_state=42, stratify=y)
model = tf.keras.Sequential([
tf.keras.layers.Input(shape=(2,)),
tf.keras.layers.Dense(16, activation="relu"),tf.keras.layers.Dropout(0.2),
tf.keras.layers.Dense(1, activation="sigmoid")
])
model.compile(optimizer="adam", loss="binary_crossentropy", metrics=["accuracy"])
model.fit(X_train, y_train, epochs=100,validation_split=0.2, verbose=1)
students = np.array([[8.76,0],[7.06,2],[7.9,3]])
students_scaled = scaler.transform(students)
predictions = model.predict(students_scaled)
predictions = model.predict(students_scaled)
for i, prob in enumerate(predictions):
placed = "Yes" if prob[0] > 0.5 else "No"
print("Student", i+1, "-> Probability:", round(prob[0], 2), "| Placed:", placed)