cor_list = []
#calculate the correlation with y for each feature
for i in all_features:
cor = np.corrcoef(X_train[i], y_train, rowvar=False)[0, 1]
cor_list.append(cor)
#replace NaN with 0
cor_list = [0 if np.isnan(i) else i for i in cor_list]
#feature_name
cor_feature = X_train.iloc[:np.argsort(np.abs(cor_list))[-num_feats:]].columns.tolist()
#feature selection? 0 for not select, 1 for select
cor_support = [True if i in cor_feature else False for i in all_features]
X_train_selected = pd.DataFrame(X_train, columns=cor_feature)
X_test_selected = pd.DataFrame(X_test, column = cor_feature)
# Correlation with output variable
return X_train_selected, X_test_selected
**This when i called in main:**
``` all_features = X_train.keys()
X_train_selected, X_test_selected = FS.Feature_cor_selector(X_train, X_test, y_train, 10, all_features) ```
AttributeError: „numpy.ndarray“-Objekt hat kein Attribut „keys“
Das ist mein Code: [code] cor_list = []
#calculate the correlation with y for each feature for i in all_features: cor = np.corrcoef(X_train[i], y_train, rowvar=False)[0, 1] cor_list.append(cor) #replace NaN with 0 cor_list = [0 if np.isnan(i) else i for i in cor_list] #feature_name cor_feature = X_train.iloc[:np.argsort(np.abs(cor_list))[-num_feats:]].columns.tolist() #feature selection? 0 for not select, 1 for select cor_support = [True if i in cor_feature else False for i in all_features] X_train_selected = pd.DataFrame(X_train, columns=cor_feature) X_test_selected = pd.DataFrame(X_test, column = cor_feature) # Correlation with output variable return X_train_selected, X_test_selected
Ich versuche, Zielcodierung auf kategorische Merkmale mit den category_encoders.targetEnCoder in Python anzuwenden. Ich erhalte jedoch immer wieder den folgenden Fehler:
AttributeError:...
Ich habe die folgende case-Anweisung in meinem Code:
status = case(
(
orders.c.item_delivered.is_(True),
OrderStatus.DELIVERED.value,
),
(
orders.c.order_processing_status ==...
Ich habe die folgende case-Anweisung in meinem Code:
status = case(
(
orders.c.item_delivered.is_(True),
OrderStatus.DELIVERED.value,
),
(
orders.c.order_processing_status ==...
Ich versuche, ResNet3D aus TensorFlow-Models Bibliothek zu verwenden, aber ich erhalte diesen seltsamen Fehler, wenn ich versuche, den Block
auszuführen def create_model():
base_model =...