Principal component analysis (PCA) on spectroscopy data

This notebook illustrates how to use the hoggorm package to carry out principal component analysis (PCA) on spectroscopy data. Furthermore, we will learn how to visualise the results of the PCA using the hoggormPlot package.


Import packages and prepare data

First import hoggorm for analysis of the data and hoggormPlot for plotting of the analysis results. We'll also import pandas such that we can read the data into a data frame. numpy is needed for checking dimensions of the data.


In [1]:
import hoggorm as ho
import hoggormplot as hop
import pandas as pd
import numpy as np

Next, load the spectroscopy data that we are going to analyse using hoggorm. After the data has been loaded into the pandas data frame, we'll display it in the notebook.


In [6]:
# Load data

# Insert code for reading data from other folder in repository instead of directly from same repository.
data_df = pd.read_csv('gasoline_NIR.txt', header=None, sep='\s+')

Let's have a look at the dimensions of the data frame.


In [7]:
np.shape(data_df)


Out[7]:
(60, 401)

The nipalsPCA class in hoggorm accepts only numpy arrays with numerical values and not pandas data frames. Therefore, the pandas data frame holding the imported data needs to be "taken apart" into three parts:

  • a numpy array holding the numeric values
  • a Python list holding variable (column) names
  • a Python list holding object (row) names.

The array with values will be used as input for the nipalsPCA class for analysis. The Python lists holding the variable and row names will be used later in the plotting function from the hoggormPlot package when visualising the results of the analysis. Below is the code needed to access both data, variable names and object names.


In [10]:
# Get the values from the data frame
data = data_df.values

Apply PCA to our data

Now, let's run PCA on the data using the nipalsPCA class. The documentation provides a description of the input parameters. Using input paramter arrX we define which numpy array we would like to analyse. By setting input parameter Xstand=False we make sure that the variables are only mean centered, not scaled to unit variance. This is the default setting and actually doesn't need to expressed explicitly. Setting paramter cvType=["loo"] we make sure that we compute the PCA model using full cross validation. "loo" means "Leave One Out". By setting paramter numpComp=4 we ask for four principal components (PC) to be computed.


In [12]:
model = ho.nipalsPCA(arrX=data, Xstand=False, cvType=["loo"], numComp=5)


loo
loo

That's it, the PCA model has been computed. Now we would like to inspect the results by visualising them. We can do this using the taylor-made plotting function for PCA from the separate hoggormPlot package. If we wish to plot the results for component 1 and component 2, we can do this by setting the input argument comp=[1, 2]. The input argument plots=[1, 6] lets the user define which plots are to be plotted. If this list for example contains value 1, the function will generate the scores plot for the model. If the list contains value 6, the function will generate a explained variance plot. The hoggormPlot documentation provides a description of input paramters.


In [15]:
hop.plot(model, comp=[1, 2], 
         plots=[1, 6])


It is also possible to generate the same plots one by one with specific plot functions as shown below.


In [19]:
hop.loadings(model, line=True)



Accessing numerical results

Now that we have visualised the PCA results, we may also want to access the numerical results. Below are some examples. For a complete list of accessible results, please see this part of the documentation.


In [21]:
# Get scores and store in numpy array
scores = model.X_scores()

# Get scores and store in pandas dataframe with row and column names
scores_df = pd.DataFrame(model.X_scores())
#scores_df.index = data_objNames
scores_df.columns = ['PC{0}'.format(x+1) for x in range(model.X_scores().shape[1])]
scores_df


Out[21]:
PC1 PC2 PC3 PC4 PC5
0 0.020082 0.073100 0.096431 -0.037799 0.046846
1 0.542646 0.046265 0.045296 -0.002835 0.000012
2 0.449275 0.044604 -0.054206 0.084612 -0.001227
3 0.376704 0.051102 0.104006 -0.053364 -0.010051
4 -0.182992 0.115471 0.057602 0.065753 -0.038813
5 0.109397 0.104524 0.100058 -0.013542 -0.010737
6 -0.111562 0.060955 0.022934 0.076916 -0.027543
7 0.212391 0.025322 -0.043598 0.068100 -0.015676
8 -0.031795 0.041594 0.010894 0.081882 -0.027163
9 -0.128297 0.043146 0.034463 0.067407 -0.034408
10 -0.330325 0.062721 0.072876 0.041560 -0.050676
11 -0.150899 0.092627 0.054870 0.034622 0.023315
12 0.187740 0.057718 -0.021295 0.019425 0.025586
13 0.383453 -0.021562 -0.036986 0.083399 -0.003030
14 0.638147 -0.001555 -0.104313 0.108991 0.029752
15 -0.007105 0.117427 0.064642 -0.048103 0.013449
16 -0.088702 0.017913 0.026664 0.047621 -0.014257
17 -0.047416 -0.015238 -0.019832 0.048342 -0.034342
18 0.181089 -0.035604 -0.003778 -0.045163 -0.031364
19 0.178874 -0.019445 -0.077394 0.038980 -0.026786
20 -0.027648 -0.035444 -0.019790 -0.029763 0.005307
21 0.071045 0.091036 0.055278 0.052574 0.046931
22 0.077800 -0.043384 -0.032646 -0.011096 0.016625
23 0.031985 -0.031871 -0.046500 -0.003679 0.011674
24 0.041228 -0.024730 -0.033556 -0.021070 -0.009628
25 -0.060019 0.028806 -0.033591 0.038877 -0.030129
26 0.016830 -0.024295 0.010075 -0.019613 -0.034138
27 -0.038189 -0.002290 0.008420 -0.051550 -0.035685
28 0.023648 -0.022413 -0.013838 -0.036173 -0.029122
29 -0.105895 0.012047 -0.004296 -0.045851 -0.040868
30 -0.047441 0.000033 -0.008697 -0.042641 -0.032110
31 0.187534 -0.022869 0.013618 -0.092517 -0.024474
32 0.146407 -0.068205 -0.003919 -0.098227 -0.033467
33 0.195055 -0.024977 0.024834 -0.086974 -0.021873
34 0.159787 0.002144 0.018705 -0.099364 -0.022671
35 -0.081573 -0.017168 -0.027075 0.013575 0.015423
36 -0.015318 0.059270 0.044154 -0.072180 -0.021116
37 -0.106706 0.100428 -0.038002 -0.002219 0.026249
38 0.139389 0.065463 -0.095523 0.007187 0.031572
39 -0.055542 0.077330 -0.067287 -0.004627 0.023319
40 -0.446575 0.068214 0.044731 0.026488 0.007700
41 -0.227192 0.036635 0.025081 0.050707 0.001265
42 -0.092009 0.134978 0.019401 0.034867 0.025334
43 0.117264 0.081724 0.017791 -0.071819 0.027142
44 -0.237260 0.018575 -0.018433 0.017841 -0.032216
45 -0.223863 -0.017054 -0.133874 -0.050688 0.000184
46 -0.214449 0.060487 -0.128651 -0.063840 0.024707
47 -0.038774 -0.028185 -0.161677 -0.015499 0.026029
48 -0.246086 0.037270 -0.124576 -0.059362 0.022400
49 -0.299978 -0.020337 -0.138278 -0.058612 0.016963
50 -0.090237 -0.132572 0.033165 0.056402 0.019897
51 -0.258698 -0.035266 0.062520 0.004572 0.046272
52 -0.199072 -0.130261 0.052066 0.061786 0.018574
53 0.188517 -0.226176 0.078105 -0.018149 0.011294
54 0.001480 -0.121921 0.138903 -0.004198 0.045438
55 0.034911 0.024347 0.109181 -0.064924 0.066777
56 0.028317 -0.274534 -0.001543 0.039919 -0.002510
57 -0.143540 -0.135706 0.048483 0.000467 0.016535
58 -0.307520 -0.151975 -0.017598 0.051528 0.009738
59 -0.098318 -0.168236 0.015503 0.001042 -0.006231

In [22]:
help(ho.nipalsPCA.X_scores)


Help on function X_scores in module hoggorm.pca:

X_scores(self)
    Returns array holding scores T. First column holds scores for
    component 1, second column holds scores for component 2, etc.


In [23]:
# Dimension of the scores
np.shape(model.X_scores())


Out[23]:
(60, 5)

We see that the numpy array holds the scores for four components as required when computing the PCA model.


In [27]:
# Get loadings and store in numpy array
loadings = model.X_loadings()

# Get loadings and store in pandas dataframe with row and column names
loadings_df = pd.DataFrame(model.X_loadings()) 
#loadings_df.index = data_varNames
loadings_df.columns = ['PC{0}'.format(x+1) for x in range(model.X_loadings().shape[1])]
loadings_df


Out[27]:
PC1 PC2 PC3 PC4 PC5
0 0.010761 0.022410 0.033510 0.039027 0.041516
1 0.010313 0.021588 0.030888 0.040657 0.038927
2 0.011046 0.022215 0.029598 0.041633 0.035870
3 0.012475 0.024319 0.027347 0.045222 0.031199
4 0.013082 0.021474 0.025045 0.045259 0.035395
5 0.014159 0.022623 0.023366 0.045839 0.035860
6 0.013685 0.018651 0.022783 0.049866 0.043444
7 0.014221 0.022608 0.023914 0.044390 0.039649
8 0.013137 0.019569 0.029728 0.040631 0.033897
9 0.012153 0.020054 0.034402 0.030317 0.039549
10 0.011833 0.018964 0.038012 0.023652 0.033032
11 0.011517 0.018122 0.042049 0.020911 0.034410
12 0.011297 0.018341 0.043471 0.022028 0.036470
13 0.010584 0.017168 0.042978 0.022732 0.035776
14 0.010523 0.018850 0.041188 0.024057 0.033013
15 0.010191 0.020333 0.038235 0.021397 0.031560
16 0.009702 0.019763 0.038111 0.022951 0.031664
17 0.009874 0.019663 0.037252 0.024125 0.033766
18 0.009604 0.020898 0.036368 0.025869 0.029849
19 0.009308 0.020849 0.033899 0.027340 0.031473
20 0.009309 0.021116 0.033105 0.027756 0.032123
21 0.009072 0.021643 0.032641 0.029110 0.031637
22 0.008492 0.020763 0.032456 0.031100 0.030221
23 0.008263 0.022119 0.032671 0.031071 0.030439
24 0.008224 0.022728 0.033646 0.033244 0.028952
25 0.008109 0.022043 0.032851 0.032624 0.029149
26 0.007509 0.021407 0.031774 0.032708 0.032481
27 0.007734 0.023586 0.031442 0.030132 0.030561
28 0.007575 0.023376 0.031838 0.031354 0.027900
29 0.007508 0.023528 0.031659 0.033006 0.029653
... ... ... ... ... ...
371 -0.058063 0.030676 0.122583 -0.059704 -0.020427
372 -0.071378 0.032703 0.101851 -0.039050 -0.010061
373 -0.079272 0.036961 0.090956 -0.021982 -0.004134
374 -0.083489 0.040491 0.079749 -0.015572 -0.022317
375 -0.088267 0.042514 0.076098 -0.014075 -0.023332
376 -0.091112 0.040744 0.082183 -0.014404 -0.035643
377 -0.099531 0.043604 0.079853 -0.013647 -0.034683
378 -0.115351 0.044113 0.084350 -0.004084 -0.029785
379 -0.136418 0.040739 0.076814 -0.012732 -0.006682
380 -0.157427 0.034603 0.087621 0.010666 -0.031447
381 -0.181087 0.037014 0.090378 0.033724 -0.038384
382 -0.217112 0.033769 0.080569 0.047116 -0.018230
383 -0.239899 0.039866 0.053926 0.040353 0.025269
384 -0.255085 0.032248 0.066375 0.057970 0.047916
385 -0.259048 0.040755 0.026546 0.025177 0.030153
386 -0.244414 0.039376 0.070818 0.050437 -0.006634
387 -0.237757 0.033854 0.096441 0.055773 -0.043270
388 -0.214056 0.048676 0.037215 -0.014064 -0.016176
389 -0.184058 0.051850 0.063721 -0.012295 0.023153
390 -0.158723 0.071630 0.057600 -0.012336 0.081500
391 -0.126247 0.095758 0.043974 -0.013859 -0.117570
392 -0.109979 0.085793 -0.016974 -0.042322 0.178112
393 -0.097485 0.115826 -0.061785 -0.069528 0.149942
394 -0.061525 0.211030 -0.041989 -0.063295 0.034113
395 -0.023988 0.357850 -0.151683 -0.088816 -0.309900
396 0.004908 0.339741 -0.200986 -0.152534 -0.588274
397 -0.041207 0.276329 -0.281156 -0.198780 0.535838
398 -0.026630 0.231176 -0.241345 -0.202683 0.170423
399 -0.000669 0.277759 -0.075110 -0.144923 0.043571
400 -0.010330 0.276600 -0.167326 -0.150471 0.167772

401 rows × 5 columns


In [28]:
help(ho.nipalsPCA.X_loadings)


Help on function X_loadings in module hoggorm.pca:

X_loadings(self)
    Returns array holding loadings P of array X. Rows represent variables
    and columns represent components. First column holds loadings for
    component 1, second column holds scores for component 2, etc.


In [29]:
np.shape(model.X_loadings())


Out[29]:
(401, 5)

In [30]:
# Get loadings and store in numpy array
loadings = model.X_corrLoadings()

# Get loadings and store in pandas dataframe with row and column names
loadings_df = pd.DataFrame(model.X_corrLoadings()) 
#loadings_df.index = data_varNames
loadings_df.columns = ['PC{0}'.format(x+1) for x in range(model.X_corrLoadings().shape[1])]
loadings_df


Out[30]:
PC1 PC2 PC3 PC4 PC5
0 0.502996 0.414017 0.484784 0.459178 0.253604
1 0.496101 0.410447 0.459857 0.492293 0.244697
2 0.523029 0.415747 0.433729 0.496223 0.221940
3 0.565736 0.435909 0.383789 0.516251 0.184878
4 0.597914 0.387894 0.354216 0.520687 0.211384
5 0.623573 0.393795 0.318431 0.508199 0.206368
6 0.604709 0.325726 0.311509 0.554671 0.250854
7 0.620098 0.389628 0.322674 0.487237 0.225915
8 0.606568 0.357106 0.424805 0.472232 0.204521
9 0.579231 0.377743 0.507474 0.363661 0.246333
10 0.576842 0.365359 0.573566 0.290162 0.210438
11 0.552626 0.343640 0.624518 0.252473 0.215777
12 0.535494 0.343593 0.637835 0.262740 0.225938
13 0.518008 0.332057 0.651067 0.279943 0.228825
14 0.518668 0.367171 0.628353 0.298380 0.212636
15 0.517930 0.408403 0.601468 0.273651 0.209600
16 0.500130 0.402618 0.608088 0.297722 0.213289
17 0.506369 0.398538 0.591331 0.311364 0.226290
18 0.493182 0.424145 0.578059 0.334334 0.200292
19 0.490109 0.433886 0.552472 0.362323 0.216554
20 0.490712 0.439904 0.540091 0.368217 0.221253
21 0.478438 0.451142 0.532813 0.386408 0.218022
22 0.456395 0.440996 0.539835 0.420670 0.212207
23 0.438455 0.463896 0.536575 0.414985 0.211049
24 0.428142 0.467638 0.542115 0.435602 0.196922
25 0.431751 0.463845 0.541333 0.437189 0.202773
26 0.410530 0.462567 0.537649 0.450087 0.232037
27 0.417684 0.503451 0.525544 0.409582 0.215652
28 0.409257 0.499140 0.532361 0.426353 0.196923
29 0.403647 0.499941 0.526789 0.446636 0.208295
... ... ... ... ... ...
371 -0.795561 0.166091 0.519969 -0.206051 -0.036569
372 -0.888902 0.160951 0.392666 -0.122511 -0.016377
373 -0.920237 0.169575 0.326862 -0.064308 -0.006285
374 -0.936794 0.179564 0.277001 -0.044038 -0.032744
375 -0.945323 0.179959 0.252285 -0.037996 -0.032672
376 -0.943833 0.166815 0.263540 -0.037608 -0.048271
377 -0.951827 0.164811 0.236390 -0.032897 -0.043360
378 -0.961086 0.145267 0.217549 -0.008602 -0.032449
379 -0.973893 0.114953 0.169754 -0.022915 -0.006242
380 -0.979956 0.085133 0.168836 0.016689 -0.025601
381 -0.981971 0.079331 0.151701 0.046017 -0.027225
382 -0.988198 0.060752 0.113509 0.053973 -0.010865
383 -0.992219 0.065178 0.069031 0.042005 0.013643
384 -0.990363 0.049491 0.079761 0.056646 0.024302
385 -0.994487 0.061851 0.031538 0.024327 0.015129
386 -0.988232 0.062932 0.088625 0.051328 -0.003503
387 -0.981587 0.055244 0.123242 0.057954 -0.023337
388 -0.983149 0.088376 0.052908 -0.016270 -0.009682
389 -0.972580 0.108297 0.104228 -0.016378 0.016043
390 -0.946047 0.168759 0.106265 -0.018539 0.063580
391 -0.907288 0.272021 0.097806 -0.025074 -0.110380
392 -0.889084 0.274163 -0.042494 -0.086160 0.188295
393 -0.820403 0.385326 -0.160980 -0.147310 0.165055
394 -0.496718 0.673463 -0.104993 -0.128639 0.036109
395 -0.141905 0.836769 -0.277835 -0.132183 -0.239548
396 0.027020 0.739548 -0.342668 -0.211353 -0.423593
397 -0.237065 0.628425 -0.500731 -0.287884 0.402993
398 -0.184102 0.631767 -0.516502 -0.352696 0.154094
399 -0.005140 0.841910 -0.178337 -0.279764 0.043640
400 -0.076794 0.812752 -0.385076 -0.281555 0.163119

401 rows × 5 columns


In [31]:
help(ho.nipalsPCA.X_corrLoadings)


Help on function X_corrLoadings in module hoggorm.pca:

X_corrLoadings(self)
    Returns array holding correlation loadings of array X. First column
    holds correlation loadings for component 1, second column holds
    correlation loadings for component 2, etc.


In [32]:
# Get calibrated explained variance of each component
calExplVar = model.X_calExplVar()

# Get calibrated explained variance and store in pandas dataframe with row and column names
calExplVar_df = pd.DataFrame(model.X_calExplVar())
calExplVar_df.columns = ['calibrated explained variance']
calExplVar_df.index = ['PC{0}'.format(x+1) for x in range(model.X_loadings().shape[1])]
calExplVar_df


Out[32]:
calibrated explained variance
PC1 72.565138
PC2 11.338019
PC3 6.954257
PC4 4.599826
PC5 1.240297

In [33]:
help(ho.nipalsPCA.X_calExplVar)


Help on function X_calExplVar in module hoggorm.pca:

X_calExplVar(self)
    Returns a list holding the calibrated explained variance for
    each component. First number in list is for component 1, second number
    for component 2, etc.


In [34]:
# Get cumulative calibrated explained variance
cumCalExplVar = model.X_cumCalExplVar()

# Get cumulative calibrated explained variance and store in pandas dataframe with row and column names
cumCalExplVar_df = pd.DataFrame(model.X_cumCalExplVar())
cumCalExplVar_df.columns = ['cumulative calibrated explained variance']
cumCalExplVar_df.index = ['PC{0}'.format(x) for x in range(model.X_loadings().shape[1] + 1)]
cumCalExplVar_df


Out[34]:
cumulative calibrated explained variance
PC0 0.000000
PC1 72.565138
PC2 83.903157
PC3 90.857413
PC4 95.457240
PC5 96.697537

In [35]:
help(ho.nipalsPCA.X_cumCalExplVar)


Help on function X_cumCalExplVar in module hoggorm.pca:

X_cumCalExplVar(self)
    Returns a list holding the cumulative validated explained variance
    for array X after each component. First number represents zero
    components, second number represents component 1, etc.


In [37]:
# Get cumulative calibrated explained variance for each variable
cumCalExplVar_ind = model.X_cumCalExplVar_indVar()

# Get cumulative calibrated explained variance for each variable and store in pandas dataframe with row and column names
cumCalExplVar_ind_df = pd.DataFrame(model.X_cumCalExplVar_indVar()) 
#cumCalExplVar_ind_df.columns = data_varNames
cumCalExplVar_ind_df.index = ['PC{0}'.format(x) for x in range(model.X_loadings().shape[1] + 1)]
cumCalExplVar_ind_df


Out[37]:
0 1 2 3 4 5 6 7 8 9 ... 391 392 393 394 395 396 397 398 399 400
PC0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
PC1 25.300542 24.611602 27.355922 32.005666 35.750065 38.884360 36.567342 38.452109 36.792509 33.550817 ... 82.317118 79.047055 67.306082 24.672910 2.013696 0.073010 5.619993 3.389344 0.002642 0.589727
PC2 42.441993 41.458724 44.640897 51.007847 50.796701 54.392295 47.177506 53.633605 49.545416 47.820232 ... 89.716152 86.563084 82.153037 70.027533 72.031710 54.766212 45.111443 43.302068 70.883884 66.646222
PC3 65.948096 62.609792 63.457029 65.741002 63.346670 64.534962 56.883549 64.048268 67.594733 73.577576 ... 90.673333 86.743400 84.743118 71.128313 79.745782 66.502726 70.177623 69.972282 74.060959 81.467589
PC4 87.040973 86.853587 88.088902 92.399968 90.465091 90.367660 87.656014 87.794167 89.902585 86.809442 ... 90.736111 87.485897 86.914025 72.783629 81.494393 70.972463 78.470780 82.418617 81.889604 89.398996
PC5 93.476085 92.844979 93.018051 95.820907 94.936826 94.629706 93.953098 92.901335 94.088453 92.880195 ... 91.954581 91.030901 89.637574 72.913872 87.233677 88.918380 94.707556 84.791428 82.079672 92.058344

6 rows × 401 columns


In [38]:
help(ho.nipalsPCA.X_cumCalExplVar_indVar)


Help on function X_cumCalExplVar_indVar in module hoggorm.pca:

X_cumCalExplVar_indVar(self)
    Returns an array holding the cumulative calibrated explained variance
    for each variable in X after each component. First row represents zero
    components, second row represents one component, third row represents
    two components, etc. Columns represent variables.


In [39]:
# Get calibrated predicted X for a given number of components

# Predicted X from calibration using 1 component
X_from_1_component = model.X_predCal()[1]

# Predicted X from calibration using 1 component stored in pandas data frame with row and columns names
X_from_1_component_df = pd.DataFrame(model.X_predCal()[1])
#X_from_1_component_df.index = data_objNames
#X_from_1_component_df.columns = data_varNames
X_from_1_component_df


Out[39]:
0 1 2 3 4 5 6 7 8 9 ... 391 392 393 394 395 396 397 398 399 400
0 -0.052611 -0.047228 -0.043363 -0.038934 -0.034474 -0.032126 -0.030556 -0.033291 -0.036478 -0.039515 ... 1.204451 1.215202 1.236595 1.252604 1.262773 1.264311 1.231643 1.225628 1.219023 1.201453
1 -0.046988 -0.041839 -0.037591 -0.032415 -0.027637 -0.024727 -0.023405 -0.025859 -0.029614 -0.033164 ... 1.138479 1.157731 1.185653 1.220453 1.250238 1.266876 1.210109 1.211712 1.218673 1.196055
2 -0.047993 -0.042802 -0.038623 -0.033580 -0.028859 -0.026049 -0.024683 -0.027187 -0.030840 -0.034299 ... 1.150267 1.168000 1.194755 1.226198 1.252478 1.266418 1.213957 1.214199 1.218736 1.197020
3 -0.048773 -0.043551 -0.039424 -0.034485 -0.029808 -0.027076 -0.025676 -0.028219 -0.031793 -0.035181 ... 1.159429 1.175981 1.201830 1.230663 1.254219 1.266062 1.216947 1.216131 1.218784 1.197769
4 -0.054796 -0.049323 -0.045606 -0.041467 -0.037130 -0.035001 -0.033336 -0.036178 -0.039146 -0.041983 ... 1.230089 1.237536 1.256392 1.265098 1.267644 1.263315 1.240011 1.231036 1.219159 1.203551
5 -0.051650 -0.046307 -0.042377 -0.037819 -0.033305 -0.030861 -0.029334 -0.032020 -0.035305 -0.038430 ... 1.193176 1.205379 1.227888 1.247109 1.260631 1.264750 1.227962 1.223250 1.218963 1.200531
6 -0.054027 -0.048586 -0.044817 -0.040576 -0.036196 -0.033990 -0.032358 -0.035163 -0.038208 -0.041115 ... 1.221071 1.229680 1.249428 1.260703 1.265931 1.263665 1.237067 1.229134 1.219111 1.202813
7 -0.050542 -0.045245 -0.041239 -0.036535 -0.031958 -0.029403 -0.027925 -0.030556 -0.033952 -0.037178 ... 1.180173 1.194052 1.217848 1.240772 1.258160 1.265255 1.223718 1.220507 1.218894 1.199467
8 -0.053169 -0.047763 -0.043936 -0.039581 -0.035152 -0.032860 -0.031266 -0.034028 -0.037160 -0.040146 ... 1.211001 1.220908 1.241652 1.255795 1.264017 1.264057 1.233780 1.227010 1.219058 1.201989
9 -0.054208 -0.048759 -0.045002 -0.040785 -0.036415 -0.034227 -0.032587 -0.035401 -0.038427 -0.041319 ... 1.223184 1.231521 1.251060 1.261733 1.266332 1.263583 1.237757 1.229579 1.219122 1.202986
10 -0.056381 -0.050842 -0.047234 -0.043305 -0.039058 -0.037087 -0.035352 -0.038274 -0.041081 -0.043774 ... 1.248689 1.253740 1.270755 1.274162 1.271178 1.262591 1.246082 1.234959 1.219258 1.205073
11 -0.054451 -0.048992 -0.045252 -0.041067 -0.036711 -0.034547 -0.032896 -0.035722 -0.038724 -0.041593 ... 1.226037 1.234007 1.253263 1.263123 1.266874 1.263472 1.238688 1.230181 1.219138 1.203220
12 -0.050807 -0.045499 -0.041511 -0.036842 -0.032280 -0.029752 -0.028262 -0.030906 -0.034276 -0.037478 ... 1.183285 1.196763 1.220251 1.242289 1.258751 1.265134 1.224734 1.221163 1.218911 1.199721
13 -0.048701 -0.043481 -0.039350 -0.034401 -0.029720 -0.026981 -0.025584 -0.028123 -0.031705 -0.035099 ... 1.158577 1.175239 1.201172 1.230248 1.254057 1.266095 1.216669 1.215951 1.218780 1.197700
14 -0.045960 -0.040854 -0.036536 -0.031223 -0.026388 -0.023375 -0.022098 -0.024501 -0.028359 -0.032004 ... 1.126423 1.147228 1.176343 1.214578 1.247947 1.267345 1.206174 1.209169 1.218610 1.195069
15 -0.052903 -0.047509 -0.043664 -0.039273 -0.034829 -0.032511 -0.030928 -0.033677 -0.036835 -0.039846 ... 1.207884 1.218192 1.239245 1.254276 1.263425 1.264178 1.232763 1.226352 1.219041 1.201734
16 -0.053781 -0.048350 -0.044565 -0.040291 -0.035897 -0.033666 -0.032045 -0.034838 -0.037907 -0.040837 ... 1.218185 1.227166 1.247200 1.259297 1.265383 1.263777 1.236125 1.228525 1.219096 1.202577
17 -0.053337 -0.047924 -0.044109 -0.039776 -0.035357 -0.033081 -0.031480 -0.034250 -0.037365 -0.040336 ... 1.212973 1.222626 1.243175 1.256757 1.264392 1.263980 1.234424 1.227426 1.219068 1.202151
18 -0.050878 -0.045568 -0.041585 -0.036925 -0.032367 -0.029846 -0.028353 -0.031001 -0.034363 -0.037558 ... 1.184125 1.197495 1.220899 1.242698 1.258911 1.265102 1.225008 1.221340 1.218915 1.199790
19 -0.050902 -0.045591 -0.041609 -0.036953 -0.032396 -0.029877 -0.028383 -0.031032 -0.034392 -0.037585 ... 1.184404 1.197739 1.221115 1.242834 1.258964 1.265091 1.225099 1.221399 1.218917 1.199813
20 -0.053124 -0.047721 -0.043890 -0.039529 -0.035098 -0.032801 -0.031210 -0.033969 -0.037105 -0.040095 ... 1.210477 1.220452 1.241248 1.255540 1.263918 1.264077 1.233609 1.226899 1.219055 1.201946
21 -0.052062 -0.046703 -0.042800 -0.038298 -0.033807 -0.031404 -0.029859 -0.032566 -0.035809 -0.038896 ... 1.198017 1.209597 1.231627 1.249468 1.261551 1.264561 1.229543 1.224271 1.218989 1.200927
22 -0.051990 -0.046633 -0.042726 -0.038214 -0.033719 -0.031308 -0.029767 -0.032470 -0.035720 -0.038814 ... 1.197165 1.208855 1.230968 1.249053 1.261389 1.264595 1.229264 1.224091 1.218985 1.200857
23 -0.052483 -0.047106 -0.043232 -0.038785 -0.034318 -0.031957 -0.030394 -0.033121 -0.036322 -0.039371 ... 1.202949 1.213893 1.235435 1.251871 1.262488 1.264370 1.231152 1.225311 1.219015 1.201330
24 -0.052383 -0.047010 -0.043130 -0.038670 -0.034197 -0.031826 -0.030267 -0.032990 -0.036200 -0.039258 ... 1.201782 1.212877 1.234534 1.251303 1.262266 1.264415 1.230771 1.225065 1.219009 1.201235
25 -0.053473 -0.048054 -0.044248 -0.039933 -0.035522 -0.033260 -0.031653 -0.034430 -0.037531 -0.040489 ... 1.214564 1.224012 1.244404 1.257532 1.264694 1.263918 1.234943 1.227761 1.219077 1.202281
26 -0.052646 -0.047262 -0.043399 -0.038974 -0.034516 -0.032172 -0.030601 -0.033337 -0.036521 -0.039555 ... 1.204862 1.215560 1.236912 1.252804 1.262851 1.264295 1.231777 1.225715 1.219025 1.201487
27 -0.053238 -0.047829 -0.044007 -0.039661 -0.035236 -0.032951 -0.031354 -0.034119 -0.037244 -0.040223 ... 1.211808 1.221611 1.242276 1.256189 1.264171 1.264025 1.234044 1.227180 1.219062 1.202055
28 -0.052573 -0.047192 -0.043324 -0.038889 -0.034427 -0.032075 -0.030508 -0.033240 -0.036431 -0.039472 ... 1.204001 1.214810 1.236248 1.252384 1.262688 1.264329 1.231496 1.225533 1.219021 1.201417
29 -0.053966 -0.048528 -0.044755 -0.040505 -0.036122 -0.033909 -0.032280 -0.035082 -0.038133 -0.041046 ... 1.220355 1.229057 1.248876 1.260354 1.265795 1.263693 1.236834 1.228983 1.219107 1.202755
30 -0.053337 -0.047925 -0.044109 -0.039776 -0.035357 -0.033082 -0.031480 -0.034251 -0.037365 -0.040336 ... 1.212976 1.222628 1.243178 1.256758 1.264393 1.263980 1.234425 1.227426 1.219068 1.202151
31 -0.050809 -0.045501 -0.041514 -0.036845 -0.032283 -0.029755 -0.028265 -0.030909 -0.034279 -0.037480 ... 1.183311 1.196786 1.220271 1.242301 1.258756 1.265133 1.224742 1.221169 1.218911 1.199724
32 -0.051252 -0.045926 -0.041968 -0.037358 -0.032821 -0.030337 -0.028828 -0.031494 -0.034819 -0.037980 ... 1.188503 1.201309 1.224280 1.244832 1.259743 1.264931 1.226437 1.222264 1.218939 1.200148
33 -0.050728 -0.045424 -0.041431 -0.036751 -0.032185 -0.029648 -0.028162 -0.030802 -0.034180 -0.037389 ... 1.182361 1.195959 1.219538 1.241839 1.258576 1.265170 1.224432 1.220968 1.218906 1.199646
34 -0.051108 -0.045788 -0.041820 -0.037191 -0.032646 -0.030148 -0.028645 -0.031304 -0.034643 -0.037817 ... 1.186814 1.199838 1.222976 1.244008 1.259422 1.264997 1.225886 1.221908 1.218930 1.200010
35 -0.053705 -0.048277 -0.044486 -0.040202 -0.035804 -0.033565 -0.031948 -0.034736 -0.037814 -0.040751 ... 1.217285 1.226382 1.246505 1.258858 1.265212 1.263812 1.235831 1.228335 1.219091 1.202503
36 -0.052992 -0.047593 -0.043754 -0.039375 -0.034937 -0.032627 -0.031041 -0.033794 -0.036943 -0.039945 ... 1.208920 1.219096 1.240046 1.254782 1.263622 1.264138 1.233101 1.226571 1.219047 1.201819
37 -0.053975 -0.048536 -0.044764 -0.040515 -0.036132 -0.033921 -0.032292 -0.035094 -0.038144 -0.041056 ... 1.220458 1.229146 1.248955 1.260404 1.265814 1.263689 1.236867 1.229004 1.219108 1.202763
38 -0.051327 -0.045998 -0.042045 -0.037445 -0.032913 -0.030436 -0.028924 -0.031594 -0.034911 -0.038065 ... 1.189389 1.202081 1.224964 1.245263 1.259911 1.264897 1.226726 1.222451 1.218943 1.200221
39 -0.053425 -0.048008 -0.044199 -0.039877 -0.035463 -0.033196 -0.031591 -0.034366 -0.037472 -0.040434 ... 1.213999 1.223519 1.243967 1.257257 1.264587 1.263940 1.234759 1.227642 1.219074 1.202235
40 -0.057632 -0.052041 -0.048518 -0.044755 -0.040579 -0.038733 -0.036943 -0.039927 -0.042609 -0.045187 ... 1.263365 1.266525 1.282087 1.281315 1.273967 1.262021 1.250872 1.238055 1.219336 1.206274
41 -0.055272 -0.049778 -0.046095 -0.042018 -0.037709 -0.035627 -0.033940 -0.036807 -0.039727 -0.042520 ... 1.235669 1.242397 1.260701 1.267817 1.268705 1.263098 1.241832 1.232213 1.219189 1.204008
42 -0.053817 -0.048384 -0.044601 -0.040332 -0.035940 -0.033713 -0.032090 -0.034885 -0.037951 -0.040878 ... 1.218602 1.227530 1.247522 1.259500 1.265462 1.263761 1.236262 1.228613 1.219098 1.202611
43 -0.051565 -0.046226 -0.042290 -0.037721 -0.033202 -0.030750 -0.029226 -0.031909 -0.035202 -0.038334 ... 1.192182 1.204514 1.227121 1.246625 1.260442 1.264788 1.227638 1.223040 1.218958 1.200449
44 -0.055380 -0.049882 -0.046206 -0.042144 -0.037840 -0.035769 -0.034078 -0.036950 -0.039859 -0.042643 ... 1.236940 1.243505 1.261682 1.268437 1.268946 1.263048 1.242247 1.232481 1.219195 1.204112
45 -0.055236 -0.049744 -0.046058 -0.041977 -0.037665 -0.035580 -0.033895 -0.036760 -0.039683 -0.042480 ... 1.235249 1.242031 1.260376 1.267612 1.268625 1.263114 1.241695 1.232124 1.219186 1.203973
46 -0.055135 -0.049647 -0.045954 -0.041859 -0.037542 -0.035446 -0.033766 -0.036626 -0.039559 -0.042366 ... 1.234060 1.240996 1.259458 1.267033 1.268399 1.263160 1.241307 1.231874 1.219180 1.203876
47 -0.053244 -0.047835 -0.044013 -0.039668 -0.035244 -0.032959 -0.031362 -0.034128 -0.037251 -0.040231 ... 1.211882 1.221675 1.242333 1.256225 1.264185 1.264022 1.234068 1.227195 1.219063 1.202061
48 -0.055475 -0.049973 -0.046303 -0.042254 -0.037956 -0.035894 -0.034199 -0.037076 -0.039975 -0.042750 ... 1.238054 1.244475 1.262543 1.268980 1.269158 1.263005 1.242611 1.232716 1.219201 1.204203
49 -0.056055 -0.050529 -0.046898 -0.042926 -0.038661 -0.036657 -0.034936 -0.037842 -0.040683 -0.043405 ... 1.244858 1.250402 1.267796 1.272295 1.270451 1.262740 1.244831 1.234151 1.219237 1.204760
50 -0.053798 -0.048366 -0.044582 -0.040310 -0.035917 -0.033688 -0.032066 -0.034859 -0.037927 -0.040856 ... 1.218379 1.227335 1.247350 1.259391 1.265419 1.263770 1.236188 1.228566 1.219097 1.202593
51 -0.055611 -0.050103 -0.046443 -0.042411 -0.038121 -0.036073 -0.034372 -0.037255 -0.040141 -0.042903 ... 1.239646 1.245862 1.263772 1.269756 1.269460 1.262943 1.243130 1.233052 1.219210 1.204333
52 -0.054969 -0.049488 -0.045784 -0.041668 -0.037341 -0.035229 -0.033556 -0.036407 -0.039357 -0.042179 ... 1.232119 1.239305 1.257959 1.266087 1.268030 1.263236 1.240673 1.231464 1.219170 1.203717
53 -0.050798 -0.045491 -0.041503 -0.036832 -0.032270 -0.029741 -0.028251 -0.030895 -0.034266 -0.037468 ... 1.183187 1.196678 1.220175 1.242241 1.258733 1.265138 1.224702 1.221143 1.218910 1.199713
54 -0.052811 -0.047420 -0.043569 -0.039166 -0.034717 -0.032389 -0.030811 -0.033555 -0.036723 -0.039741 ... 1.206800 1.217248 1.238409 1.253748 1.263219 1.264220 1.232409 1.226123 1.219036 1.201646
55 -0.052451 -0.047075 -0.043199 -0.038749 -0.034280 -0.031916 -0.030353 -0.033080 -0.036283 -0.039335 ... 1.202579 1.213571 1.235149 1.251691 1.262417 1.264384 1.231031 1.225233 1.219013 1.201300
56 -0.052522 -0.047143 -0.043272 -0.038831 -0.034366 -0.032009 -0.030444 -0.033173 -0.036370 -0.039415 ... 1.203412 1.214297 1.235792 1.252097 1.262576 1.264352 1.231303 1.225409 1.219018 1.201368
57 -0.054372 -0.048916 -0.045171 -0.040975 -0.036614 -0.034442 -0.032796 -0.035617 -0.038628 -0.041504 ... 1.225108 1.233197 1.252546 1.262671 1.266698 1.263508 1.238385 1.229985 1.219133 1.203144
58 -0.056136 -0.050607 -0.046982 -0.043020 -0.038760 -0.036764 -0.035040 -0.037949 -0.040782 -0.043497 ... 1.245810 1.251232 1.268531 1.272759 1.270631 1.262703 1.245142 1.234352 1.219242 1.204838
59 -0.053885 -0.048449 -0.044671 -0.040411 -0.036023 -0.033802 -0.032177 -0.034974 -0.038034 -0.040954 ... 1.219399 1.228224 1.248137 1.259888 1.265613 1.263730 1.236522 1.228781 1.219102 1.202676

60 rows × 401 columns


In [40]:
# Get predicted X for a given number of components

# Predicted X from calibration using 4 components
X_from_4_component = model.X_predCal()[4]

# Predicted X from calibration using 1 component stored in pandas data frame with row and columns names
X_from_4_component_df = pd.DataFrame(model.X_predCal()[4])
#X_from_4_component_df.index = data_objNames
#X_from_4_component_df.columns = data_varNames
X_from_4_component_df


Out[40]:
0 1 2 3 4 5 6 7 8 9 ... 391 392 393 394 395 396 397 398 399 400
0 -0.049217 -0.044208 -0.040459 -0.036228 -0.032200 -0.029951 -0.028881 -0.031010 -0.033717 -0.035878 ... 1.216216 1.221437 1.241732 1.266374 1.277662 1.275531 1.232244 1.226915 1.237562 1.211225
1 -0.044544 -0.039557 -0.035341 -0.030179 -0.025638 -0.022752 -0.021652 -0.023856 -0.027477 -0.030764 ... 1.144941 1.161052 1.188410 1.228494 1.260175 1.273923 1.210722 1.212050 1.228533 1.201700
2 -0.045507 -0.040074 -0.035713 -0.030151 -0.025429 -0.022428 -0.020867 -0.023719 -0.028141 -0.032704 ... 1.150982 1.169166 1.197388 1.232531 1.269147 1.279560 1.224703 1.220443 1.222934 1.205696
3 -0.046226 -0.041404 -0.037432 -0.032811 -0.028521 -0.025936 -0.025014 -0.026945 -0.029870 -0.032196 ... 1.169635 1.180859 1.205033 1.240457 1.261469 1.270659 1.212434 1.213659 1.232900 1.202531
4 -0.047712 -0.042377 -0.038599 -0.034110 -0.030232 -0.028029 -0.026591 -0.029272 -0.032502 -0.035692 ... 1.242768 1.243682 1.261636 1.282885 1.294388 1.280938 1.242653 1.230501 1.237377 1.215958
5 -0.046483 -0.041511 -0.037657 -0.033154 -0.029168 -0.026779 -0.025780 -0.027866 -0.030835 -0.033302 ... 1.207772 1.213222 1.234754 1.265822 1.284060 1.282216 1.231405 1.226009 1.242443 1.214737
6 -0.048891 -0.043434 -0.039582 -0.034988 -0.030831 -0.028549 -0.026863 -0.029822 -0.033208 -0.036772 ... 1.226850 1.231265 1.249724 1.267735 1.277433 1.268032 1.232173 1.222100 1.223172 1.204262
7 -0.048777 -0.043276 -0.039132 -0.034031 -0.029424 -0.026727 -0.025050 -0.028003 -0.031986 -0.036105 ... 1.179737 1.194083 1.218740 1.243636 1.267786 1.272233 1.229436 1.223080 1.219333 1.203519
8 -0.048676 -0.043200 -0.039281 -0.034568 -0.030280 -0.027911 -0.026159 -0.029193 -0.032695 -0.036454 ... 1.214328 1.220826 1.240104 1.258933 1.269977 1.263508 1.225934 1.217400 1.217926 1.199350
9 -0.049455 -0.044022 -0.040217 -0.035745 -0.031574 -0.029355 -0.027636 -0.030609 -0.033820 -0.037224 ... 1.227896 1.231785 1.249241 1.265124 1.270558 1.261033 1.226591 1.217574 1.218749 1.199011
10 -0.050912 -0.045547 -0.041953 -0.037907 -0.034005 -0.032060 -0.030449 -0.033268 -0.035999 -0.038749 ... 1.257324 1.256125 1.270627 1.281708 1.278878 1.262914 1.234663 1.223447 1.225182 1.203974
11 -0.049185 -0.043889 -0.040129 -0.035748 -0.031780 -0.029582 -0.028192 -0.030779 -0.033874 -0.036798 ... 1.236840 1.239557 1.258195 1.278175 1.288623 1.278632 1.241975 1.231335 1.235727 1.214449
12 -0.049469 -0.044121 -0.040051 -0.035142 -0.030695 -0.028053 -0.026702 -0.029248 -0.032990 -0.036464 ... 1.187606 1.201255 1.226901 1.254134 1.280911 1.286060 1.242809 1.235709 1.233727 1.216327
13 -0.047169 -0.041698 -0.037451 -0.032165 -0.027335 -0.024510 -0.022670 -0.025793 -0.029838 -0.034275 ... 1.153730 1.170487 1.195161 1.221972 1.244544 1.253482 1.204532 1.202990 1.203483 1.185375
14 -0.045237 -0.039679 -0.035121 -0.029185 -0.024101 -0.020851 -0.019069 -0.022193 -0.027062 -0.032319 ... 1.120176 1.144253 1.175030 1.211731 1.253533 1.271157 1.213407 1.211894 1.210217 1.195693
15 -0.049983 -0.044933 -0.041144 -0.036825 -0.032866 -0.030549 -0.029664 -0.031612 -0.034570 -0.036725 ... 1.222637 1.229205 1.252197 1.279387 1.299914 1.298418 1.256599 1.247647 1.253774 1.230636
16 -0.050628 -0.045204 -0.041395 -0.036972 -0.032689 -0.030455 -0.028729 -0.031681 -0.034829 -0.038117 ... 1.220413 1.226235 1.244316 1.258943 1.263519 1.257240 1.224112 1.216579 1.215167 1.195905
17 -0.052457 -0.046901 -0.043022 -0.038502 -0.033993 -0.031673 -0.029806 -0.032923 -0.036289 -0.039858 ... 1.209971 1.219609 1.239274 1.251314 1.257654 1.255415 1.226180 1.218891 1.209320 1.193980
18 -0.053565 -0.048289 -0.044368 -0.039937 -0.035271 -0.032810 -0.031355 -0.033901 -0.037007 -0.039772 ... 1.181175 1.196416 1.220149 1.238202 1.250754 1.260654 1.225209 1.223175 1.215855 1.197370
19 -0.052410 -0.046816 -0.042709 -0.037779 -0.032988 -0.030339 -0.028565 -0.031593 -0.035490 -0.039456 ... 1.178599 1.195734 1.220935 1.239513 1.260283 1.268094 1.233737 1.227682 1.213680 1.201519
20 -0.055743 -0.050307 -0.046503 -0.042278 -0.037702 -0.035430 -0.033806 -0.036565 -0.039596 -0.042389 ... 1.206625 1.219006 1.240435 1.250775 1.256879 1.260553 1.235295 1.229514 1.215010 1.199932
21 -0.046118 -0.040893 -0.036953 -0.032195 -0.028088 -0.025643 -0.024280 -0.026852 -0.030248 -0.033575 ... 1.208437 1.214244 1.235101 1.263031 1.281074 1.276361 1.228706 1.221319 1.232504 1.208947
22 -0.054489 -0.049029 -0.045118 -0.040663 -0.035970 -0.033561 -0.031873 -0.034724 -0.037990 -0.041143 ... 1.191728 1.206156 1.228732 1.241971 1.251801 1.258109 1.228660 1.224190 1.210994 1.195989
23 -0.054899 -0.049380 -0.045469 -0.040998 -0.036333 -0.033933 -0.032231 -0.035117 -0.038477 -0.041721 ... 1.197903 1.212104 1.234872 1.247331 1.258463 1.263449 1.236151 1.229912 1.214189 1.200849
24 -0.054884 -0.049437 -0.045549 -0.041142 -0.036522 -0.034136 -0.032543 -0.035287 -0.038538 -0.041547 ... 1.198230 1.212216 1.235208 1.248827 1.260377 1.265971 1.237560 1.231717 1.217714 1.203180
25 -0.052436 -0.046889 -0.042984 -0.038393 -0.033985 -0.031611 -0.029942 -0.032856 -0.036386 -0.039888 ... 1.215306 1.225408 1.247113 1.262561 1.276645 1.274526 1.244620 1.234648 1.223967 1.210019
26 -0.053618 -0.048273 -0.044457 -0.040176 -0.035673 -0.033385 -0.031803 -0.034516 -0.037494 -0.040290 ... 1.203250 1.214135 1.234839 1.248495 1.254371 1.257008 1.226129 1.221642 1.214363 1.196032
27 -0.055019 -0.049715 -0.045955 -0.041817 -0.037407 -0.035169 -0.033775 -0.036258 -0.039133 -0.041543 ... 1.212673 1.223453 1.245074 1.258615 1.266653 1.269418 1.241291 1.235067 1.225264 1.207770
28 -0.054950 -0.049574 -0.045737 -0.041449 -0.036892 -0.034564 -0.033045 -0.035683 -0.038751 -0.041494 ... 1.201748 1.214653 1.237021 1.250525 1.259979 1.265013 1.236383 1.231023 1.219077 1.202975
29 -0.055630 -0.050264 -0.046523 -0.042403 -0.038046 -0.035839 -0.034440 -0.036948 -0.039888 -0.042343 ... 1.221956 1.232104 1.253725 1.265979 1.274830 1.275643 1.250485 1.242098 1.229421 1.213705
30 -0.055292 -0.049926 -0.046141 -0.041941 -0.037504 -0.035239 -0.033804 -0.036351 -0.039356 -0.041927 ... 1.213188 1.224584 1.246683 1.259829 1.269511 1.272243 1.245355 1.238175 1.225910 1.210031
31 -0.054476 -0.049336 -0.045470 -0.041212 -0.036620 -0.034195 -0.032995 -0.035207 -0.038080 -0.040275 ... 1.183002 1.198508 1.223213 1.242759 1.256724 1.268739 1.232985 1.231347 1.224944 1.205041
32 -0.056745 -0.051513 -0.047688 -0.043566 -0.038829 -0.036474 -0.035087 -0.037490 -0.040261 -0.042461 ... 1.183161 1.199681 1.223452 1.236820 1.244654 1.257530 1.228217 1.227351 1.214524 1.196719
33 -0.053850 -0.048732 -0.044871 -0.040612 -0.036035 -0.033620 -0.032399 -0.034634 -0.037464 -0.039672 ... 1.182267 1.197075 1.221158 1.241030 1.253596 1.264960 1.227837 1.226829 1.222708 1.201669
34 -0.054311 -0.049203 -0.045356 -0.041121 -0.036629 -0.034217 -0.033133 -0.035219 -0.038082 -0.040143 ... 1.189219 1.203909 1.228977 1.249965 1.266177 1.277122 1.240971 1.238028 1.232520 1.212425
35 -0.054467 -0.048932 -0.045104 -0.040746 -0.036236 -0.033964 -0.032208 -0.035169 -0.038403 -0.041615 ... 1.214262 1.224794 1.245245 1.255513 1.261969 1.261351 1.236001 1.228149 1.214389 1.200242
36 -0.053001 -0.047885 -0.044136 -0.039990 -0.035825 -0.033563 -0.032529 -0.034602 -0.037404 -0.039426 ... 1.217538 1.226486 1.249202 1.270004 1.284545 1.286409 1.251413 1.244246 1.242654 1.221686
37 -0.053085 -0.047632 -0.043750 -0.039213 -0.035028 -0.032639 -0.031395 -0.033830 -0.037398 -0.040417 ... 1.228434 1.238501 1.263089 1.283334 1.307714 1.305785 1.275744 1.261842 1.250179 1.237234
38 -0.052781 -0.047243 -0.043119 -0.038141 -0.033574 -0.030858 -0.029521 -0.032079 -0.036178 -0.039821 ... 1.191358 1.209015 1.237949 1.262634 1.297188 1.305240 1.270244 1.259182 1.243259 1.233230
39 -0.054127 -0.048605 -0.044665 -0.040046 -0.035697 -0.033231 -0.031913 -0.034432 -0.038147 -0.041339 ... 1.218509 1.231492 1.257403 1.276694 1.302877 1.304442 1.275965 1.262696 1.246277 1.235579
40 -0.053571 -0.048110 -0.044576 -0.040675 -0.036795 -0.034930 -0.033330 -0.036139 -0.038868 -0.041477 ... 1.271497 1.270497 1.285383 1.292155 1.289240 1.272165 1.251880 1.237660 1.231084 1.213672
41 -0.051631 -0.046151 -0.042427 -0.038148 -0.033999 -0.031888 -0.030157 -0.033128 -0.036204 -0.039386 ... 1.239577 1.242969 1.259869 1.271286 1.273506 1.262768 1.234824 1.224351 1.220132 1.202314
42 -0.048781 -0.043454 -0.039577 -0.034942 -0.030978 -0.028608 -0.027392 -0.029821 -0.033316 -0.036446 ... 1.231898 1.237305 1.259533 1.284963 1.307724 1.300401 1.261174 1.248067 1.250079 1.231453
43 -0.051940 -0.046832 -0.042938 -0.038495 -0.034252 -0.031777 -0.030878 -0.032824 -0.035992 -0.038261 ... 1.201786 1.214263 1.240481 1.267670 1.293367 1.299932 1.259495 1.252195 1.250730 1.230884
44 -0.054885 -0.049325 -0.045596 -0.041389 -0.037096 -0.034962 -0.033262 -0.036179 -0.039318 -0.042364 ... 1.237661 1.244656 1.263732 1.272001 1.276804 1.270342 1.249016 1.237608 1.223154 1.209649
45 -0.062082 -0.056308 -0.052509 -0.048345 -0.043678 -0.041417 -0.039791 -0.042597 -0.046056 -0.048964 ... 1.228431 1.244986 1.270196 1.272843 1.287330 1.291958 1.284697 1.270765 1.231851 1.229284
46 -0.060582 -0.054911 -0.051076 -0.046794 -0.042354 -0.040010 -0.038752 -0.041169 -0.044794 -0.047514 ... 1.235080 1.251071 1.278852 1.289241 1.315228 1.319305 1.306882 1.289845 1.254896 1.251740
47 -0.059898 -0.054068 -0.050070 -0.045476 -0.040600 -0.038085 -0.036344 -0.039319 -0.043239 -0.046828 ... 1.202288 1.222657 1.250135 1.258047 1.279999 1.289306 1.274817 1.262841 1.225624 1.223651
48 -0.061131 -0.055430 -0.051634 -0.047439 -0.042962 -0.040683 -0.039302 -0.041847 -0.045361 -0.048088 ... 1.236968 1.252300 1.278684 1.285833 1.306663 1.309760 1.299735 1.283430 1.247513 1.244289
49 -0.063432 -0.057622 -0.053883 -0.049853 -0.045213 -0.043035 -0.041389 -0.044210 -0.047573 -0.050347 ... 1.237642 1.253485 1.278059 1.277520 1.289353 1.292563 1.289740 1.274702 1.232469 1.231091
50 -0.053456 -0.047910 -0.044197 -0.040076 -0.035380 -0.033326 -0.030971 -0.034560 -0.037244 -0.040664 ... 1.206360 1.213011 1.226024 1.226452 1.207938 1.203461 1.179019 1.178482 1.171609 1.151887
51 -0.054128 -0.048748 -0.045185 -0.041353 -0.037105 -0.035200 -0.033377 -0.036354 -0.038786 -0.041321 ... 1.238955 1.241582 1.255507 1.259399 1.246951 1.237699 1.214899 1.208884 1.204056 1.183430
52 -0.053732 -0.048180 -0.044564 -0.040617 -0.036038 -0.034127 -0.031718 -0.035364 -0.037848 -0.041127 ... 1.221079 1.224631 1.235359 1.232501 1.208031 1.199092 1.177758 1.176262 1.170124 1.149678
53 -0.053958 -0.048699 -0.044971 -0.041018 -0.035992 -0.033865 -0.031595 -0.034946 -0.037107 -0.039867 ... 1.165215 1.176716 1.190414 1.192380 1.167561 1.175367 1.143851 1.153684 1.152852 1.126815
54 -0.051053 -0.045932 -0.042341 -0.038522 -0.034046 -0.032094 -0.030130 -0.033176 -0.035150 -0.037535 ... 1.201291 1.204608 1.215997 1.222453 1.198893 1.195521 1.160500 1.165265 1.175346 1.145312
55 -0.050781 -0.045817 -0.042130 -0.038107 -0.033961 -0.031790 -0.030649 -0.032800 -0.035199 -0.037059 ... 1.210611 1.216555 1.235738 1.256354 1.260335 1.260615 1.219968 1.217670 1.226984 1.199535
56 -0.057168 -0.051495 -0.047755 -0.043744 -0.038493 -0.036426 -0.033609 -0.037645 -0.040166 -0.043764 ... 1.176502 1.189080 1.201314 1.191700 1.161022 1.165302 1.147940 1.154224 1.137094 1.119684
57 -0.055770 -0.050329 -0.046731 -0.042928 -0.038293 -0.036358 -0.034199 -0.037505 -0.039823 -0.042543 ... 1.214239 1.220712 1.233800 1.231967 1.210740 1.207588 1.187161 1.186818 1.177730 1.157425
58 -0.058121 -0.052336 -0.048733 -0.044867 -0.040132 -0.038251 -0.035706 -0.039519 -0.042185 -0.045588 ... 1.229769 1.236311 1.248433 1.238165 1.214340 1.206748 1.197852 1.193022 1.170884 1.157992
59 -0.057095 -0.051560 -0.047906 -0.044031 -0.039200 -0.037198 -0.034909 -0.038361 -0.040823 -0.043763 ... 1.203956 1.213483 1.227621 1.223669 1.202966 1.203299 1.185467 1.185936 1.171058 1.153392

60 rows × 401 columns


In [41]:
help(ho.nipalsPCA.X_predCal)


Help on function X_predCal in module hoggorm.pca:

X_predCal(self)
    Returns a dictionary holding the predicted arrays Xhat from
    calibration after each computed component. Dictionary key represents
    order of component.


In [42]:
# Get validated explained variance of each component
valExplVar = model.X_valExplVar()

# Get calibrated explained variance and store in pandas dataframe with row and column names
valExplVar_df = pd.DataFrame(model.X_valExplVar())
valExplVar_df.columns = ['validated explained variance']
valExplVar_df.index = ['PC{0}'.format(x+1) for x in range(model.X_loadings().shape[1])]
valExplVar_df


Out[42]:
validated explained variance
PC1 71.415215
PC2 10.672744
PC3 7.088484
PC4 5.448433
PC5 1.145096

In [43]:
help(ho.nipalsPCA.X_valExplVar)


Help on function X_valExplVar in module hoggorm.pca:

X_valExplVar(self)
    Returns a list holding the validated explained variance for X after
    each component. First number in list is for component 1, second number
    for component 2, third number for component 3, etc.


In [44]:
# Get cumulative validated explained variance
cumValExplVar = model.X_cumValExplVar()

# Get cumulative validated explained variance and store in pandas dataframe with row and column names
cumValExplVar_df = pd.DataFrame(model.X_cumValExplVar())
cumValExplVar_df.columns = ['cumulative validated explained variance']
cumValExplVar_df.index = ['PC{0}'.format(x) for x in range(model.X_loadings().shape[1] + 1)]
cumValExplVar_df


Out[44]:
cumulative validated explained variance
PC0 0.000000
PC1 71.415215
PC2 82.087959
PC3 89.176443
PC4 94.624876
PC5 95.769973

In [45]:
help(ho.nipalsPCA.X_cumValExplVar)


Help on function X_cumValExplVar in module hoggorm.pca:

X_cumValExplVar(self)
    Returns a list holding the cumulative validated explained variance
    for array X after each component.


In [46]:
# Get cumulative validated explained variance for each variable
cumCalExplVar_ind = model.X_cumCalExplVar_indVar()

# Get cumulative validated explained variance for each variable and store in pandas dataframe with row and column names
cumValExplVar_ind_df = pd.DataFrame(model.X_cumValExplVar_indVar())
#cumValExplVar_ind_df.columns = data_varNames
cumValExplVar_ind_df.index = ['PC{0}'.format(x) for x in range(model.X_loadings().shape[1] + 1)]
cumValExplVar_ind_df


Out[46]:
0 1 2 3 4 5 6 7 8 9 ... 391 392 393 394 395 396 397 398 399 400
PC0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 ... 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
PC1 22.710872 21.660941 24.633452 29.395892 32.929146 36.269480 33.410238 36.056511 34.476418 31.650333 ... 81.508076 78.599717 66.107833 23.652124 -0.308331 -2.210922 2.928987 0.323311 -1.866828 -1.736965
PC2 37.041768 35.701940 39.251132 46.268708 45.824521 49.846358 41.555877 49.099234 44.884280 43.187382 ... 88.428120 85.245979 79.717190 66.259572 69.632602 50.840185 40.400170 38.230413 67.908421 63.038326
PC3 59.549386 55.127538 55.861670 58.527133 55.416556 56.896679 47.825787 56.688266 61.150641 68.928297 ... 88.968249 84.631048 82.184860 66.422820 77.869434 63.746844 65.688602 63.197396 69.828459 77.373464
PC4 84.409841 84.151860 85.759920 90.776563 88.410193 88.494435 85.189375 85.545819 87.891494 84.123411 ... 88.700223 85.085762 84.491970 66.990241 78.535613 67.574335 74.788183 78.349408 78.462909 87.311900
PC5 91.611547 90.890894 91.184396 94.505493 93.312892 93.084239 92.169401 91.093997 92.373971 90.861056 ... 89.548650 88.720966 86.525575 63.075198 84.344950 85.840815 93.573627 80.572202 76.758932 89.815669

6 rows × 401 columns


In [47]:
help(ho.nipalsPCA.X_cumValExplVar_indVar)


Help on function X_cumValExplVar_indVar in module hoggorm.pca:

X_cumValExplVar_indVar(self)
    Returns an array holding the cumulative validated explained variance
    for each variable in X after each component. First row represents
    zero components, second row represents component 1, third row for
    compnent 2, etc. Columns represent variables.


In [49]:
# Get validated predicted X for a given number of components

# Predicted X from validation using 1 component
X_from_1_component_val = model.X_predVal()[1]

# Predicted X from calibration using 1 component stored in pandas data frame with row and columns names
X_from_1_component_val_df = pd.DataFrame(model.X_predVal()[1])
#X_from_1_component_val_df.index = data_objNames
#X_from_1_component_val_df.columns = data_varNames
X_from_1_component_val_df


Out[49]:
0 1 2 3 4 5 6 7 8 9 ... 391 392 393 394 395 396 397 398 399 400
0 -0.052654 -0.047253 -0.043385 -0.038966 -0.034495 -0.032144 -0.030568 -0.033327 -0.036519 -0.039577 ... 1.204576 1.215067 1.236509 1.252646 1.263053 1.264538 1.231093 1.225307 1.218563 1.201118
1 -0.047475 -0.042245 -0.037951 -0.032718 -0.027856 -0.024933 -0.023602 -0.026006 -0.029788 -0.033307 ... 1.140074 1.159301 1.185280 1.219966 1.249506 1.264172 1.209302 1.209640 1.216976 1.195430
2 -0.048160 -0.043013 -0.038847 -0.033862 -0.029165 -0.026398 -0.025090 -0.027483 -0.031057 -0.034387 ... 1.150832 1.168292 1.194591 1.225073 1.251362 1.265056 1.213313 1.213155 1.217364 1.195619
3 -0.048993 -0.043709 -0.039550 -0.034547 -0.029842 -0.027097 -0.025709 -0.028282 -0.031926 -0.035339 ... 1.159720 1.176811 1.202179 1.230568 1.253510 1.265437 1.217519 1.216286 1.217592 1.197049
4 -0.054901 -0.049436 -0.045730 -0.041604 -0.037243 -0.035085 -0.033372 -0.036204 -0.039167 -0.042003 ... 1.229091 1.237254 1.256051 1.264647 1.266633 1.262159 1.240285 1.230951 1.218680 1.203491
5 -0.051742 -0.046399 -0.042469 -0.037919 -0.033391 -0.030948 -0.029415 -0.032108 -0.035405 -0.038539 ... 1.192850 1.205387 1.227701 1.246833 1.260031 1.264153 1.227957 1.223175 1.218755 1.200373
6 -0.054114 -0.048671 -0.044907 -0.040678 -0.036286 -0.034081 -0.032450 -0.035264 -0.038304 -0.041197 ... 1.220707 1.229692 1.249463 1.260550 1.265708 1.263024 1.237448 1.229354 1.219030 1.202849
7 -0.050596 -0.045307 -0.041314 -0.036630 -0.032055 -0.029521 -0.028038 -0.030657 -0.034040 -0.037225 ... 1.179995 1.194176 1.217751 1.240628 1.258077 1.264336 1.223809 1.220514 1.218559 1.199847
8 -0.053225 -0.047823 -0.044000 -0.039660 -0.035221 -0.032936 -0.031338 -0.034103 -0.037231 -0.040201 ... 1.210842 1.221006 1.241755 1.255860 1.263868 1.263652 1.234152 1.227244 1.219112 1.202090
9 -0.054279 -0.048829 -0.045078 -0.040876 -0.036489 -0.034311 -0.032660 -0.035482 -0.038508 -0.041383 ... 1.223016 1.231621 1.251305 1.261676 1.266167 1.262965 1.238314 1.229963 1.219180 1.203228
10 -0.056608 -0.051037 -0.047434 -0.043545 -0.039261 -0.037275 -0.035505 -0.038459 -0.041296 -0.043968 ... 1.248120 1.254471 1.271578 1.274293 1.269925 1.259988 1.247542 1.235868 1.219169 1.205495
11 -0.054549 -0.049090 -0.045344 -0.041185 -0.036812 -0.034641 -0.032996 -0.035814 -0.038825 -0.041716 ... 1.225591 1.233629 1.252665 1.262470 1.265523 1.264272 1.238503 1.229731 1.219115 1.202677
12 -0.050908 -0.045569 -0.041593 -0.036948 -0.032373 -0.029853 -0.028361 -0.031005 -0.034369 -0.037559 ... 1.182853 1.196213 1.219559 1.241581 1.257947 1.265327 1.224176 1.220392 1.218778 1.198834
13 -0.048885 -0.043686 -0.039564 -0.034683 -0.029987 -0.027266 -0.025915 -0.028403 -0.031930 -0.035245 ... 1.159500 1.176465 1.201753 1.231145 1.254843 1.266980 1.218474 1.217215 1.219020 1.198370
14 -0.046766 -0.041815 -0.037483 -0.032258 -0.027576 -0.024561 -0.023485 -0.025645 -0.029256 -0.032611 ... 1.131729 1.148309 1.177782 1.215363 1.249687 1.267777 1.199994 1.208301 1.217845 1.195189
15 -0.052977 -0.047570 -0.043724 -0.039334 -0.034881 -0.032562 -0.030977 -0.033729 -0.036901 -0.039918 ... 1.207475 1.217680 1.238999 1.253922 1.262887 1.263568 1.232085 1.226166 1.218458 1.201334
16 -0.053816 -0.048388 -0.044600 -0.040340 -0.035940 -0.033709 -0.032084 -0.034877 -0.037952 -0.040866 ... 1.218090 1.227185 1.247294 1.259450 1.265157 1.263902 1.236617 1.228605 1.219550 1.202496
17 -0.053305 -0.047895 -0.044080 -0.039759 -0.035344 -0.033066 -0.031463 -0.034231 -0.037348 -0.040303 ... 1.213041 1.222856 1.243361 1.256781 1.264343 1.263839 1.234888 1.227866 1.219047 1.202331
18 -0.050754 -0.045454 -0.041460 -0.036807 -0.032240 -0.029708 -0.028219 -0.030860 -0.034242 -0.037454 ... 1.184125 1.197849 1.221089 1.242831 1.258917 1.264636 1.225379 1.221517 1.219135 1.200170
19 -0.050816 -0.045509 -0.041527 -0.036877 -0.032326 -0.029822 -0.028326 -0.030989 -0.034329 -0.037497 ... 1.184356 1.197976 1.221149 1.242749 1.258797 1.264667 1.225422 1.221602 1.218767 1.199940
20 -0.053067 -0.047647 -0.043817 -0.039471 -0.035032 -0.032727 -0.031137 -0.033889 -0.037034 -0.040023 ... 1.210477 1.220377 1.241080 1.255421 1.263535 1.264751 1.233761 1.226787 1.219418 1.201828
21 -0.052265 -0.046892 -0.042988 -0.038495 -0.034001 -0.031588 -0.030047 -0.032750 -0.035994 -0.039074 ... 1.197787 1.209399 1.231306 1.249094 1.260840 1.265138 1.229399 1.223994 1.219021 1.200658
22 -0.051908 -0.046554 -0.042645 -0.038149 -0.033654 -0.031238 -0.029691 -0.032394 -0.035651 -0.038735 ... 1.197082 1.208912 1.230868 1.249047 1.261171 1.265612 1.229310 1.224021 1.219344 1.200709
23 -0.052412 -0.047040 -0.043166 -0.038728 -0.034264 -0.031899 -0.030336 -0.033056 -0.036261 -0.039305 ... 1.202808 1.213789 1.235335 1.251729 1.262283 1.265011 1.231141 1.225187 1.219287 1.201242
24 -0.052309 -0.046941 -0.043054 -0.038602 -0.034135 -0.031760 -0.030199 -0.032916 -0.036130 -0.039185 ... 1.201561 1.212815 1.234440 1.251183 1.261981 1.264664 1.230873 1.224894 1.219295 1.201253
25 -0.053465 -0.048050 -0.044253 -0.039940 -0.035531 -0.033269 -0.031657 -0.034440 -0.037538 -0.040486 ... 1.214408 1.224003 1.244415 1.257315 1.264415 1.263389 1.235152 1.227707 1.218784 1.202335
26 -0.052613 -0.047226 -0.043368 -0.038941 -0.034483 -0.032138 -0.030559 -0.033300 -0.036488 -0.039524 ... 1.204892 1.215770 1.237039 1.252950 1.262768 1.264066 1.232154 1.225901 1.219032 1.201754
27 -0.053183 -0.047777 -0.043958 -0.039606 -0.035180 -0.032895 -0.031294 -0.034066 -0.037194 -0.040180 ... 1.211742 1.221735 1.242364 1.256032 1.263922 1.263602 1.234276 1.227265 1.218747 1.202117
28 -0.052518 -0.047136 -0.043276 -0.038835 -0.034372 -0.032020 -0.030443 -0.033188 -0.036382 -0.039423 ... 1.203951 1.214817 1.236316 1.252414 1.262577 1.263980 1.231662 1.225628 1.218909 1.201611
29 -0.053914 -0.048467 -0.044699 -0.040442 -0.036066 -0.033849 -0.032214 -0.035025 -0.038079 -0.040992 ... 1.220123 1.229078 1.248838 1.260188 1.265382 1.262821 1.237010 1.228932 1.218977 1.202612
30 -0.053292 -0.047869 -0.044057 -0.039724 -0.035309 -0.033029 -0.031422 -0.034203 -0.037321 -0.040289 ... 1.212795 1.222617 1.243174 1.256607 1.264139 1.263495 1.234614 1.227328 1.218981 1.202128
31 -0.050684 -0.045380 -0.041401 -0.036716 -0.032153 -0.029626 -0.028120 -0.030785 -0.034175 -0.037401 ... 1.183294 1.196977 1.220493 1.242160 1.258437 1.264593 1.224951 1.220899 1.218941 1.199792
32 -0.051118 -0.045786 -0.041831 -0.037211 -0.032680 -0.030194 -0.028671 -0.031354 -0.034693 -0.037875 ... 1.188694 1.201840 1.224590 1.245032 1.259768 1.264670 1.226905 1.222380 1.218889 1.200487
33 -0.050592 -0.045285 -0.041314 -0.036612 -0.032050 -0.029510 -0.028001 -0.030663 -0.034060 -0.037302 ... 1.182343 1.196200 1.219672 1.241871 1.258405 1.264915 1.224751 1.221056 1.218760 1.199645
34 -0.050997 -0.045690 -0.041706 -0.037086 -0.032527 -0.030044 -0.028504 -0.031198 -0.034539 -0.037750 ... 1.186630 1.199939 1.222852 1.243726 1.259119 1.264361 1.226002 1.221642 1.218533 1.199600
35 -0.053682 -0.048246 -0.044460 -0.040169 -0.035776 -0.033537 -0.031935 -0.034711 -0.037797 -0.040704 ... 1.217431 1.226421 1.246357 1.258627 1.264801 1.264627 1.235814 1.228358 1.219312 1.202382
36 -0.052996 -0.047596 -0.043762 -0.039366 -0.034928 -0.032623 -0.031025 -0.033784 -0.036937 -0.039969 ... 1.208743 1.218976 1.239773 1.254380 1.263183 1.263457 1.233184 1.226188 1.218708 1.201518
37 -0.054023 -0.048591 -0.044817 -0.040563 -0.036170 -0.033981 -0.032344 -0.035163 -0.038180 -0.041102 ... 1.220186 1.228501 1.248661 1.259852 1.265227 1.262804 1.235477 1.228574 1.218583 1.201640
38 -0.051350 -0.046025 -0.042087 -0.037475 -0.032962 -0.030485 -0.028965 -0.031669 -0.034931 -0.038093 ... 1.189470 1.201900 1.224967 1.245129 1.259285 1.263994 1.224712 1.222004 1.218445 1.198990
39 -0.053416 -0.048008 -0.044210 -0.039876 -0.035462 -0.033212 -0.031593 -0.034384 -0.037475 -0.040435 ... 1.213979 1.223132 1.243966 1.257054 1.264091 1.263227 1.233351 1.227364 1.218552 1.201515
40 -0.058163 -0.052633 -0.049038 -0.045234 -0.041085 -0.039233 -0.037524 -0.040408 -0.043103 -0.045639 ... 1.261598 1.265987 1.280780 1.280134 1.270146 1.263052 1.251149 1.236879 1.218122 1.204033
41 -0.055466 -0.049996 -0.046305 -0.042226 -0.037918 -0.035835 -0.034130 -0.036998 -0.039913 -0.042704 ... 1.235488 1.242533 1.261031 1.267759 1.268183 1.263236 1.242219 1.232297 1.218644 1.203970
42 -0.053980 -0.048542 -0.044757 -0.040478 -0.036077 -0.033853 -0.032225 -0.035048 -0.038075 -0.041017 ... 1.218347 1.226732 1.247096 1.259111 1.264862 1.262902 1.235320 1.228055 1.218466 1.202203
43 -0.051606 -0.046281 -0.042337 -0.037753 -0.033232 -0.030788 -0.029253 -0.031969 -0.035251 -0.038406 ... 1.192168 1.204148 1.227089 1.246454 1.259873 1.263954 1.226282 1.222591 1.218423 1.199552
44 -0.055375 -0.049900 -0.046203 -0.042145 -0.037856 -0.035781 -0.034116 -0.036953 -0.039871 -0.042636 ... 1.237420 1.243388 1.262329 1.268331 1.268287 1.261699 1.242737 1.232274 1.218482 1.204230
45 -0.054917 -0.049468 -0.045761 -0.041708 -0.037371 -0.035314 -0.033610 -0.036478 -0.039390 -0.042187 ... 1.235579 1.241753 1.259459 1.267400 1.267824 1.261871 1.239520 1.231925 1.218229 1.202607
46 -0.054924 -0.049438 -0.045741 -0.041651 -0.037340 -0.035232 -0.033574 -0.036415 -0.039333 -0.042148 ... 1.233955 1.240245 1.258309 1.266659 1.267548 1.261268 1.238425 1.228436 1.217939 1.201970
47 -0.053121 -0.047723 -0.043905 -0.039554 -0.035155 -0.032870 -0.031276 -0.034022 -0.037132 -0.040108 ... 1.212072 1.221754 1.242160 1.256395 1.264122 1.263852 1.233160 1.225954 1.218928 1.201755
48 -0.055234 -0.049735 -0.046057 -0.042024 -0.037725 -0.035672 -0.033977 -0.036852 -0.039724 -0.042511 ... 1.238331 1.243601 1.260994 1.268319 1.268162 1.261052 1.239478 1.230131 1.217973 1.202396
49 -0.055729 -0.050170 -0.046542 -0.042579 -0.038314 -0.036302 -0.034590 -0.037494 -0.040317 -0.043047 ... 1.245502 1.250393 1.267086 1.272205 1.269761 1.261335 1.241755 1.230343 1.218232 1.203426
50 -0.053810 -0.048383 -0.044598 -0.040312 -0.035927 -0.033698 -0.032097 -0.034868 -0.037943 -0.040858 ... 1.218515 1.227335 1.247433 1.259623 1.266906 1.265109 1.237286 1.229614 1.220457 1.203248
51 -0.055730 -0.050217 -0.046559 -0.042490 -0.038219 -0.036165 -0.034490 -0.037353 -0.040245 -0.043011 ... 1.239860 1.246074 1.263781 1.268866 1.271785 1.265299 1.243528 1.233875 1.219121 1.205316
52 -0.054992 -0.049510 -0.045810 -0.041666 -0.037335 -0.035242 -0.033589 -0.036424 -0.039387 -0.042195 ... 1.232848 1.239936 1.258739 1.266783 1.270672 1.265578 1.242075 1.233686 1.220265 1.205570
53 -0.050745 -0.045446 -0.041440 -0.036760 -0.032230 -0.029673 -0.028216 -0.030839 -0.034238 -0.037479 ... 1.184309 1.197157 1.222520 1.244801 1.262009 1.268272 1.227444 1.223068 1.221549 1.201600
54 -0.052865 -0.047474 -0.043610 -0.039197 -0.034748 -0.032420 -0.030847 -0.033581 -0.036763 -0.039815 ... 1.207212 1.217496 1.238561 1.255162 1.264472 1.265754 1.232984 1.227202 1.219438 1.202412
55 -0.052553 -0.047162 -0.043283 -0.038814 -0.034356 -0.031991 -0.030426 -0.033149 -0.036360 -0.039432 ... 1.202559 1.213446 1.234980 1.250860 1.263382 1.264948 1.230802 1.225157 1.218225 1.201486
56 -0.052481 -0.047107 -0.043237 -0.038784 -0.034330 -0.031974 -0.030433 -0.033138 -0.036340 -0.039368 ... 1.204162 1.214773 1.236340 1.253477 1.264378 1.265725 1.232655 1.226298 1.220781 1.203204
57 -0.054369 -0.048920 -0.045163 -0.040951 -0.036600 -0.034415 -0.032781 -0.035601 -0.038612 -0.041500 ... 1.225132 1.233319 1.252778 1.262877 1.268512 1.264931 1.239355 1.231426 1.219872 1.204501
58 -0.056059 -0.050509 -0.046887 -0.042858 -0.038650 -0.036642 -0.035005 -0.037874 -0.040695 -0.043370 ... 1.245295 1.251606 1.269484 1.273763 1.274182 1.266384 1.247249 1.237277 1.221932 1.207860
59 -0.053766 -0.048332 -0.044552 -0.040294 -0.035907 -0.033673 -0.032061 -0.034842 -0.037929 -0.040850 ... 1.219400 1.228077 1.248237 1.261004 1.266972 1.264899 1.237607 1.229697 1.220475 1.203496

60 rows × 401 columns


In [50]:
# Get validated predicted X for a given number of components

# Predicted X from validation using 3 components
X_from_3_component_val = model.X_predVal()[3]

# Predicted X from calibration using 3 components stored in pandas data frame with row and columns names
X_from_3_component_val_df = pd.DataFrame(model.X_predVal()[3])
#X_from_3_component_val_df.index = data_objNames
#X_from_3_component_val_df.columns = data_varNames
X_from_3_component_val_df


Out[50]:
0 1 2 3 4 5 6 7 8 9 ... 391 392 393 394 395 396 397 398 399 400
0 -0.047637 -0.042494 -0.038693 -0.034349 -0.030292 -0.028006 -0.026761 -0.029198 -0.032074 -0.034737 ... 1.216597 1.219273 1.238665 1.264580 1.276182 1.271058 1.221824 1.217379 1.230466 1.204159
1 -0.044526 -0.039469 -0.035202 -0.029961 -0.025365 -0.022465 -0.021381 -0.023503 -0.027150 -0.030395 ... 1.147647 1.163132 1.188177 1.229174 1.261016 1.271847 1.209454 1.209287 1.228007 1.201681
2 -0.049028 -0.043788 -0.039523 -0.034326 -0.029643 -0.026734 -0.025609 -0.027837 -0.031863 -0.035384 ... 1.153025 1.173436 1.203704 1.237631 1.277363 1.293061 1.242832 1.238199 1.235285 1.218615
3 -0.043804 -0.038810 -0.034727 -0.029781 -0.025472 -0.022833 -0.021727 -0.023996 -0.027241 -0.030184 ... 1.169744 1.179724 1.201307 1.237315 1.255866 1.260941 1.200861 1.201215 1.223371 1.192680
4 -0.050624 -0.045423 -0.041740 -0.037530 -0.033607 -0.031369 -0.030102 -0.032361 -0.035336 -0.037803 ... 1.242196 1.246887 1.266674 1.287483 1.299825 1.290147 1.258939 1.245708 1.247596 1.227744
5 -0.045705 -0.040741 -0.036878 -0.032344 -0.028343 -0.025950 -0.024910 -0.027057 -0.030122 -0.032745 ... 1.206838 1.212801 1.233005 1.265096 1.282073 1.278787 1.228466 1.222590 1.241473 1.212971
6 -0.052084 -0.046748 -0.042978 -0.038679 -0.034507 -0.032269 -0.030897 -0.033445 -0.036538 -0.039282 ... 1.227423 1.234674 1.255328 1.272558 1.284257 1.279184 1.248589 1.238505 1.234466 1.216267
7 -0.051500 -0.046123 -0.042063 -0.037237 -0.032637 -0.030007 -0.028605 -0.031160 -0.034865 -0.038216 ... 1.180503 1.197158 1.223409 1.247895 1.273908 1.281658 1.243242 1.237054 1.229039 1.214441
8 -0.051986 -0.046645 -0.042812 -0.038413 -0.034112 -0.031799 -0.030371 -0.032961 -0.036153 -0.039047 ... 1.215204 1.224414 1.245950 1.264164 1.277040 1.275517 1.242827 1.234425 1.229843 1.211847
9 -0.052243 -0.046917 -0.043185 -0.038977 -0.034785 -0.032616 -0.031157 -0.033768 -0.036728 -0.039411 ... 1.228649 1.234915 1.254482 1.269522 1.276691 1.270888 1.241364 1.232293 1.228907 1.209911
10 -0.052761 -0.047432 -0.043892 -0.040067 -0.036132 -0.034193 -0.032724 -0.035331 -0.037936 -0.040180 ... 1.258062 1.259872 1.275673 1.285857 1.282160 1.266374 1.246310 1.234209 1.232553 1.212143
11 -0.050719 -0.045487 -0.041747 -0.037555 -0.033566 -0.031369 -0.030154 -0.032508 -0.035493 -0.038087 ... 1.237011 1.240754 1.259886 1.279848 1.289945 1.287291 1.249581 1.238271 1.241985 1.219502
12 -0.050337 -0.044979 -0.040941 -0.036130 -0.031671 -0.029048 -0.027781 -0.030212 -0.033881 -0.037138 ... 1.187385 1.201444 1.227517 1.254800 1.282302 1.290082 1.246574 1.239172 1.236958 1.218669
13 -0.050683 -0.045373 -0.041219 -0.036311 -0.031463 -0.028709 -0.027253 -0.029864 -0.033528 -0.037010 ... 1.155718 1.175223 1.201453 1.227970 1.252388 1.266835 1.222849 1.221118 1.215582 1.198408
14 -0.050993 -0.045813 -0.041345 -0.035926 -0.031024 -0.027830 -0.026777 -0.028950 -0.033092 -0.036785 ... 1.127577 1.150100 1.184809 1.220074 1.266804 1.290699 1.230213 1.235776 1.226743 1.214338
15 -0.048092 -0.042917 -0.039074 -0.034564 -0.030588 -0.028236 -0.027161 -0.029373 -0.032590 -0.035287 ... 1.220984 1.225440 1.248258 1.275966 1.295191 1.289906 1.244780 1.237523 1.245567 1.222711
16 -0.052544 -0.047200 -0.043436 -0.039201 -0.034912 -0.032704 -0.031167 -0.033857 -0.036833 -0.039609 ... 1.220977 1.228313 1.247805 1.262213 1.267611 1.264813 1.234356 1.226495 1.222722 1.203116
17 -0.054304 -0.048831 -0.045001 -0.040670 -0.036167 -0.033874 -0.032199 -0.035049 -0.038232 -0.041282 ... 1.210729 1.221913 1.242830 1.254382 1.261827 1.262558 1.236236 1.229122 1.216279 1.201408
18 -0.051678 -0.046339 -0.042361 -0.037776 -0.033096 -0.030598 -0.028962 -0.031752 -0.035048 -0.038298 ... 1.180448 1.194809 1.217104 1.235301 1.246439 1.252946 1.216397 1.214006 1.209310 1.190754
19 -0.053925 -0.048401 -0.044331 -0.039556 -0.034767 -0.032166 -0.030549 -0.033383 -0.037101 -0.040610 ... 1.178713 1.197766 1.223781 1.241753 1.263540 1.273625 1.242902 1.236701 1.219255 1.208053
20 -0.054504 -0.048999 -0.045165 -0.040854 -0.036266 -0.033966 -0.032223 -0.035137 -0.038291 -0.041391 ... 1.206190 1.217622 1.238100 1.248665 1.253610 1.256744 1.229436 1.223211 1.211060 1.195180
21 -0.048779 -0.043605 -0.039711 -0.035166 -0.031056 -0.028611 -0.027489 -0.029742 -0.032948 -0.035697 ... 1.208509 1.215976 1.238093 1.265761 1.284760 1.287255 1.239787 1.232179 1.241105 1.217029
22 -0.053951 -0.048475 -0.044549 -0.040080 -0.035383 -0.032959 -0.031217 -0.034131 -0.037449 -0.040704 ... 1.191336 1.205675 1.227700 1.241085 1.250239 1.257738 1.226350 1.221681 1.209729 1.193906
23 -0.054656 -0.049137 -0.045223 -0.040753 -0.036091 -0.033682 -0.031962 -0.034859 -0.038242 -0.041519 ... 1.197518 1.211709 1.234377 1.246731 1.257627 1.263886 1.235339 1.228895 1.213996 1.200036
24 -0.053965 -0.048489 -0.044572 -0.040100 -0.035486 -0.033081 -0.031399 -0.034252 -0.037588 -0.040814 ... 1.197579 1.211197 1.233560 1.247240 1.257984 1.262987 1.233429 1.227130 1.214942 1.199929
25 -0.053947 -0.048470 -0.044615 -0.040168 -0.035765 -0.033414 -0.031898 -0.034603 -0.037983 -0.041065 ... 1.215685 1.227110 1.249918 1.264839 1.279888 1.279910 1.252840 1.242631 1.229373 1.216119
26 -0.052819 -0.047439 -0.043609 -0.039256 -0.034752 -0.032452 -0.030780 -0.033607 -0.036663 -0.039664 ... 1.202983 1.213510 1.233576 1.247348 1.252414 1.253636 1.222547 1.217784 1.211435 1.193281
27 -0.052956 -0.047569 -0.043763 -0.039434 -0.035020 -0.032752 -0.031147 -0.033918 -0.036992 -0.039941 ... 1.211883 1.221399 1.241589 1.255197 1.261843 1.261154 1.231325 1.224742 1.217481 1.200101
28 -0.053477 -0.048040 -0.044177 -0.039752 -0.035192 -0.032843 -0.031167 -0.034019 -0.037225 -0.040342 ... 1.201167 1.213107 1.234549 1.248214 1.256548 1.259004 1.229293 1.223720 1.213634 1.197671
29 -0.053782 -0.048334 -0.044553 -0.040261 -0.035910 -0.033671 -0.032082 -0.034850 -0.037965 -0.040893 ... 1.221096 1.230193 1.250506 1.262925 1.270359 1.267776 1.241559 1.232758 1.222663 1.206675
30 -0.053577 -0.048132 -0.044308 -0.039957 -0.035522 -0.033227 -0.031615 -0.034406 -0.037574 -0.040583 ... 1.212417 1.222765 1.243708 1.256971 1.265449 1.265222 1.237041 1.229405 1.219632 1.203572
31 -0.050753 -0.045463 -0.041515 -0.036905 -0.032306 -0.029826 -0.028236 -0.030979 -0.034228 -0.037409 ... 1.181652 1.194800 1.217059 1.236790 1.248314 1.254232 1.215057 1.212509 1.211632 1.191339
32 -0.052658 -0.047258 -0.043340 -0.038847 -0.034116 -0.031701 -0.029897 -0.032864 -0.036028 -0.039278 ... 1.182030 1.196224 1.216991 1.230893 1.236006 1.242142 1.209260 1.207489 1.200224 1.182405
33 -0.050330 -0.045063 -0.041140 -0.036539 -0.031960 -0.029488 -0.027888 -0.030629 -0.033817 -0.036969 ... 1.180939 1.193639 1.215280 1.235553 1.245791 1.251561 1.211155 1.209498 1.209942 1.188703
34 -0.050361 -0.045101 -0.041137 -0.036551 -0.032036 -0.029580 -0.028056 -0.030725 -0.033973 -0.037108 ... 1.187567 1.199820 1.222013 1.243423 1.257241 1.261572 1.221732 1.217940 1.217785 1.197267
35 -0.054985 -0.049462 -0.045653 -0.041336 -0.036832 -0.034568 -0.032884 -0.035756 -0.038950 -0.041986 ... 1.214599 1.225406 1.246003 1.256057 1.262629 1.264374 1.238681 1.230933 1.216581 1.202111
36 -0.050183 -0.044940 -0.041127 -0.036679 -0.032510 -0.030210 -0.028858 -0.031345 -0.034443 -0.037288 ... 1.216141 1.223218 1.243712 1.264710 1.277511 1.274270 1.237523 1.229063 1.231540 1.210403
37 -0.053082 -0.047643 -0.043751 -0.039177 -0.034980 -0.032640 -0.031385 -0.033860 -0.037374 -0.040447 ... 1.228338 1.237382 1.263024 1.283031 1.308177 1.305300 1.273642 1.261912 1.250046 1.235727
38 -0.053235 -0.047711 -0.043627 -0.038611 -0.034104 -0.031372 -0.030061 -0.032668 -0.036617 -0.040233 ... 1.191581 1.208897 1.239097 1.263794 1.298571 1.306558 1.268217 1.261813 1.244565 1.232807
39 -0.053938 -0.048430 -0.044512 -0.039825 -0.035483 -0.033055 -0.031690 -0.034272 -0.037985 -0.041232 ... 1.218745 1.230569 1.257716 1.276725 1.302752 1.303381 1.272542 1.262384 1.245210 1.234146
40 -0.054937 -0.049616 -0.046022 -0.042163 -0.038357 -0.036501 -0.035150 -0.037644 -0.040283 -0.042528 ... 1.271077 1.271931 1.286620 1.294291 1.289507 1.279740 1.258844 1.242680 1.235728 1.216717
41 -0.053822 -0.048453 -0.044770 -0.040670 -0.036528 -0.034444 -0.032902 -0.035591 -0.038472 -0.041122 ... 1.240237 1.245422 1.263961 1.274714 1.277845 1.271085 1.245718 1.235041 1.227215 1.210260
42 -0.050596 -0.045316 -0.041465 -0.036915 -0.032947 -0.030608 -0.029549 -0.031850 -0.035087 -0.037888 ... 1.232728 1.237052 1.261732 1.287747 1.311709 1.305475 1.267081 1.255153 1.255240 1.237536
43 -0.049164 -0.043962 -0.039980 -0.035243 -0.030995 -0.028490 -0.027282 -0.029683 -0.033111 -0.036174 ... 1.200709 1.210502 1.235416 1.262938 1.286326 1.287805 1.242946 1.236974 1.239529 1.218671
44 -0.055580 -0.050073 -0.046339 -0.042198 -0.037921 -0.035792 -0.034194 -0.036974 -0.040061 -0.042904 ... 1.238475 1.245373 1.265787 1.273199 1.278024 1.271971 1.253439 1.241305 1.225222 1.212750
45 -0.059136 -0.053372 -0.049446 -0.045148 -0.040382 -0.038170 -0.036228 -0.039394 -0.043073 -0.046632 ... 1.228985 1.242318 1.264171 1.268805 1.280342 1.279871 1.268010 1.259756 1.220271 1.216966
46 -0.057111 -0.051314 -0.047393 -0.042847 -0.038438 -0.036009 -0.034538 -0.037290 -0.041169 -0.044694 ... 1.235099 1.246810 1.271553 1.285135 1.308677 1.304540 1.285463 1.266011 1.241871 1.236567
47 -0.058882 -0.053049 -0.049042 -0.044296 -0.039573 -0.037017 -0.035198 -0.038167 -0.042141 -0.046001 ... 1.203018 1.222756 1.248328 1.258400 1.279496 1.287574 1.267464 1.252284 1.221925 1.220150
48 -0.058008 -0.052188 -0.048296 -0.043886 -0.039406 -0.037103 -0.035459 -0.038367 -0.042100 -0.045586 ... 1.237648 1.248064 1.271100 1.281126 1.300353 1.296542 1.280393 1.264950 1.235697 1.231128
49 -0.060301 -0.054266 -0.050460 -0.046194 -0.041535 -0.039293 -0.037371 -0.040595 -0.044203 -0.047757 ... 1.238873 1.251317 1.272393 1.273289 1.282158 1.279125 1.269740 1.252344 1.219616 1.217948
50 -0.055960 -0.050522 -0.046869 -0.042931 -0.038250 -0.036244 -0.034169 -0.037386 -0.039845 -0.042610 ... 1.207437 1.215240 1.229888 1.229735 1.216010 1.214835 1.192641 1.192468 1.183013 1.161119
51 -0.054456 -0.049080 -0.045532 -0.041673 -0.037456 -0.035554 -0.033783 -0.036708 -0.039107 -0.041584 ... 1.239420 1.241961 1.255507 1.257868 1.249672 1.240661 1.214980 1.209866 1.203786 1.184504
52 -0.056568 -0.051112 -0.047583 -0.043822 -0.039216 -0.037416 -0.035287 -0.038568 -0.040799 -0.043364 ... 1.223968 1.228973 1.241482 1.236950 1.217875 1.212111 1.191844 1.193316 1.179914 1.161907
53 -0.052905 -0.047683 -0.043834 -0.039821 -0.034892 -0.032595 -0.030303 -0.033787 -0.036032 -0.039285 ... 1.164102 1.170434 1.195120 1.195928 1.167991 1.174776 1.139227 1.146678 1.153632 1.120163
54 -0.051192 -0.046084 -0.042404 -0.038540 -0.034053 -0.032140 -0.030157 -0.033187 -0.035165 -0.037832 ... 1.204217 1.204786 1.214213 1.230596 1.201998 1.200182 1.155315 1.166169 1.172675 1.144269
55 -0.048543 -0.043396 -0.039620 -0.035261 -0.031145 -0.028920 -0.027484 -0.030017 -0.032735 -0.035427 ... 1.209280 1.212992 1.230334 1.249001 1.258510 1.253174 1.206148 1.204162 1.214249 1.190338
56 -0.059693 -0.054125 -0.050482 -0.046583 -0.041310 -0.039339 -0.036829 -0.040475 -0.042717 -0.045626 ... 1.180335 1.191169 1.204175 1.201023 1.169180 1.171552 1.159554 1.162342 1.152404 1.136330
57 -0.055976 -0.050555 -0.046934 -0.043115 -0.038493 -0.036540 -0.034382 -0.037723 -0.039976 -0.042716 ... 1.214061 1.220646 1.233553 1.230399 1.212535 1.207884 1.186475 1.188435 1.176809 1.158402
58 -0.060607 -0.054840 -0.051313 -0.047537 -0.042871 -0.041024 -0.038815 -0.042319 -0.044700 -0.047464 ... 1.228713 1.238880 1.253178 1.240613 1.221115 1.217393 1.209066 1.206951 1.179831 1.168238
59 -0.056943 -0.051407 -0.047764 -0.043953 -0.039087 -0.037047 -0.034760 -0.038192 -0.040721 -0.043646 ... 1.203313 1.212129 1.226882 1.226111 1.203750 1.203302 1.186381 1.186690 1.173315 1.152874

60 rows × 401 columns


In [51]:
help(ho.nipalsPCA.X_predVal)


Help on function X_predVal in module hoggorm.pca:

X_predVal(self)
    Returns a dictionary holding the predicted arrays Xhat from
    validation after each computed component. Dictionary key represents
    order of component.


In [52]:
# Get predicted scores for new measurements (objects) of X

# First pretend that we acquired new X data by using part of the existing data and overlaying some noise
import numpy.random as npr
new_data = data[0:4, :] + npr.rand(4, np.shape(data)[1])
np.shape(new_data)

# Now insert the new data into the existing model and compute scores for two components (numComp=2)
pred_scores = model.X_scores_predict(new_data, numComp=2)

# Same as above, but results stored in a pandas dataframe with row names and column names
pred_scores_df = pd.DataFrame(model.X_scores_predict(new_data, numComp=2))
pred_scores_df.columns = ['PC{0}'.format(x) for x in range(2)]
pred_scores_df.index = ['new object {0}'.format(x) for x in range(np.shape(new_data)[0])]
pred_scores_df


Out[52]:
PC0 PC1
new object 0 2.143577 7.487844
new object 1 2.930911 6.962830
new object 2 1.878479 7.650605
new object 3 2.172548 7.371672

In [53]:
help(ho.nipalsPCA.X_scores_predict)


Help on function X_scores_predict in module hoggorm.pca:

X_scores_predict(self, Xnew, numComp=None)
    Returns array of X scores from new X data using the exsisting model.
    Rows represent objects and columns represent components.


In [ ]: