Ravindra BagaleCourses & study guides English Track your progress

33. sklearn सह Python मध्ये Linear Regression

Data Science

33.1 Number का Predict करायचे (Regression)

का गरजेचे आहे. अनेक India business प्रश्न numbers चे असतात: ₹ मधील rent, रोजचे pedha sales, delivery minutes. Classification yes/no सांगते. Regression एक number predict करते.

हे काय आहे. Linear regression सरळ रेषेसारखा संबंध काढते: “flat size वाढला की rent वाढायची प्रवृत्ती.” sklearn ची LinearRegression training rows वरून best-fitting line (किंवा plane) शोधते.

कसे करायचे.

Regression प्रश्न ओळखा

  1. विचारा: “उत्तर ₹ / kg / minutes मध्ये मला महत्वाचे असणारे number आहे का?”
  2. असल्यास → regression (हा chapter). yes/no किंवा category → Chapter 34.
  3. एक वाक्य लिहा: “मी ___ मधून ___ predict करेन.” उदाहरण: area_sqft आणि city tier मधून monthly rent (काल्पनिक Pune flats).

Worked example — काल्पनिक rent rows.

import pandas as pd

rent = pd.DataFrame({
 "area_sqft": [450, 600, 750, 900, 1100],
 "rent_inr": [12000, 15500, 19000, 22500, 27000],
})
print(rent)
print("Target y = rent_inr (a number). Feature X = area_sqft.")

तुम्हाला काय दिसायला हवे. मोठ्या flats ची किंमत जास्त असण्याची प्रवृत्ती असलेली छोटी table. Linear regression तो slope data मधून शिकेल — हाताने लिहिलेल्या सूत्रातून नाही.

काल्पनिक data

Rents आणि flat sizes फक्त शिकवण्याचे samples आहेत, खऱ्या listings नाहीत.

Ravindra Bagale's Tip

Remember this simple rule: regression predicts a number, and classification predicts a class or category. For example, predicting next month's sales in rupees is regression, while predicting whether a customer will leave is classification. Interviewers often ask this, so be ready to say it clearly in one line.