correlations.h
1// OpenNN: Open Neural Networks Library
2// www.opennn.net
3//
4// C O R R E L A T I O N S H E A D E R
5//
6// Artificial Intelligence Techniques SL
7// artelnics@artelnics.com
8
9#ifndef CORRELATIONS_H
10#define CORRELATIONS_H
11
12// System includes
13
14#include <iostream>
15#include <fstream>
16#include <string>
17#include <sstream>
18#include <cmath>
19#include <algorithm>
20#include <cstdlib>
21#include <stdexcept>
22#include <ctime>
23#include <exception>
24
25// OpenNN includes
26
27#include "statistics.h"
28#include "config.h"
29
30namespace OpenNN
31{
32
34
35enum class CorrelationMethod{Linear, Logistic, Logarithmic, Exponential, Power};
36
38
40{
41 explicit Correlation() {}
42
43 virtual ~Correlation() {}
44
45 string write_correlation_type() const
46 {
47 switch(correlation_type)
48 {
49 case CorrelationMethod::Linear: return "linear";
50 case CorrelationMethod::Logistic: return "logistic";
51 case CorrelationMethod::Logarithmic: return "logarithmic";
52 case CorrelationMethod::Exponential: return "exponential";
53 case CorrelationMethod::Power: return "power";
54 }
55
56 return string();
57 }
58
59 void print()
60 {
61 cout << "Correlation" << endl;
62 cout << "Type: " << write_correlation_type() << endl;
63 cout << "a: " << a << endl;
64 cout << "b: " << b << endl;
65 cout << "r: " << r << endl;
66 }
67
69
70 type a = static_cast<type>(NAN);
71
73
74 type b = static_cast<type>(NAN);
75
77
78 type r = static_cast<type>(NAN);
79
81
82 CorrelationMethod correlation_type = CorrelationMethod::Linear;
83};
84
85 // Correlation methods
86
87 Correlation linear_correlation(const ThreadPoolDevice*, const Tensor<type, 1>&, const Tensor<type, 1>&);
88
89 Correlation logarithmic_correlation(const ThreadPoolDevice*, const Tensor<type, 1>&, const Tensor<type, 1>&);
90
91 Correlation exponential_correlation(const ThreadPoolDevice*, const Tensor<type, 1>&, const Tensor<type, 1>&);
92
93 Correlation power_correlation(const ThreadPoolDevice*, const Tensor<type, 1>&, const Tensor<type, 1>&);
94
95 Correlation logistic_correlation_vector_vector(const ThreadPoolDevice*, const Tensor<type, 1>&, const Tensor<type, 1>&);
96
97 Correlation logistic_correlation_vector_matrix(const ThreadPoolDevice*, const Tensor<type, 1>&, const Tensor<type, 2>&);
98
99 Correlation logistic_correlation_matrix_vector(const ThreadPoolDevice*, const Tensor<type, 2>&, const Tensor<type, 1>&);
100
101 Correlation logistic_correlation_matrix_matrix(const ThreadPoolDevice*, const Tensor<type, 2>&, const Tensor<type, 2>&);
102
103 Correlation correlation(const ThreadPoolDevice*, const Tensor<type, 2>&, const Tensor<type, 2>&);
104
105 // Time series correlation methods
106
107 Tensor<type, 1> autocorrelations(const ThreadPoolDevice*,
108 const Tensor<type, 1>&,
109 const Index& = 10);
110
111 Tensor<type, 1> cross_correlations(const ThreadPoolDevice*,
112 const Tensor<type, 1>&,
113 const Tensor<type, 1>&,
114 const Index&);
115
116 Tensor<type, 2> get_correlation_values(const Tensor<Correlation, 2>&);
117
118 // Missing values methods
119
120 pair<Tensor<type, 1>, Tensor<type, 1>> filter_missing_values_vector_vector(const Tensor<type, 1>&, const Tensor<type, 1>&);
121 pair<Tensor<type, 1>, Tensor<type, 1>> filter_missing_values_vector_matrix(const Tensor<type, 1>&, const Tensor<type, 1>&);
122 pair<Tensor<type, 1>, Tensor<type, 1>> filter_missing_values_matrix_vector(const Tensor<type, 1>&, const Tensor<type, 1>&);
123 pair<Tensor<type, 2>, Tensor<type, 2>> filter_missing_values_matrix_matrix(const Tensor<type, 2>&, const Tensor<type, 2>&);
124}
125
126
127#endif
128
129
130// OpenNN: Open Neural Networks Library.
131// Copyright(C) 2005-2021 Artificial Intelligence Techniques, SL.
132//
133// This library is free software; you can redistribute it and/or
134// modify it under the terms of the GNU Lesser General Public
135// License as published by the Free Software Foundation; either
136// version 2.1 of the License, or any later version.
137//
138// This library is distributed in the hope that it will be useful,
139// but WITHOUT ANY WARRANTY; without even the implied warranty of
140// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
141// Lesser General Public License for more details.
142
143// You should have received a copy of the GNU Lesser General Public
144// License along with this library; if not, write to the Free Software
145// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
This structure provides the results obtained from the regression analysis.
Definition: correlations.h:40
type a
Independent coefficient of the logistic function.
Definition: correlations.h:70
CorrelationMethod correlation_type
Regression method type.
Definition: correlations.h:82
type r
Correlation coefficient of the regression.
Definition: correlations.h:78
type b
x coefficient of the logistic function.
Definition: correlations.h:74