LSTM 数组转换

问题描述 投票:0回答:0

我正在编写一个函数来提取传递的 url 的特征并将其作为列表返回

def main(url):
    
    status = []
    
    status.append(having_ip_address(url))
    status.append(abnormal_url(url))
    status.append(count_dot(url))
    status.append(count_www(url))
    status.append(count_atrate(url))
    status.append(no_of_dir(url))
    status.append(no_of_embed(url))
    
    status.append(shortening_service(url))
    status.append(count_http(url))
    status.append(count_https(url))

    
    status.append(count_per(url))
    status.append(count_ques(url))
    status.append(count_hyphen(url))
    status.append(count_equal(url))
    
    status.append(url_length(url))
    status.append(hostname_length(url))
    status.append(suspicious_words(url))
    status.append(digit_count(url))
    status.append(letter_count(url))
    status.append(fd_length(url))
    tld = get_tld(url,fail_silently=True)
      
    status.append(tld_length(tld))
    
    
    

    return status

现在我在我的 LSTM 模型中使用这 21 个特征来预测它的输出

def get_prediction_from_url(test_url):
    features_test = main(test_url)
    features_test = np.array(features_test).reshape(features_test, [1, 1, 21])
    print(features_test)

    

    pred = model.predict(features_test)
    if int(pred[0]) == 0:
        
        res="SAFE"
        return res
    elif int(pred[0]) == 2.0:
        
        res="MALWARE"
        return res
    elif int(pred[0]) == 1.0:
        res="PHISHING"
        return res
        

但是它在 features_test = np.array 行上给出了一个错误,即“‘list’对象不能被解释为一个整数”

我期待将数组转换为 lstm 模型的数组,但数组转换给我带来了问题,我总共有 21 个特征

python multidimensional-array lstm
© www.soinside.com 2019 - 2024. All rights reserved.