Skip to content
Snippets Groups Projects
Commit 5ee800c9 authored by manxilin's avatar manxilin
Browse files

update

parent b5a18028
No related branches found
No related tags found
No related merge requests found
Showing
with 23 additions and 12 deletions
File added
File added
......@@ -9,10 +9,10 @@ import numpy as np
N = 1000
# Standard deviation of x1
s1 = 2
s1 = 10
# Standard deviation of x2
s2 = 3
s2 = 10
# Correlation between x1 and x2
corr = 0.5
......@@ -21,7 +21,7 @@ corr = 0.5
S = np.matrix([[s1*s1, corr*s1*s2], [corr*s1*s2, s2*s2]])
# Mean
mu = np.array([13, 17])
mu = np.array([5, 5])
# Number of bins in histogram
nbins = 20
......
......@@ -5,13 +5,12 @@ from matplotlib.pyplot import (figure, subplot, title, imshow, xticks, yticks,
import scipy.linalg as linalg
from scipy.io import loadmat
import numpy as np
# Digits to include in analysis (to include all: n = range(10))
n = [0]
n = [9]
# Load Matlab data file to python dict structure
# and extract variables of interest
traindata = loadmat('../Data/zipdata.mat')['traindata']
traindata = loadmat('Software toolboxes/02450ToolBox_Python/Data/zipdata.mat')['traindata']
X = traindata[:,1:]
y = traindata[:,0]
N, M = X.shape
......
......@@ -13,7 +13,7 @@ ngen = 10
# Load Matlab data file to python dict structure
# and extract variables of interest
traindata = loadmat('../Data/zipdata.mat')['traindata']
traindata = loadmat('Software toolboxes/02450ToolBox_Python/Data/zipdata.mat')['traindata']
X = traindata[:,1:]
y = traindata[:,0]
N, M = np.shape(X) #or X.shape
......
......@@ -4,7 +4,7 @@ import numpy as np
import xlrd
# Load xls sheet with data
doc = xlrd.open_workbook('../Data/iris.xls').sheet_by_index(0)
doc = xlrd.open_workbook('Software toolboxes/02450ToolBox_Python/Data/iris.xls').sheet_by_index(0)
# Extract attribute names
attributeNames = doc.row_values(0,0,4)
......
......@@ -3,6 +3,8 @@
from matplotlib.pyplot import figure, subplot, hist, xlabel, ylim, show
import numpy as np
# requires data from exercise 4.2.1
import sys
sys.path.append('Software toolboxes/02450ToolBox_Python/Scripts/')
from ex4_2_1 import *
figure(figsize=(8,7))
......
......@@ -3,6 +3,8 @@
from matplotlib.pyplot import boxplot, xticks, ylabel, title, show
# requires data from exercise 4.2.1
import sys
sys.path.append('Software toolboxes/02450ToolBox_Python/Scripts/')
from ex4_2_1 import *
boxplot(X)
......
......@@ -2,6 +2,8 @@
from matplotlib.pyplot import (figure, subplot, boxplot, title, xticks, ylim,
show)
# requires data from exercise 4.1.1
import sys
sys.path.append('Software toolboxes/02450ToolBox_Python/Scripts/')
from ex4_2_1 import *
figure(figsize=(14,7))
......
......@@ -4,6 +4,8 @@ from matplotlib.pyplot import (figure, subplot, plot, xlabel, ylabel,
xticks, yticks,legend,show)
# requires data from exercise 4.2.1
import sys
sys.path.append('Software toolboxes/02450ToolBox_Python/Scripts/')
from ex4_2_1 import *
figure(figsize=(12,10))
......
# Exercise 4.2.6
from matplotlib.pyplot import (figure, show, hold)
from matplotlib.pyplot import (figure, show)
from mpl_toolkits.mplot3d import Axes3D
# requires data from exercise 4.1.1
import sys
sys.path.append('Software toolboxes/02450ToolBox_Python/Scripts/')
from ex4_2_1 import *
# Indices of the variables to plot
......
......@@ -5,6 +5,8 @@ from matplotlib.pyplot import (figure, imshow, xticks, xlabel, ylabel, title,
from scipy.stats import zscore
# requires data from exercise 4.2.1
import sys
sys.path.append('Software toolboxes/02450ToolBox_Python/Scripts/')
from ex4_2_1 import *
X_standarized = zscore(X, ddof=1)
......
......@@ -7,7 +7,7 @@ from scipy.io import loadmat
from scipy.stats import zscore
# Load Matlab data file and extract variables of interest
mat_data = loadmat('../Data/wine.mat')
mat_data = loadmat('Software toolboxes/02450ToolBox_Python/Data/wine.mat')
X = mat_data['X']
y = mat_data['y'].squeeze()
C = mat_data['C'][0,0]
......
# exercise 4.3.2
from matplotlib.pyplot import (figure, hold, subplot, plot, legend, show,
from matplotlib.pyplot import (figure, subplot, plot, legend, show,
xlabel, ylabel, xticks, yticks, boxplot, setp,title,ylim)
import numpy as np
from scipy.io import loadmat
from scipy.stats import zscore
# Load Matlab data file and extract variables of interest
mat_data = loadmat('../Data/wine.mat')
mat_data = loadmat('Software toolboxes/02450ToolBox_Python/Data/wine.mat')
X = mat_data['X']
y = np.squeeze(mat_data['y'])
C = mat_data['C'][0,0]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment