47281/ignore-the-nan-and-the-linear-regression-on-remaining-values

Is there a way to ignore the NaN and do the linear regression on remaining values?

val=([0,2,1,'NaN',6],[4,4,7,6,7],[9,7,8,9,10]) time=[0,1,2,3,4] slope_1 = stats.linregress(time,values[1]) # This works slope_0 = stats.linregress(time,values[0]) # This doesn't work

Yes, you can do this using statsmodels:

import statsmodels.api as sm from numpy import NaN x = [0, 2, NaN, 4, 5, 6, 7, 8] y = [1, 3, 4, 5, 6, 7, 8, 9] model = sm.OLS(y, x, missing='drop') results = model.fit() In [2]: results.params Out[2]: array([ 1.16494845])

Hi Dev, to answer your question Linear Regression ...READ MORE

The above situation is the case where ...READ MORE

Use the following code: from scipy import stats slope, ...READ MORE

when we train a model with data, ...READ MORE

Hey @Tanmay, try something like this: >>> from ...READ MORE

Hey @Vivek, Try something like this: >>> from ...READ MORE

Supervised learning is the machine learning task ...READ MORE

In reinforcement learning, the output depends on ...READ MORE

Hey @Ruth, you can use this model ...READ MORE

LassoLars is a lasso model implemented using ...READ MORE

OR

At least 1 upper-case and 1 lower-case letter

Minimum 8 characters and Maximum 50 characters

Already have an account? Sign in.