# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
import numpy as np
import matplotlib.pyplot as plt
import sklearn.model_selection
import sklearn.linear_model

# %matplotlib inline
# -

data = np.loadtxt("notas_andes.dat", skiprows=1)

# +
Y = data[:,4]
X = data[:,:4]

X_train, X_test, Y_train, Y_test = sklearn.model_selection.train_test_split(X, Y, test_size=0.3)

print(np.shape(Y_train), np.shape(X_train))
# -

regresion = sklearn.linear_model.LinearRegression()
regresion.fit(X_train, Y_train)

print(regresion.coef_, regresion.intercept_)
print(regresion.score(X_train,Y_train), regresion.score(X_test,Y_test))

# +
plt.figure(figsize=(8,8))
labels = ["Fisica I", "Fisica II", "Alg Lin", "Calc Dif"]

for i, label in enumerate(labels):
    plt.subplot(2,2,i+1)
    plt.scatter(X_train[:,i], Y_train)
    plt.scatter(X_train[:,i], regresion.predict(X_train), marker='^')
    plt.xlabel(label)
    plt.ylabel('PGA')
# -



StarcoderdataJupyterScriptsDedupFiltered