Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---------------------------------------------------------------------------
- TypeError Traceback (most recent call last)
- Cell In[58], line 6
- 4 vif=pd.DataFrame()
- 5 vif["feature"]=df.columns
- ----> 6 vif["value"]=[variance_inflation_factor(df.values,i) for i in range(len(df.columns))]
- File ~\AppData\Roaming\Python\Python312\site-packages\statsmodels\stats\outliers_influence.py:196, in variance_inflation_factor(exog, exog_idx)
- 194 mask = np.arange(k_vars) != exog_idx
- 195 x_noti = exog[:, mask]
- --> 196 r_squared_i = OLS(x_i, x_noti).fit().rsquared
- 197 vif = 1. / (1. - r_squared_i)
- 198 return vif
- File ~\AppData\Roaming\Python\Python312\site-packages\statsmodels\regression\linear_model.py:924, in OLS.__init__(self, endog, exog, missing, hasconst, **kwargs)
- 921 msg = ("Weights are not supported in OLS and will be ignored"
- 922 "An exception will be raised in the next version.")
- 923 warnings.warn(msg, ValueWarning)
- --> 924 super().__init__(endog, exog, missing=missing,
- 925 hasconst=hasconst, **kwargs)
- 926 if "weights" in self._init_keys:
- 927 self._init_keys.remove("weights")
- File ~\AppData\Roaming\Python\Python312\site-packages\statsmodels\regression\linear_model.py:749, in WLS.__init__(self, endog, exog, weights, missing, hasconst, **kwargs)
- 747 else:
- 748 weights = weights.squeeze()
- --> 749 super().__init__(endog, exog, missing=missing,
- 750 weights=weights, hasconst=hasconst, **kwargs)
- 751 nobs = self.exog.shape[0]
- 752 weights = self.weights
- File ~\AppData\Roaming\Python\Python312\site-packages\statsmodels\regression\linear_model.py:203, in RegressionModel.__init__(self, endog, exog, **kwargs)
- 202 def __init__(self, endog, exog, **kwargs):
- --> 203 super().__init__(endog, exog, **kwargs)
- 204 self.pinv_wexog: Float64Array | None = None
- 205 self._data_attr.extend(['pinv_wexog', 'wendog', 'wexog', 'weights'])
- File ~\AppData\Roaming\Python\Python312\site-packages\statsmodels\base\model.py:270, in LikelihoodModel.__init__(self, endog, exog, **kwargs)
- 269 def __init__(self, endog, exog=None, **kwargs):
- --> 270 super().__init__(endog, exog, **kwargs)
- 271 self.initialize()
- File ~\AppData\Roaming\Python\Python312\site-packages\statsmodels\base\model.py:95, in Model.__init__(self, endog, exog, **kwargs)
- 93 missing = kwargs.pop('missing', 'none')
- 94 hasconst = kwargs.pop('hasconst', None)
- ---> 95 self.data = self._handle_data(endog, exog, missing, hasconst,
- 96 **kwargs)
- 97 self.k_constant = self.data.k_constant
- 98 self.exog = self.data.exog
- File ~\AppData\Roaming\Python\Python312\site-packages\statsmodels\base\model.py:135, in Model._handle_data(self, endog, exog, missing, hasconst, **kwargs)
- 134 def _handle_data(self, endog, exog, missing, hasconst, **kwargs):
- --> 135 data = handle_data(endog, exog, missing, hasconst, **kwargs)
- 136 # kwargs arrays could have changed, easier to just attach here
- 137 for key in kwargs:
- File ~\AppData\Roaming\Python\Python312\site-packages\statsmodels\base\data.py:675, in handle_data(endog, exog, missing, hasconst, **kwargs)
- 672 exog = np.asarray(exog)
- 674 klass = handle_data_class_factory(endog, exog)
- --> 675 return klass(endog, exog=exog, missing=missing, hasconst=hasconst,
- 676 **kwargs)
- File ~\AppData\Roaming\Python\Python312\site-packages\statsmodels\base\data.py:88, in ModelData.__init__(self, endog, exog, missing, hasconst, **kwargs)
- 86 self.const_idx = None
- 87 self.k_constant = 0
- ---> 88 self._handle_constant(hasconst)
- 89 self._check_integrity()
- 90 self._cache = {}
- File ~\AppData\Roaming\Python\Python312\site-packages\statsmodels\base\data.py:133, in ModelData._handle_constant(self, hasconst)
- 131 check_implicit = False
- 132 exog_max = np.max(self.exog, axis=0)
- --> 133 if not np.isfinite(exog_max).all():
- 134 raise MissingDataError('exog contains inf or nans')
- 135 exog_min = np.min(self.exog, axis=0)
- TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement