tuomasvaltanen

Untitled

Nov 2nd, 2022
967
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.14 KB | None | 0 0
  1. # in this example, we'll create a heatmap of our correlation matrix
  2. plt.figure(figsize=(16,16))
  3. sns.heatmap(df.corr(), annot=True, fmt=".2f")
  4.  
  5. print(df.corr()['price_range'].sort_values(ascending=False))
  6.  
  7. # X = df[['ram','battery_power','px_width', 'px_height', 'int_memory', 'sc_w', 'sc_h', 'pc', 'talk_time', 'mobile_wt']]
  8.  
  9.  
  10. # trying with a new phone
  11.  
  12. # new phone, outside the dataset
  13. # for exmaple, if we we used fields: ['ram','battery_power','px_width', 'px_height']
  14.  
  15. # then, do something like this:
  16. # X = df[['ram','battery_power','px_width', 'px_height', 'int_memory', 'sc_w', 'sc_h', 'pc', 'talk_time', 'mobile_wt']]
  17. np_ram = 4096
  18. np_battery = 1500
  19. np_px_width = 600
  20. np_px_height = 1200
  21. np_intmemory = 32
  22. np_scw = 5
  23. np_sch = 12
  24. np_pc = 24
  25. np_talk_time = 12
  26. np_mobile_wt = 150
  27.  
  28. # build the phone
  29. new_phone = [[np_ram, np_battery, np_px_width, np_px_height, np_intmemory, np_scw, np_sch, np_pc, np_talk_time, np_mobile_wt]]
  30.  
  31. # what's the price range? scale the data and give it to model
  32. new_phone = sc.transform(new_phone)
  33. result = categories[np.argmax(model.predict(new_phone))]
  34. print(f"\nPredicted price category: {result}")
Advertisement
Add Comment
Please, Sign In to add comment