Skip to content

Instantly share code, notes, and snippets.

View rodrigols89's full-sized avatar
🎯
Creating Things & Solving Problems

Rodrigo Leite rodrigols89

🎯
Creating Things & Solving Problems
View GitHub Profile
from matplotlib import pyplot as plt
import pandas as pd
df = pd.DataFrame(
{
'Grade':[50, 50, 46, 95, 50, 5, 57, 42, 26, 72, 78, 60, 40, 17, 85],
'Salary':[50000, 54000, 50000, 189000, 55000, 40000, 59000, 42000, 47000, 78000, 119000, 95000, 49000, 29000, 130000]
}
)
from matplotlib import pyplot as plt
import pandas as pd
df = pd.DataFrame(
{
'Grade':[50, 50, 46, 95, 50, 5, 57, 42, 26, 72, 78, 60, 40, 17, 85],
'Salary':[50000, 54000, 50000, 189000, 55000, 40000, 59000, 42000, 47000, 78000, 119000, 95000, 49000, 29000, 130000]
}
)
from matplotlib import pyplot as plt
import pandas as pd
df = pd.DataFrame(
{
'Grade':[50, 50, 46, 95, 50, 5, 57, 42, 26, 72, 78, 60, 40, 17, 85],
'Salary':[50000, 54000, 50000, 189000, 55000, 40000, 59000, 42000, 47000, 78000, 119000, 95000, 49000, 29000, 130000]
}
)
def checkVersion():
import sklearn
print('Scikit-Learn Version: {0}'.format(sklearn.__version__))
if __name__ =='__main__':
checkVersion()
def createRegression(samples, variavel_numbers, n_noise):
from sklearn.datasets import make_regression
x, y = make_regression(n_samples=samples, n_features=variavel_numbers, noise=n_noise)
return x, y
if __name__ =='__main__':
from matplotlib import pyplot as plt
reg = createRegression(200, 1, 30)
def createRegression(samples, variavel_numbers, n_noise):
from sklearn.datasets import make_regression
x, y = make_regression(n_samples=samples, n_features=variavel_numbers, noise=n_noise)
return x, y
if __name__ =='__main__':
from sklearn.linear_model import LinearRegression
from matplotlib import pyplot as plt
def createRegression(samples,variavel_numbers, n_noise):
from sklearn.datasets import make_regression
x, y = make_regression(n_samples=samples, n_features=variavel_numbers, noise=n_noise)
return x, y
if __name__ =='__main__':
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
from matplotlib import pyplot as plt
"""
R-Squared or Coefficient of Determination
"""
def createRegression(samples,variavel_numbers, n_noise):
from sklearn.datasets import make_regression
x, y = make_regression(n_samples=samples, n_features=variavel_numbers, noise=n_noise)
return x, y
if __name__ =='__main__':
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from matplotlib import pyplot as plt
import pandas as pd
pd.set_option('display.max_columns', 21)
df = pd.read_csv('../datasets/kc_house_data.csv')
df = df.drop(['id', 'date', 'zipcode', 'lat', 'long'], axis=1)
y = df['price']
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from matplotlib import pyplot as plt
diameter = [[7], [10], [15], [30], [45], [13], [60], [100], [5], [30], [90], [18], [70], [110], [25]]
prices = [[8], [11], [16], [38.5], [52], [14], [70], [90], [6], [38.5], [102], [20], [85], [100], [34]]
model = LinearRegression()