File size: 1,285 Bytes
8bc6fd8
9e1219a
 
8bc6fd8
 
9e1219a
 
 
 
8bc6fd8
9e1219a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import argparse
import pandas as pd
import joblib


def run_prediction():
    input_path = "data/X_test_1st.csv"
    output_path = "results/predictions.csv"
    model_path = "model/best_model.pkl"

    # Load data and model
    df = pd.read_csv(input_path)
    model = joblib.load(model_path)

    # Preprocessing
    features = [
        'product_category_1',
        'product_category_2',
        'user_depth',
        'age_level',
        'city_development_index',
        'var_1',
        'gender'
    ]

    X = df[features]
    X = pd.get_dummies(X, columns=['gender'], drop_first=True)

    # Predict
    predictions = model.predict(X)

    # Save predictions
    df['predictions'] = predictions
    df.to_csv(output_path, index=False)
    print(f"Predictions saved to {output_path}")


    
# def main():
#     parser = argparse.ArgumentParser()
#     parser.add_argument('--model-path', type=str, required=True, help='Path to the trained model')
#     parser.add_argument('--input-data', type=str, required=True, help='Path to input data for prediction')
#     args = parser.parse_args()

#     print(f"Loading model from {args.model_path}")
#     print(f"Predicting on data from {args.input_data}")
#     # Add prediction logic here

# if __name__ == '__main__':
#     main()