в
from sklearn.ensemble import IsolationForest
isol_forest = IsolationForest(n_estimators=50)
name1 = df['name1'].values.reshape(-1, 1) # преобразование в двухмерный массив
df_new = df[['name1', 'name2']]
isol_forest.fit(df_new)
scores = isol_forest.decision_function(df_new) #вызов функции decision_function
estimator = isol_forest.fit_predict(df_new)
outliers = [e for e in estimator if e == -1] # аномалии
print("Количество аномалий: ", len(outliers))