Ejemplo n.º 1
0
    def remove_by_y(self, y_):
        corr = self.cov_y(self.data, y_)
        corr = self.feature_fold(corr)
        lcount = self.list_count
        fea_all = []
        score = name_to_name(corr,
                             search=lcount,
                             search_which=0,
                             return_which=(1, ),
                             two_layer=True)
        for score_i, list_i in zip(score, lcount):
            indexs = np.argmax(score_i)
            feature_index = list_i[int(indexs)]
            fea_all.append(feature_index)

        fea_all = sorted(list(set(fea_all)))
        return fea_all
Ejemplo n.º 2
0
    X_frame = data225_import.drop(['exp_gap', 'group_number'], axis=1)
    y_frame = data225_import['exp_gap']
    X = X_frame.values
    y = y_frame.values
    """calculate corr"""
    corr = Corr(threshold=0.90, muti_grade=2, muti_index=[2, len(X)])
    corr.fit(X_frame)
    cof_list = corr.count_cof()
    """get x_name and abbr"""

    X_frame_name = corr.transform(X_frame.columns.values)
    X_frame_name = [i.replace("_0", "") for i in X_frame_name]

    X_frame_abbr = name_to_name(name_init,
                                abbr_init,
                                search=X_frame_name,
                                search_which=1,
                                return_which=2,
                                two_layer=False)
    """rename"""
    # cov = pd.DataFrame(corr.cov_shrink)
    # cov = cov.set_axis(X_frame_abbr, axis='index', inplace=False)
    # cov = cov.set_axis(X_frame_abbr, axis='columns', inplace=False)
    #
    # # fig = plt.figure()
    # # fig.add_subplot(111)
    # # sns.heatmap(cov, vmin=-1, vmax=1, cmap="bwr", linewidths=0.3, xticklabels=True, yticklabels=True, square=True,
    # #             annot=True, annot_kws={'size': 3})
    # # plt.show()
    #
    # corr_plot(corr.cov_shrink, X_frame_abbr,title="", left_down="fill", right_top="pie", threshold_right=0, front_raito=0.4)
    #
Ejemplo n.º 3
0
    """base_method"""
    method_name = ['GPR-set', 'SVR-set', 'KRR-set', 'KNR-set']
    index_all = [data.pickle_pd.GPR_set23, data.pickle_pd.SVR_set23, data.pickle_pd.KR_set23, data.pickle_pd.KNR_set23]

    estimator_all = []
    for i in method_name:
        me1, cv1, scoring1, param_grid1 = dict_method_reg()[i]
        estimator_all.append(GridSearchCV(me1, cv=cv1, scoring=scoring1, param_grid=param_grid1, n_jobs=1))

    """union"""
    index_all = [tuple(index[0]) for _ in index_all for index in _[:10]]
    index_all = list(set(index_all))

    """get x_name and abbr"""
    index_all_name = name_to_name(X_frame.columns.values, search=[i for i in index_all],
                                  search_which=0, return_which=(1,), two_layer=True)

    index_all_name = [list(set([re.sub(r"_\d", "", j) for j in i])) for i in index_all_name]
    [i.sort() for i in index_all_name]
    index_all_abbr = name_to_name(name_init, abbr_init, search=index_all_name, search_which=1, return_which=2,
                                  two_layer=True)

    store.to_pkl_pd(index_all, "index_all")
    store.to_csv(index_all_name, "index_all_name")
    store.to_csv(index_all_abbr, "index_all_abbr")

    ugs = UGS(estimator_all, index_all, estimator_n=[2, 3], n_jobs=3)
    ugs.fit(X, y)
    # re = gs.cv_score_all(index_all)
    binary_distance = ugs.cal_binary_distance_all(index_all, estimator_i=3)
    # slice_k  = gs._cv_predict_all(estimator_i=3)
Ejemplo n.º 4
0
    y = y_frame.values
    #
    # """calculate corr"""
    corr = Corr(threshold=0.90, muti_grade=2, muti_index=[2, len(X)])
    corr.fit(X_frame)
    cof_list = corr.count_cof()
    #
    """get x_name and abbr"""

    X_frame_name = corr.transform(X_frame.columns.values)
    X_frame_name = [i.replace("_0", "") for i in X_frame_name]

    X_frame_abbr = name_to_name(name_and_abbr.columns.values,
                                list(name_and_abbr.iloc[0, :]),
                                search=X_frame_name,
                                search_which=1,
                                return_which=[
                                    2,
                                ],
                                two_layer=False)
    """rename"""
    # cov = pd.DataFrame(corr.cov_shrink)
    # cov = cov.set_axis(X_frame_abbr, axis='index', inplace=False)
    # cov = cov.set_axis(X_frame_abbr, axis='columns', inplace=False)
    #
    # fig = plt.figure()
    # fig.add_subplot(111)
    # sns.heatmap(cov, vmin=-1, vmax=1, cmap="bwr", linewidths=0.3, xticklabels=True, yticklabels=True, square=True,
    #             annot=True, annot_kws={'size': 3})
    # plt.show()
    #
    plt0 = corr_plot(corr.cov_shrink,
Ejemplo n.º 5
0
                             scoring=scoring1,
                             param_grid=param_grid1,
                             n_jobs=1)
    # n_select = [1,]
    n_select = (2, 3)
    clf = Exhaustion(estimator,
                     n_select=n_select,
                     muti_grade=2,
                     muti_index=[2, X.shape[1]],
                     must_index=None,
                     n_jobs=1,
                     refit=True).fit(X, y)

    name_ = name_to_name(X_frame.columns.values,
                         search=[i[0] for i in clf.score_ex[:10]],
                         search_which=0,
                         return_which=(1, ),
                         two_layer=True)
    sc = np.array(clf.scatter)

    for i in clf.score_ex[:]:
        print(i[1])
    for i in name_:
        print(i)

    t = clf.predict(X)
    p = BasePlot()
    p.scatter(y, t, strx='True $E_{gap}$', stry='Calculated $E_{gap}$')
    plt.show()
    p.scatter(sc[:, 0], sc[:, 1], strx='Number', stry='Score')
    plt.show()