Linear regression with np.polyfit()
📖 Scenario: You are a data analyst at a small store. You want to understand how the number of hours spent advertising affects the number of sales. You have collected data for 7 days.
🎯 Goal: Build a simple linear regression model using np.polyfit() to find the relationship between advertising hours and sales. Then, display the slope and intercept of the line.
📋 What You'll Learn
Create two lists:
hours and sales with given valuesCreate a variable
degree to set the polynomial degreeUse
np.polyfit() with hours, sales, and degree to find the slope and interceptPrint the slope and intercept values
💡 Why This Matters
🌍 Real World
Linear regression helps businesses understand relationships between variables, like advertising time and sales, to make better decisions.
💼 Career
Data analysts and scientists use linear regression to build predictive models and explain trends in data.
Progress0 / 4 steps