File size: 5,125 Bytes
55cdb7e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
07d23c4
55cdb7e
 
 
07d23c4
a32e584
1a584f9
55cdb7e
 
 
 
07d23c4
55cdb7e
 
 
07d23c4
a32e584
1a584f9
55cdb7e
 
 
 
 
 
 
 
 
 
 
07d23c4
55cdb7e
 
 
07d23c4
a32e584
1a584f9
55cdb7e
 
 
 
07d23c4
55cdb7e
 
 
07d23c4
a32e584
1a584f9
55cdb7e
 
 
 
 
 
 
 
 
 
 
07d23c4
55cdb7e
 
 
07d23c4
a32e584
1a584f9
55cdb7e
 
 
 
07d23c4
55cdb7e
 
 
07d23c4
a32e584
1a584f9
55cdb7e
 
 
 
 
 
 
 
 
 
 
07d23c4
55cdb7e
 
 
07d23c4
a32e584
1a584f9
55cdb7e
 
 
 
07d23c4
55cdb7e
 
 
07d23c4
a32e584
1a584f9
55cdb7e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
"""Example script showing how to use the salary prediction model programmatically."""

from src.schema import SalaryInput
from src.infer import predict_salary


def main():
    """Run sample predictions with different input parameters."""

    print("=" * 60)
    print("Developer Salary Prediction - Sample Inference")
    print("=" * 60)

    # Example 1: Default parameters (same as Streamlit app defaults)
    print("\nπŸ“Š Example 1: Default Parameters")
    print("-" * 60)

    input_data_1 = SalaryInput(
        country="United States of America",
        years_code=5.0,
        work_exp=3.0,
        education_level="Bachelor's degree (B.A., B.S., B.Eng., etc.)",
        dev_type="Developer, full-stack",
        industry="Software Development",
        age="25-34 years old",
        ic_or_pm="Individual contributor",
        org_size="20 to 99 employees",
    )

    print(f"Country: {input_data_1.country}")
    print(f"Years of Coding (Total): {input_data_1.years_code}")
    print(f"Work Experience: {input_data_1.work_exp}")
    print(f"Education Level: {input_data_1.education_level}")
    print(f"Developer Type: {input_data_1.dev_type}")
    print(f"Industry: {input_data_1.industry}")
    print(f"Age: {input_data_1.age}")
    print(f"IC or PM: {input_data_1.ic_or_pm}")
    print(f"Organization Size: {input_data_1.org_size}")

    salary_1 = predict_salary(input_data_1)
    print(f"πŸ’° Predicted Salary: ${salary_1:,.2f} USD/year")

    # Example 2: Junior developer
    print("\nπŸ“Š Example 2: Junior Developer")
    print("-" * 60)

    input_data_2 = SalaryInput(
        country="United States of America",
        years_code=2.0,
        work_exp=1.0,
        education_level="Master's degree (M.A., M.S., M.Eng., MBA, etc.)",
        dev_type="Developer, front-end",
        industry="Fintech",
        age="18-24 years old",
        ic_or_pm="Individual contributor",
        org_size="20 to 99 employees",
    )

    print(f"Country: {input_data_2.country}")
    print(f"Years of Coding (Total): {input_data_2.years_code}")
    print(f"Work Experience: {input_data_2.work_exp}")
    print(f"Education Level: {input_data_2.education_level}")
    print(f"Developer Type: {input_data_2.dev_type}")
    print(f"Industry: {input_data_2.industry}")
    print(f"Age: {input_data_2.age}")
    print(f"IC or PM: {input_data_2.ic_or_pm}")
    print(f"Organization Size: {input_data_2.org_size}")

    salary_2 = predict_salary(input_data_2)
    print(f"πŸ’° Predicted Salary: ${salary_2:,.2f} USD/year")

    # Example 3: Senior developer with Master's degree
    print("\nπŸ“Š Example 3: Senior Developer")
    print("-" * 60)

    input_data_3 = SalaryInput(
        country="United States of America",
        years_code=10.0,
        work_exp=8.0,
        education_level="Master's degree (M.A., M.S., M.Eng., MBA, etc.)",
        dev_type="Engineering manager",
        industry="Banking/Financial Services",
        age="35-44 years old",
        ic_or_pm="People manager",
        org_size="1,000 to 4,999 employees",
    )

    print(f"Country: {input_data_3.country}")
    print(f"Years of Coding (Total): {input_data_3.years_code}")
    print(f"Work Experience: {input_data_3.work_exp}")
    print(f"Education Level: {input_data_3.education_level}")
    print(f"Developer Type: {input_data_3.dev_type}")
    print(f"Industry: {input_data_3.industry}")
    print(f"Age: {input_data_3.age}")
    print(f"IC or PM: {input_data_3.ic_or_pm}")
    print(f"Organization Size: {input_data_3.org_size}")

    salary_3 = predict_salary(input_data_3)
    print(f"πŸ’° Predicted Salary: ${salary_3:,.2f} USD/year")

    # Example 4: Different country
    print("\nπŸ“Š Example 4: Different Country (Germany)")
    print("-" * 60)

    input_data_4 = SalaryInput(
        country="Germany",
        years_code=5.0,
        work_exp=3.0,
        education_level="Bachelor's degree (B.A., B.S., B.Eng., etc.)",
        dev_type="Developer, back-end",
        industry="Manufacturing",
        age="25-34 years old",
        ic_or_pm="Individual contributor",
        org_size="100 to 499 employees",
    )

    print(f"Country: {input_data_4.country}")
    print(f"Years of Coding (Total): {input_data_4.years_code}")
    print(f"Work Experience: {input_data_4.work_exp}")
    print(f"Education Level: {input_data_4.education_level}")
    print(f"Developer Type: {input_data_4.dev_type}")
    print(f"Industry: {input_data_4.industry}")
    print(f"Age: {input_data_4.age}")
    print(f"IC or PM: {input_data_4.ic_or_pm}")
    print(f"Organization Size: {input_data_4.org_size}")

    salary_4 = predict_salary(input_data_4)
    print(f"πŸ’° Predicted Salary: ${salary_4:,.2f} USD/year")

    print("\n" + "=" * 60)
    print("βœ… All predictions completed successfully!")
    print("=" * 60)


if __name__ == "__main__":
    try:
        main()
    except FileNotFoundError:
        print("❌ Error: Model file not found!")
        print("Please train the model first by running:")
        print("  uv run python src/train.py")
    except Exception as e:
        print(f"❌ Error occurred: {str(e)}")