Deep Learning Project – Student Placement Prediction using ANN

Machine Learning courses with 100+ Real-time projects Start Now!!

Program 1

Placement Dataset

Student Placement Prediction Using ANN on Academic and Skill Data

To build an Artificial Neural Network (ANN) model that predicts whether a student will get placed or not based on their academic records, skills, and personal details


import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder, StandardScaler
from sklearn.metrics import classification_report, confusion_matrix
import matplotlib.pyplot as plt
import seaborn as sns
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense

# Load dataset
df = pd.read_csv("D://scikit_data/placement/Placement_data_full_class.csv")
#df.drop(['sl_no', 'salary'], axis=1, inplace=True)
df.isnull().sum()

# Encode categorical variables
label_encoders = {}
for column in df.select_dtypes(include=['object']).columns:
    le = LabelEncoder()
    df = le.fit_transform(df)
    label_encoders = le
df.head()

# Split features and target
X = df.drop('status', axis=1) # Input valeus
y = df['status'] # Out put value
y.head()

# Normalize features
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X)

# Train-test split
X_train, X_test, y_train, y_test = train_test_split(X_scaled, y, test_size=0.4)
len(X_train)

# ANN model
model = Sequential()
model.add(Dense(16, input_dim=X_train.shape[1], activation='relu'))  # Input + I Hidden Layer
model.add(Dense(8, activation='relu')) # Hidden Layer
model.add(Dense(1, activation='sigmoid')) # OutPut Layer

model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])

# Train model and store history
history = model.fit(X_train, y_train, epochs=100, batch_size=8, verbose=0)

# Plot Loss Curve
plt.figure(figsize=(8,5))
plt.plot(history.history['loss'], label='Training Loss')
plt.title('Loss Over Epochs')
plt.xlabel('Epoch')
plt.ylabel('Binary Crossentropy Loss')
plt.legend()
plt.grid(True)
plt.show()

# Predict and evaluate
y_pred = (model.predict(X_test) > 0.5).astype("int32")

print("\nClassification Report:\n", classification_report(y_test, y_pred))

#Confusion Matrix
cm = confusion_matrix(y_test, y_pred)
plt.figure(figsize=(6,5))
sns.heatmap(cm, annot=True, fmt="d", cmap='Blues')
plt.title("Confusion Matrix")
plt.xlabel("Predicted")
plt.ylabel("Actual")
plt.show()

# --- Console-based prediction ---
print("\n--- Predict Placement for a New Student ---")
def get_user_input():
    input_data = {}
    for col in X.columns:
        if col in label_encoders:
            classes = label_encoders[col].classes_
            print(f"{col} options: {list(classes)}")
            val = input(f"Enter {col}: ")
            input_data[col] = label_encoders[col].transform([val])[0]
        else:
            val = float(input(f"Enter {col}: "))
            input_data[col] = val
    return pd.DataFrame([input_data])

user_df = get_user_input()
user_scaled = scaler.transform(user_df)
user_pred = model.predict(user_scaled)
result = "Placed" if user_pred[0][0] > 0.5 else "Not Placed"
print(f"\n Predicted Placement Status: {result} (Probability: {user_pred[0][0]:.2f})")

 

Did we exceed your expectations?
If Yes, share your valuable feedback on Google

courses

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

Your email address will not be published. Required fields are marked *