Created
January 29, 2017 02:32
-
-
Save hackintoshrao/49b5c45ae567632d00b4727fbaddeabc to your computer and use it in GitHub Desktop.
Doing linear regression using python.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # TODO: Add import statements | |
| import pandas as pd | |
| from sklearn import linear_model | |
| # Assign the dataframe to this variable. | |
| # TODO: Load the data | |
| bmi_life_data = pd.read_csv("bmi_and_life_expectancy.csv") | |
| # Make and fit the linear regression model | |
| #TODO: Fit the model and Assign it to bmi_life_model | |
| bmi_life_model = linear_model.LinearRegression() | |
| bmi_life_model.fit(bmi_life_data[['BMI']],bmi_life_data[['Life expectancy']]) | |
| # Mak a prediction using the model | |
| # TODO: Predict life expectancy for a BMI value of 21.07931 | |
| laos_life_exp = bmi_life_model.predict(21.07931) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment