Untitled

 avatar
user_0159819
plain_text
7 months ago
1.4 kB
2
Indexable
Never
# Identifying the unique SDT Types in the data
sdt_types = data['SDT Type'].unique()

# Dictionary to store model results for each SDT Type
sdt_type_optimizations = {}

# Analyzing each SDT Type separately
for sdt_type in sdt_types:
    # Filter data for the current SDT Type
    sdt_type_data = data[data['SDT Type'] == sdt_type]

    # Preparing data for regression
    X_sdt = sdt_type_data[['IN Gross', 'Out Tare (ton)']]
    y_sdt = sdt_type_data['Payload Netto (ton)']

    # Creating and fitting the linear regression model
    model_sdt = LinearRegression()
    model_sdt.fit(X_sdt, y_sdt)

    # Coefficients and intercept
    coefficients_sdt = model_sdt.coef_
    intercept_sdt = model_sdt.intercept_

    # Finding the maximum IN Gross and minimum Out Tare in the data for the current SDT Type
    max_in_gross = X_sdt['IN Gross'].max()
    min_out_tare = X_sdt['Out Tare (ton)'].min()

    # Calculating the maximum possible Payload Netto using the model
    # Payload Netto = Intercept + Coef_IN_Gross * IN_Gross + Coef_Out_Tare * Out_Tare
    max_payload_netto = intercept_sdt + coefficients_sdt[0] * max_in_gross + coefficients_sdt[1] * min_out_tare

    # Storing the results
    sdt_type_optimizations[sdt_type] = {
        'Max IN Gross': max_in_gross,
        'Min Out Tare': min_out_tare,
        'Max Payload Netto': max_payload_netto
    }

sdt_type_optimizations
Leave a Comment