# Tag Info

## Hot answers tagged python

5

You're trying to fit a linear model to distinctly nonlinear data. While linear regression does not limit you to lines, planes, and hyperplanes, it does limit you to lines, planes, and hyperplanes once you've decided on what you're going to feed into your regression. Try doing your regression on $x$, $x^2$, and $x^3$, maybe going up to $x^{11}$ or so to ...

4

You're asking for a linear model. $$\text{Results} = 100 \cdot \text{b1} + 10 \cdot \text{b2} + \text{b3} + 0\cdot \text{Date}$$ This solution is trivial because $\text{Result}$ is exactly represented by its digits, and has no relation at all to $\text{Date}$.

3

You have fitted an ARMA(1,1) model with an intercept (the "const") term, i.e., $$Y_t - c = \phi_1(Y_{t-1}-c) + \theta_1\epsilon_{t-1} + \epsilon_t,$$ where $$\hat{c} = 5873.4432, \quad \hat{\phi_1}=-0.6770, \quad \hat{\theta_1}=0.5240$$ and $$\epsilon_t\sim N(0,\sigma^2), \quad \hat{\sigma}=8807.627.$$ In forecasting the first step, say f\hat{\...

3

Is it rotated or flipped (like in a mirror)? The latter happens when you use eigen analysis to do PCA. You're essentially plotting the eigenvectors, and they are invariant to the sign. The sign can flip arbitrarily when you run eigenvalue routines, and it doesn't matter but can produce "flipped" plots Here's the horizontally flipped second image, compare it ...

2

You probably know the answer by now, but here I'll explain this for those who dont know what is happening here. When you want to change the image size, you also need to change your Discriminator and Generators networks. Both of these networks were designed with a specific image size in mind (e.g 64x64 in our case). Take this discriminator for example : ...

2

Colin Carol has a nice blog series on doing Hamiltonian Monte Carlo (the method by which Stan and PyMC3 do the sampling) from scratch. It's really good, and he even has a github repo called minimcmc which does some sampling. If you are interested in MCMC/HMC, I would start there. If you want to avoid MCMC/HMC all together, you are really limiting yourself....

2

There's at least three considerations here: effort: unless what you do is extremely time consuming and computationally expensive, the effort to try to come up with a better implementation is usually not worth it, even if it is possible (i.e. you save some seconds, but spend days implementing) flexibility (closely related to effort): major libraries tend to ...

2

The residuals from your model are not random as one can "see" a change in the mean possibly at year 2 period 4 effectively identifying the need for deterministic structure of some form . This data set requires a hybrid model containing memory (ARIMA) and deterministic structure. I will present the "logic" in identifying this model. Following this discussion ...

1

I can suggest a number of improvements that will make any minimization method more stable. instead of # Generates values from a normal distributed pdf pdf_vals = norm_pdf(xvals, mu, sigma) # Take log of normal distributed pdf values ln_pdf_vals = np.log(pdf_vals) you should analytically compute the log of the pdf. The reason is that the ...

1

To answer your main question: Multilevel TimeSeries modelling in Python There is nothing equivalent to the HTS package in Python. The two things that I know of that are the closest are PyAF and htsprophet. However they use different forecasting models than those used in HTS. PyAF uses models from scikit-learn to do forecasting, which is unusual since ...

1

I don't really know this test but if I base my code on that formula: where M = (P+Q)/2 and D(Q|M) the KLD between Q and M (same for D(P|M) so on python I do this: import numpy as np import scipy.stats x1 = np.random.normal(size=100) x2 = np.random.normal(size=100) p = scipy.stats.norm.cdf(x1) q = scipy.stats.norm.cdf(x2) m = (p + q) / 2 divergence = (...

1

Starting with an additive "variance components" model, I think the Python/Statsmodels code you want is like this: # df is your "toy data" df["groups"] = 0 fml = "dependent_var ~ 1" vcf =...

1

If you are looking to just build a "good" (aka good enough) model and are not restricted to one type of model or another, I would recommend the following sequence of actions. Perform a single factor analysis first, where you calculate the Accuracy Ratio between your default indicator and each of your independent variables (since the outcome variable is ...

1

My original comment misunderstood the nature of your problem. Indeed, it is correct that PyMC cannot model systems where the observed variable is deterministic. That was a bit of a surprise to me, but the article that you link provides a good reason why that is the case. Now, for your problem: Given that we cannot directly observe the sum-of-products $Y$ as ...

1

There is no model that will perform this as far as I know. The only option I see, if you really wanted to test pairs, is to build 3 models, one with A, one with B, and one with A and B. After this you check whether the last model performs better than the other ones. And you would have to perform this for every possible pair. If you have 200 million mutations ...

1

Tableau has a neat heat map tool that would be interesting show how the hashtag usage changes over time! As for collecting the data, I have only used a dataset for the entirety of hashtags as opposed to over time. I did stumble across this page that has a whole list of different applications for data crawling multiple social media platforms. I imagine you ...

1

If you examine this 3D scatter plot and 3D surface plot, you can see that the data is concentrated in one 3-space region on the left side of the images. From the "Y = a + (b * X1) + (c * X2)" linear regression surface plot, it appears that the region with a high data density is much more vertical than the fitted surface. In my personal opinion, the "body" ...

1

This seems more of an outlier/novelty detection task. Roughly speaking the goal in these settings is to examine what parts of the data "don't fit" based on their attribute realizations. I personally like the brief overview that the sklearn documentation provides on the topic, but implementations of various methods should be available in all common ...

1

Yes, it is possible and in general there is nothing wrong with it. You just want to treat your test split as validation and wait for a real test set. But, note that the answer might also depend on the choice of ML model. In many models, this won't be a problem; especially in simple models like decision trees. You've already found the best hyper-parameters, ...

1

try fixing the random seed before running the prediction (if this doesn't work at the beginning of the script). This should fix any stochasticity in the evaluation of the predict_proba method (I don't know if there is any...): np.random.seed(2000) clf.predict_proba(X) I also can't reproduce this error in sklearn 0.20.3 so try upgrading to this version if ...

1

Since your DV is Misfit, using Var1 and Var2 as your x-y axes, and coloring Misfit, i.e. your z and with a suitable colormap would be the best to obtain an intuition how your DVs combined effect look like. Specific to Python, you can use matplotlib scatter plots with c argument as your color variable. For example, in your case, assume we have a dataframe ...

1

Noting this in an answer as it solved the problem and the community has voted to keep the question open: The intercept is significant because the mean value of the response is detectably greater than zero. As you discovered, if you rescale the response variable by subtracting the mean, the intercept will be zero and no longer significant in subsequent ...

1

Mathematically, your conclusion is correct that the diagonals of your result equal the Hotelling's $T^2$ values for each sample. However, it took me a while to figure that out. So I'm posting my own answer in case it helps anyone else who is trying to calculate Hotelling's $T^2$ values using Python. According to the page you linked from wiki.eigenvector.com,...

Only top voted, non community-wiki answers of a minimum length are eligible