import os import pandas as pd import math import numpy as np import pickle import dill def load_object(file_path): with open(file_path,"rb") as file_obj: return dill.load(file_obj) class PredictPipeline: def __init__(self): pass def predict(self,features): model_path=os.path.join("model.pkl") preprocessor_path=os.path.join('preprocessor.pkl') model=load_object(model_path) preprocessor=load_object(preprocessor_path) data_scaled=preprocessor.transform(features) result=model.predict(data_scaled) output=math.floor(np.exp(result[0])) return output class CustomData: def __init__(self,company:str,typename:str,ram:int,weight:float,touchscrren:int,ips:int,ppi:float,cpu:str,gpu:str,os:str,HDD:int,SDD:int): self.company=company self.typename=typename self.ram=ram self.weight=weight self.touchscrren=touchscrren self.ips=ips self.ppi=ppi self.cpu=cpu self.gpu=gpu self.os=os self.HDD=HDD self.SDD=SDD def get_data_as_dataframe(self): custom_data_input_dict={ "Company": [self.company], "TypeName":[self.typename], "Ram":[self.ram], "Weight":[self.weight], "Touchscreen":[self.touchscrren], "IPS":[self.ips], "ppi":[self.ppi], "CPU_brand":[self.cpu], "Gpu_brand":[self.gpu], "os":[self.os], "HDD":[self.HDD], "SDD":[self.SDD], } return pd.DataFrame(custom_data_input_dict)