模拟退火算法之特征选择的python实现(二)

目录

1. 模拟退火算法之特征选择的python实现(类封装)

2. 实验结果

按照模拟退火算法基本流程的python实现,可以参考模拟退火算法之特征选择的python实现(一)

特此申明:代码是作者辛辛苦苦码的, 转载请注明出处

1. 模拟退火算法之特征选择的python实现(类封装)

import numpy as np
from sklearn.metrics import mean_squared_error
import numpy as np
from sklearn.neural_network import MLPRegressor
import scipy.io as sio
from sklearn.model_selection import train_test_split


class SimulatedAnnealing(object):
    """Feature selection with simulated annealing algorithm.

    parameters
    ----------
    initT: int or float, default: 100
        The maximum temperature
    minT: int or float, default: 1
        The minimum temperature
    alpha:float, default:0.98
        Decay coefficient of temperature
    iteration: int, default:50
        Balance times at present temperature
    features: int
        The number of attributes in the original data
    init_features_sel: int
        The index of selected fatures
    estimator: object
        A supervised learning estimator with a `fit` method.

    Attributes
    ----------
    temp_history: array
        record the temperatures
    best_cost_history: array
        record the MSEs
    best_solution_history: array
        record the solutions
    """

    def __init__(self, features, ini
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值