# -*- coding: utf-8 -*-
"""
Created on Wed Sep 23 13:05:56 2020

@author: hallgato
"""

import numpy as np;
import matplotlib.pyplot as plt;
from sklearn import datasets, linear_model, neural_network, preprocessing;

minta = np.random.normal(0,1,100);

atlag = np.mean(minta,axis=0);
szoras = np.std(minta,axis=0);

b0 = 5;
b1 = 1;
n = 100;
x = np.random.normal(0,1,n);
sig =0.2;
eps = np.random.normal(0,sig,n);

y = b0 + b1*x + eps;

# output


plt.figure(1);
plt.title('Regresszió');
plt.xlabel('input');
plt.ylabel('output');
plt.scatter(x,y,color="blue");
xmin = min(x)-0.2;
xmax = max(x)+0.2;
ymin = b0 + b1*xmin;
ymax = b0 + b1*xmax;
plt.plot([xmin,xmax],[ymin,ymax],color='red');
plt.show(); 

reg = linear_model.LinearRegression();
X = x.reshape(1, -1).T;
scaler = preprocessing.MinMaxScaler();
X_norm = scaler.fit_transform(X);
y_norm = scaler.fit_transform(y.reshape(1, -1).T);
reg.fit(X_norm,y_norm);
b0hat = reg.intercept_;
b1hat = reg.coef_;
y_pred = reg.predict(X_norm);

neural = neural_network.MLPRegressor(hidden_layer_sizes=());
neural.fit(X,y);
b0hat1 = neural.intercepts_[0][0];
b1hat1 = neural.coefs_[0][0,0];
y_pred1 = neural.predict(X);


X,y,coef = datasets.make_regression(n_samples=10000, n_features=20, n_informative=5, bias=10, noise=5, coef=True);
reg = linear_model.LinearRegression();
reg.fit(X,y);
b0hat = reg.intercept_;
b1hat = reg.coef_;
score = reg.score(X,y);

reg1 = linear_model.Lasso(alpha=0.2);
reg1.fit(X,y);
b0hat1 = reg1.intercept_;
b1hat1 = reg1.coef_;
score1 = reg1.score(X,y);
y_pred1 = reg1.predict(X);
