GithubHelp home page GithubHelp logo

ml_final's Introduction

ML_Final

1. Dependencies

Python 3.8 is required.

Clone the repository first

git clone https://github.com/chenjiaj109550158/ML_Final.git

and then install the dependencies.

pip install -r requirements_examples.txt

2. Training section

Run training section

python 109550158_Final_train.py

This will produce my_columns.npy in my_data and LR_models in models. my_columns.npy is the attributes chosen as features. LR_models are the train models.

There are some hyperparameters that can be adjusted to get better(or worse) performance.

n_neighbors: n_neighbors represents the number of the neighbors in KNN imputer.

    for code in train.product_code.unique():
        knnimputer1 = KNNImputer(n_neighbors=100)
        train.loc[train.product_code == code, t_list[1:-1]] = knnimputer1.fit_transform(
            train.loc[train.product_code == code, t_list[1:-1]])
        condition = train["product_code"] == code
        for c_n in t_list:
            if c_n != 'product_code' and c_n != 'failure' and c_n != 'attribute_0':
                train.where(condition)[c_n] = (train.where(condition)[
                    c_n] - train.where(condition)[c_n].mean()) / train.where(condition)[c_n].std()

my_columns_n and 'attribute_0' my_columns_n represents the number of the attributes chosen as features. It's optional to choose 'attribute_0' as a feature.

    my_columns_n = 2
    my_columns = np.array(cor.index)[0:1+my_columns_n]
    my_columns = np.append(my_columns, 'attribute_0')

random_state: The random_state of SMOTE

sm = SMOTE(random_state=42, n_jobs=-1)

max_iter and C: Hyperparameter in LogisticRegression

        model_lr = LogisticRegression(
            max_iter=700, C=0.1, dual=False, penalty="l2", solver='newton-cg')

3. Evaluation section

Run Evaluation section

python 109550158_Final_inference.py

The results will be saved in 109550158.csv.

Pre-trained models link: https://drive.google.com/drive/folders/1tbeLJngp6G5djGV9grW9UmRD2Kj8YTPI?usp=share_link

ml_final's People

Contributors

chenjiaj109550158 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.