# Importa le librerie import numpy as np import pandas as pd from sklearn.linear_model import LinearRegression from sklearn.model_selection import train_test_split from statsmodels.stats.diagnostic import het_breuschpagan from statsmodels.stats.outliers_influence import variance_inflation_factor import statsmodels.api as sm
# Carica i dati data = pd.read_csv("tuo_dataset.csv")
# Crea una matrice di design e una variabile dipendente X = data[['Variable1', 'Variable2', 'Variable3']] y = data['VariabileDipendente']
# Dividi i dati in training set e test set X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Crea un modello di regressione lineare model = LinearRegression()
# Verifica la collinearità vif = pd.DataFrame() vif["VIF"] = [variance_inflation_factor(X.values, i) for i in range(X.shape[1])] vif["Feature"] = X.columns print(vif)
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.