Spaces:
Runtime error
Runtime error
File size: 1,697 Bytes
a5cb203 659d1e5 a5cb203 659d1e5 a5cb203 | 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 | 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)
|