File size: 2,128 Bytes
154b7a1
dab724c
 
154b7a1
 
dab724c
154b7a1
 
dab724c
154b7a1
dab724c
 
154b7a1
 
 
dab724c
 
 
 
154b7a1
dab724c
154b7a1
 
dab724c
 
154b7a1
dab724c
 
154b7a1
 
 
 
 
dab724c
154b7a1
 
a8155b6
 
dab724c
a8155b6
 
 
 
dab724c
a8155b6
 
dab724c
a8155b6
 
dab724c
a8155b6
 
 
 
 
 
dab724c
a8155b6
154b7a1
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Import necessary libraries
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
import gradio as gr

# Load the CSV data into a pandas DataFrame
data = pd.read_csv('dataset.csv')

# Split the data into features (X) and labels (y)
X = data.iloc[:, :-1]  # All columns except the last one
y = data.iloc[:, -1]  # Last column (placed or not)

# Split the data into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Create a pipeline with a Random Forest Classifier
pipeline = Pipeline([
    ('scaler', StandardScaler()),  # Standardize features
    ('classifier', RandomForestClassifier())  # Random Forest Classifier
])

# Fit the pipeline to the training data
pipeline.fit(X_train, y_train)

# Make predictions on the testing data
y_pred = pipeline.predict(X_test)

# Calculate accuracy of the model
accuracy = accuracy_score(y_test, y_pred)
print('Accuracy:', accuracy)

# Define the input and output types for Gradio
input_type = 'csv'
output_type = 'label'

# Define the function to make predictions using the trained model
def predict_placement(Internships, CGPA, HistoryOfBacklogs):
    # Create a DataFrame from the input data
    input_df = pd.DataFrame({'Internships': [Internships], 'CGPA': [CGPA], 'HistoryOfBacklogs': [HistoryOfBacklogs]})
    
    # Make a prediction using the trained model
    prediction = pipeline.predict(input_df)[0]
    
    # Return the predicted label
    return 'Placed' if prediction else 'Not Placed'

# Create the Gradio interface
iface = gr.Interface(fn=predict_placement, 
                     inputs=input_type, 
                     outputs=output_type, 
                     title='Student Job Placement Predictor', 
                     description='Predicts whether a student will be placed in a job or not based on internships, CGPA, and history of backlogs.')

# Launch the Gradio interface
iface.launch()