import pandas as pd
df=pd.read_csv('https://raw.githubusercontent.com/gtchandra/skema-Bootcamp1-students/master/RegressionMetrics.csv')
df
import pandas as pd
import numpy as np
data=pd.read_csv('https://raw.githubusercontent.com/gtchandra/skema-Bootcamp1-students/master/RegressionMetrics.csv')
len(data)
y = data['Y'].values
y1 = data['y1'].values
y2 = data['y2'].values
y3 = data['y3'].values
def compute_mse(array_tested: np.array) -> float:
minus = y - array_tested
minus_2 = minus ** 2
sum_minus_2 = np.sum(minus_2)
return sum_minus_2 / len(minus_2)
for df in [y1, y2, y3]:
print(compute_mse(df))
def compute_rmse(array_tested: np.array) -> float:
return np.sqrt(compute_mse(array_tested))
for df in [y1, y2, y3]:
print(compute_rmse(df))
def compute_r_2(array_tested: np.array) -> float:
rss = np.sum((y - array_tested)**2)
tss = np.sum((y - np.mean(y))**2)
return 1 - rss/tss
for df in [y1, y2, y3]:
print(compute_r_2(df))
def func(une_variable_locale: str):
print(une_variable_locale)
func("test")
df = pd.DataFrame(columns=['short', 'mid', 'long', 'index'])
df
df['short'] = [15, 1, 4]
df['mid'] = [5, 12, 3]
df['long'] = [3, 4, 34]
df['index'] = ['short', 'mid', 'long']
df = df.set_index('index')
df
matrix = pd.DataFrame(columns=["T", "F", "index"])
matrix["index"] = ["T", "F"]
matrix = matrix.set_index("index")
matrix
matrix["T"]["T"] = sum(df[i][i] for i in df.index)
matrix["F"]["F"] =
matrix