Exemple #1
0
from data_parser import DataParser
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

parser = DataParser('europe.csv')

matrix_non_standarized = np.matrix(parser.get_numerical_csv())

# Create a figure instance
fig = plt.figure(1, figsize=(9, 6))

# Create an axes instance
ax = fig.add_subplot(111)

## Custom x-axis labels
ax.set_xticklabels([
    'Area', 'GDP', 'Inflation', 'Life.expect', 'Military', 'Pop.growth',
    'Unemployment'
])

## add patch_artist=True option to ax.boxplot()
## to get fill color
bp = ax.boxplot(matrix_non_standarized, patch_artist=True)

## change outline color, fill color and linewidth of the boxes
for box in bp['boxes']:
    # change outline color
    box.set(color='#7570b3', linewidth=2)
    # change fill color
    box.set(facecolor='#1b9e77')
Exemple #2
0
    'GDP': matrix_for_correlation[1],
    'Inflation': matrix_for_correlation[2],
    'Life.expect': matrix_for_correlation[3],
    'Military': matrix_for_correlation[4],
    'Pop.growth': matrix_for_correlation[5],
    'Unemployment': matrix_for_correlation[6]
}

df = pd.DataFrame(matrix_for_correlation_with_keys, columns=[
                  'Area', 'GDP', 'Inflation', 'Life.expect', 'Military', 'Pop.growth', 'Unemployment'])

correlation_matrix = df.corr()
# If you want to show heatmap:


covariance_matrix = np.cov(np.array(parser.get_numerical_csv()).T)
print('COV', covariance_matrix)

autovals_corr, autovecs_corr = np.linalg.eig(correlation_matrix)

print('AUTOVALS | AUTOVECS, COR')
print(autovals_corr, autovecs_corr)

autovals_cov, autovecs_cov = np.linalg.eig(covariance_matrix)

print('AUTOVALS | AUTOVECS, COV')
print(autovals_cov, autovecs_cov)

# PCA
n_components = 7
pca = PCA(n_components=n_components)