In [23]: import numpy as np
import pandas as pd
[Link].chained_assignment = None
from sklearn.linear_model import LogisticRegression
import joblib
In [24]: # Load Model and Standard Scalar
model = [Link](r'Model/[Link]')
scaler = [Link](r'Scalar/[Link]')
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 = [Link]([{'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']] = [Link](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([Link]) - 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
[Link]()
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 = [Link](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