Beispiel #1
0
    results = {
        'realization': [],
        'ACCURACY': [],
        # 'MCC': [],
        'f1_score': [],
        'precision': [],
        'recall': [],
        'cf': [],
        'alphas': []
    }

    # carregar a base
    base = load_base(path='iris.data', type='csv')

    # normalizar a base
    base[['SepalLengthCm', 'SepalWidthCm', 'PetalLengthCm', 'PetalWidthCm']] = normalization(
        base[['SepalLengthCm', 'SepalWidthCm', 'PetalLengthCm', 'PetalWidthCm']], type='min-max')

    N, M = base.shape
    C = len(base['Species'].unique())

    y_out_of_c = pd.get_dummies(base['Species'])

    base = base.drop(['Species'], axis=1)
    base = concatenate([base[['SepalLengthCm', 'SepalWidthCm', 'PetalLengthCm', 'PetalWidthCm']], y_out_of_c], axis=1)

    for realization in range(20):
        train, test = split_random(base, train_percentage=.8)
        train, train_val = split_random(train, train_percentage=.8)

        x_train = train[:, :4]
        y_train = train[:, 4:]
Beispiel #2
0
    # carregar a base
    base = load_base(path='column_3C_weka.arff', type='arff')

    # features
    features = ['pelvic_incidence', 'pelvic_tilt', 'lumbar_lordosis_angle', 'sacral_slope', 'pelvic_radius',
                'degree_spondylolisthesis']

    print(base.info())

    # ----------------------------- Clean the data ----------------------------------------------------------------

    # -------------------------- Normalization ------------------------------------------------------------------

    # normalizar a base
    base[features] = normalization(base[features], type='min-max')

    base = base.drop(['pelvic_incidence', 'pelvic_tilt', 'lumbar_lordosis_angle', 'sacral_slope'], axis=1)
    # ------------------------------------------------------------------------------------------------------------
    base['class'][base['class'] == b'Abnormal'] = 1
    base['class'][base['class'] == b'Normal'] = 0

    for one_versus_others in ['Hernia_vs_OT', 'Spondylolisthesis_vs_OT', 'Normal_vs_OT']:
        final_result = {
            'ACCURACY': [],
            'std ACCURACY': [],
            'f1_score': [],
            'std f1_score': [],
            'precision': [],
            'std precision': [],
            'recall': [],
Beispiel #3
0
    df = df.iloc[:100000]
    nRow, nCol = df.shape
    print(f'There are {nRow} rows and {nCol} columns')


    df.info()

    features = ['u_q', 'coolant', 'u_d', 'motor_speed',
                'i_d', 'i_q', 'ambient', 'torque'] # 'profile_id'

    targets = ['stator_yoke', 'pm',  'stator_winding', 'stator_tooth']

    # -------------------- Realiztions ---------------------------------------------

    # normalizar a base
    df[features] = normalization(df[features], type='min-max')

    N, M = df.shape
    C = 1  # Problema de regressão

    for different_target in targets:
        print('Target: ' + different_target)
        final_result = {
            'MSE': [],
            'std MSE': [],
            'RMSE': [],
            'std RMSE': [],
            'alphas': []
        }

        results = {
Beispiel #4
0
    }

    results = {
        'realization': [],
        'ACCURACY': [],
        # 'MCC': [],
        'f1_score': [],
        'precision': [],
        'recall': [],
        'cf': [],
        'alphas': []
    }

    base = load_mock(type='TRIANGLE_CLASSES')
    # normalizar a base
    base[['x1', 'x2']] = normalization(base[['x1', 'x2']], type='min-max')

    x = array(base[['x1', 'x2']])
    y = array(base[['y']])

    classe0 = x[np.where(y == 0)[0]]
    classe1 = x[np.where(y == 1)[0]]
    classe2 = x[np.where(y == 2)[0]]

    plt.plot(classe0[:, 0], classe0[:, 1], 'b^')
    plt.plot(classe1[:, 0], classe1[:, 1], 'go')
    plt.plot(classe2[:, 0], classe2[:, 1], 'm*')
    plt.xlabel("X1")
    plt.ylabel("X2")
    plt.savefig(get_project_root() + '/run/TR-03/ARTIFICIAL/results/' +
                'dataset_artificial.png')
Beispiel #5
0
    # ----------------------------- Clean the data ----------------------------------------------------------------

    # The Age has values ?
    for unique_value in base['x33'].unique():
        if unique_value != '?':
            base['x33'][base['x33'] == unique_value] = int(unique_value)

    # ? -> mean of column
    base['x33'][base['x33'] == '?'] = int(
        np.mean(base['x33'][base['x33'] != '?']))

    # -------------------------- Normalization ------------------------------------------------------------------

    # normalizar a base
    base[features] = (normalization(base[features],
                                    type='min-max')).to_numpy(dtype=np.float)

    # ------------------------------------------------------------------------------------------------------------

    N, M = base.shape
    C = len(base['y'].unique())

    y_out_of_c = pd.get_dummies(base['y'])

    base = base.drop(['y'], axis=1)
    base = concatenate([base[features], y_out_of_c], axis=1)

    for realization in range(1):
        train, test = split_random(base, train_percentage=.8)
        train, train_val = split_random(train, train_percentage=.8)