Perform DTW simultaneously on multiple trajectories

Good day, I have ~50 sample trajectories (timeseries) showing reactor temperature over time for a given process. In addition, I have a reference signal of the ideal trajectory for this process. I would like to synchronize all the sample trajectories with the reference trajectory. Performing DTW with 1 sample signal and reference produces new signals along a common axis (as it should). My question is how can I perform this synchronization of all sample trajectories with the reference simultaneously? Such …
Category: Data Science

gradient descent diverges extremely

I have manually created a random data set around some mean value and I have tried to use gradient descent linear regression to predict this simple mean value. I have done exactly like in the manual and for some reason my predictor coefficients are going to infinity, even though it worked for another case. Why, in this case, can it not predict a simple 1.4 value? clear all; n=10000; t=1.4; sigma_R = t*0.001; min_value_t = t-sigma_R; max_value_t = t+sigma_R; y_data …
Category: Data Science

Polynomial regression with two variables. How can I find expressions to describe the coefficients?

I'm not sure if this is an appropriate place for this question, so please feel free to redirect me if it is not. I just moved it from Super User, where it seemed like there weren't many similar questions. Please also feel free to suggest tags. I'm trying to modify part of an old code. It uses regression to describe the relationship between two variables (described as "a fourth order power series in X and y"). I know very little …
Category: Data Science

Where can I find an algorithm for human activity classification using thigh and shank sensors?

I am working on a project where I initially need to classify the type of activity a subject is performing based on raw accelerometer and gyroscope data from the thigh and shank of both legs. The type of activities would be day-to-day tasks such as standing, sitting, running, sit-to-stand, stair climbing, if playing sports, cutting, etc. I have tried reading papers and looking on git to find an algorithm that will do this for me. I know that there are …
Category: Data Science

Performing 1D Depthwise conv using Keras 2D Depthwise conv

I would like to perform a 1D Depthwise convolution (ie the first step of the depthwise-separable convolution) for a machine learning model I am working on. This means that for an input activation space of h x w, there are h kernels, each 1xk, where k is the length of the kernel (see attached figure). This is not currently offered by Keras, but one can use the available Depthwise 2D convolution (which operates on 3D inputs), and simply add an …
Category: Data Science

How do you calculate Precision and Recall using a confusion matrix in Matlab?

I am working on a three class problem. How do you calculate precision, recall, f-score, and MCC for each class while using MATLAB? Here is my confusion matrix: 2775 0 0 1 591 0 4 0 845 I am calculating Accuracy from the Confusion matrix in this way: Accuracyy = 100*sum(diag(confusionMat))./sum(confusionMat(:)); I would like to measure the below performance measures for each class. I know the formulas, but not how to execute this in MATLAB. Please help. I would really …
Category: Data Science

What's the correct form of use the real coded genetic algorithm?

I'm new to genetic algorithms, but I haven't found specific info about real-coded GA's. I want to do antenna array optimization by using the real values of antenna position, phase, and amplitude, but I've only found binary encodings. Although the binary encodings seem easier during crossover, but I would like to use real continuous values, but I don't know how to apply crossover. In MATLAB, I've been using an error value as a fitness function obtaining a vector with all …
Category: Data Science

LSTM for multiple time series

I am working with FE simulation data of 30 inputs and 30 outputs of various lengths. My input is the temperature cycle over time and I want to predict accumulation of plastic strains over time. My data just an example x--> 273,300,325,385,310..... y--> 0.0176,0.01764,0.0177,0.0181,0.0183... 30 such curves with 400-500 points each. I have resampled the data to have each time stamps of 60secs. I used taken differences of the output as had an increasing trend. My prediction data now in …
Topic: lstm matlab
Category: Data Science

Semi-Unsupervised learning - kmeans

Given data that contain n vector (m×1 each). I want to cluster the data based on distance. Also, each vector in the data is labeled to some category. I used kmeans algorithm (in Matlab) to cluster the data. I want that non of the clusters will include data from only one category. There is any way to add this constraint, or any algorithm that could do it? Thanks!
Category: Data Science

Why are my ridge regression coefficients completely different from ordinary linear regression coefficients in MATLAB?

I am attempting to implement my own Ridge Regression algorithm and I am trying to achieve similar coefficients found in a MATLAB tutorial on regression. Specifically, on the MATLAB tutorial page you will see: load carsmall x1 = Weight; x2 = Horsepower; % Contains NaN data y = MPG; X = [ones(size(x1)) x1 x2 x1.*x2]; b = regress(y,X) % Removes NaN data b = 4×1 60.7104 -0.0102 -0.1882 0.0000 Above, you can see the first coefficient is about 60, and …
Category: Data Science

Tensorflow simple neural network has very bad performance in regression (curve fitting) problem

I'm trying to implement a very simple one layered MLP for a toy regression problem with one variable (dimension = 1) and one target (dimension = 1). It's a simple curve fitting problem with zero noise. Matlab - Deep Learning Toolbox Using levenberg-marquardt backpropagation on a MLP with a single hidden layer with 100 neurons and hyperbolic tangent activation I got pretty decent performance with almost zero effort: MSE = 7.18e-08 Here's a plot of the fitting: Edit: This is …
Category: Data Science

Estimating joint angle using machine learning methods

I am currently working on a project which uses IMU sensor data in order to predict the Knee Angle at each time point. My input data consists of 9 sensors, I plotted an example section below. The goal of the algorithm now is to find the point where the knee angle reversal takes place (indexed in red) or predict the knee angle over the whole time section. This would depend either I choose a classification model (1 for a swing …
Category: Data Science

Block matrix indexing

Hello this might be a stupid question but i need some help indexing a Matlab matrix consisting of several sub-matrices. for k = 1:tf-1 r(k) = rand(1)/4; u(k+1) = 0.5; x1(k+1) = A(1,1)*x1(k) + A(1,2)*x2(k) + B(1,1)*u(k); x2(k+1) = A(2,1)*x1(k) + A(2,2)*x2(k) + B(2,1)*u(k); x = [x1(k) x2(k)]'; y(k) = C*x + r(k); P_prior(k+1) = A*P(k)*A.' + Q; K(k+1) = P_prior(k+1)*C.'/(C*P_prior(k+1)*C.' + R); xhat(k+1) = x(k+1) + K(k+1)*(y(k) - C*x(k+1)); P(k+1) = (eye(size(1,1)) - K(k+1)*C)*P_prior(k+1); end For example i want …
Category: Data Science

Hamming distance between column-wise of two matrices

Is there any MATLAB trick to perform hamming distance between columns of two different binary matrices(-1 & 1): A(64 by100) and B(64 by 80), and report the minimum distances? "A" is a data matrix with 100 samples, and "B" has 80 cluster centroids and in terms of clustering i would like to create the indicator matrix based on the minimum hamming distance between A and B. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Just an erroneous MATLAB example %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% HamDist = pdist2(B,C,'hamming'); [~,ind] = min(HamDist,[],2);
Category: Data Science

How to find the average over an area of center for a given radius

I have an excel file which contains the lat and long values of the center of a Tropical Cyclone(TC). The excel file is as given below: 19.8 69.4 20 69 20.4 68.2 20.5 67.2 20.5 65.7 20.3 65 20.2 64.2 20.2 63.7 20.2 62.9 20.2 62.3 20.2 61.5 20.1 61 20.1 60.3 20 59.5 19.9 58.9 19.8 58.3 Also, I have an NC(NetCDF) file which is of that of air temperature(The link to the data is given)air_temp.nc. Now what I …
Category: Data Science

Finding roots of a non linear expression when multiplied with a linear expression

Here is a simple polynomial equation: b^2 + 2b + 1 = 0 I could easily solve this as: import numpy as np from scipy.optimize import fsolve eq = lambda b : np.power(b,2) + 2*b + 1 fsolve(eq, np.linspace(0,1,2)) Similarly, I could solve any equation that has finite number of terms. But how do I solve an equation with infinite number of terms which is given as: $G_t^{\lambda}=(1-\lambda) \sum \limits_{n=1}^{\infty} \lambda^{n-1}G_{t:t+n}$ The above equation could be written as: (1 - …
Topic: matlab python
Category: Data Science

Which machine learning model is best for a combination of numerical and categorical data?

I want to develop a ML model which will allow my company to highlight employees which are at a risk of leaving the business, based on a variety of parameters such as performance, absence rates, location, age, team manager etc. We have a fairly diverse database of individuals who have already left the business, with values for each of the inputs which can be used to train the model. The output is a simple 1 or 0: based on all …
Category: Data Science

Pixel labelled image is must for semantic segmentation using deep learning in matlab?

I have large set of CT images containing lung regions. But I don't have corrosponding pixel labelled images. So how I could do semantic segmentation using DL in matlab. Like a test program I created 6 pixel labelled images using image Labeler. But it's not practical. I have thousands of such images. Could someone help me with a solution?
Category: Data Science

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.