-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxstar.py
88 lines (61 loc) · 2.53 KB
/
xstar.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# -*- coding: utf-8 -*-
"""
Created on Thu Apr 25 07:35:09 2024
@author: Alex Salce
"""
from ucimlrepo import fetch_ucirepo
import numpy as np
from scipy.optimize import lsq_linear
# _ _ _ _ _ _
# __ _(_)_ __ ___ __ _ _ _ __ _| (_| |_ _ _ __| | __ _| |_ __ _
# \ \ /\ / | | '_ \ / _ \ / _` | | | |/ _` | | | __| | | | / _` |/ _` | __/ _` |
# \ V V /| | | | | __/ | (_| | |_| | (_| | | | |_| |_| | | (_| | (_| | || (_| |
# \_/\_/ |_|_| |_|\___| \__, |\__,_|\__,_|_|_|\__|\__, | \__,_|\__,_|\__\__,_|
# |_| |___/
###############################################################################
#CITATION
# Cortez,Paulo, Cerdeira,A., Almeida,F., Matos,T., and Reis,J.. (2009).
# Wine Quality. UCI Machine Learning Repository.
# https://doi.org/10.24432/C56S3T.
###############################################################################
# # fetch dataset
# wine_quality = fetch_ucirepo(id=186)
# # data (as pandas dataframes)
# A = wine_quality.data.features
# b = wine_quality.data.targets
# # metadata
# print(wine_quality.metadata)
# # variable information
# print(wine_quality.variables)
# A = np.array(A)
# # A = np.append(A,np.ones([A.shape[0],1]), axis=1)
# b = np.array(b)
# b = np.squeeze(b)
# # x = np.zeros((A.shape[1],1))
# n,m = A.shape
# _
# _ |_) _ __ _ _ __ _| _ _|_ o o _|_ \/
# _> |_|| (/_ | (_ (_)| |(_||_|(_ |_ | \_/ | |_ /
# _| _ _|_ _
# (_|(_| |_(_|
# ###############################################################################
# #CITATION
# # Hamidieh,Kam. (2018). Superconductivty Data. UCI Machine Learning Repository.
# # https://doi.org/10.24432/C53P47.
# ###############################################################################
# fetch dataset
superconductivty_data = fetch_ucirepo(id=464)
# data (as pandas dataframes)
A = superconductivty_data.data.features
b = superconductivty_data.data.targets
# metadata
print(superconductivty_data.metadata)
# variable information
print(superconductivty_data.variables)
A = np.array(A)
A = np.append(A,np.ones([A.shape[0],1]), axis=1)
b = np.array(b)
b = np.squeeze(b)
x = np.zeros((A.shape[1],1))
model = lsq_linear(A, b,tol=1e-10, lsq_solver='exact',method='bvls')
xstar = model.x