擅长:python、mysql、java
<p>明白了,我修改了整件事,看起来很有效。请参见下面的外观</p>
<p>非常感谢你的帮助</p>
<pre><code> variables = list(range(X.shape[1]))
for i in variables:
vif = [variance_inflation_factor(X.iloc[:, variables].values, ix)
for ix in range(X.iloc[:, variables].shape[1])]
maxloc = vif.index(max(vif))
if max(vif) > thresh:
print('dropping \'' + X.iloc[:, variables].columns[maxloc] +
'\' at index: ' + str(maxloc))
del variables[maxloc]
print('Remaining variables:')
print(X.columns[variables])
return X.iloc[:, variables]
X = training_set
X2 = calculate_vif_(X)```
</code></pre>