0% found this document useful (0 votes)
7 views

Lecture 4 StudentRecommedSystemWithLoadModel

Uploaded by

Alisha Ashraf
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Lecture 4 StudentRecommedSystemWithLoadModel

Uploaded by

Alisha Ashraf
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

In [23]: import numpy as np

import pandas as pd
pd.options.mode.chained_assignment = None
from sklearn.linear_model import LogisticRegression
import joblib

In [24]: # Load Model and Standard Scalar


model = joblib.load(r'Model/model.pickle')
scaler = joblib.load(r'Scalar/scalar.pickle')

In [25]: # Input to User for Final


print('Enter the Information for Student Recommendation of Grant')
Name = input('Name of Student:')
OverAllScore = input('Over All Grade(A,B,C,D,E,F):')
Obedient = input('Obedient:(Y/N)')
ResearchScore = input('Research Score')
ProjectScore = input('Project Score')
NewStudentRecord = pd.DataFrame([{'Name':Name,
'OverAllGrade':OverAllScore,
'Obedient':Obedient,
'ResearchScore':ResearchScore,
'ProjectScore':ProjectScore}])
NewStudentRecord
NewStudentFeatures = NewStudentRecord[['OverAllGrade','Obedient','ResearchScore','Projec

Enter the Information for Student Recommendation of Grant


Name of Student:Jamil
Over All Grade(A,B,C,D,E,F):A
Obedient:(Y/N)Y
Research Score89
Project Score78

In [26]: # Scanling for Numeric Columns - New Student


NewStudentFeatures[['ResearchScore','ProjectScore']] = scaler.transform(NewStudentFeatur

# One-Hot CODING for Categorical Columns - New Student


NewStudentFeatures = pd.get_dummies(NewStudentFeatures, columns=['OverAllGrade','Obedien
NewStudentFeatures

Out[26]: ResearchScore ProjectScore OverAllGrade_A Obedient_Y

0 0.865796 1.074327 1 1

In [27]: # Added the Missing Columns of Data ONE-HOT Coding


RequiredCategoricalColumns = ['OverAllGrade_A',
'OverAllGrade_B',
'OverAllGrade_C',
'OverAllGrade_E',
'OverAllGrade_F',
'Obedient_N',
'Obedient_Y',]
CurrentCategoricalColumns = set(NewStudentFeatures.columns) - set(NewStudentFeatures[['R
print(f"Current Columns:{CurrentCategoricalColumns}")

MissingCategoricalColumns = set(RequiredCategoricalColumns) - set(CurrentCategoricalColum


print(f"\nCurrent Columns:{MissingCategoricalColumns}")

# Add the Missing Columns with zero values


for feature in MissingCategoricalColumns:
NewStudentFeatures[feature] = 0

NewStudentFeatures.head()
Current Columns:{'Obedient_Y', 'OverAllGrade_A'}

Current Columns:{'Obedient_N', 'OverAllGrade_F', 'OverAllGrade_B', 'OverAllGrade_E', 'Ov


erAllGrade_C'}
Out[27]: ResearchScore ProjectScore OverAllGrade_A Obedient_Y Obedient_N OverAllGrade_F OverAllGrade_B OverA

0 0.865796 1.074327 1 1 0 0 0

In [28]: # Predict by the Model


NewPrediction = model.predict(NewStudentFeatures)

# Add Recommed Column in the New_Student with Output / Answer


NewStudentRecord['Recommend'] = NewPrediction
print(NewStudentRecord)

Name OverAllGrade Obedient ResearchScore ProjectScore Recommend


0 Jamil A Y 89 78 Yes

You might also like