Sunday, 17 May 2026

Part 2: Building a Python Model for Cotton Yarn Quality Optimisation Using SVR, Genetic Algorithm and Desirability Function



Part 2: Building a Python Model for Cotton Yarn Quality Optimisation Using SVR, Genetic Algorithm and Desirability Function

In the previous article, we discussed how cotton yarn quality can be optimised through the careful selection of raw material parameters. The main idea was simple but powerful: yarn quality does not depend on one fibre property alone. It depends on a combination of fibre strength, elongation, length, uniformity, fineness and short fibre content.

In this second part, we will convert that idea into a simple Python demonstration. The purpose is not to reproduce the exact experimental model of the research paper, but to understand how such a model can be built. We will assume suitable spinning data, train a prediction model, and then use an optimisation algorithm to search for the best cotton fibre profile.

\[ \text{Cotton Fibre Parameters} \rightarrow \text{SVR Prediction Model} \rightarrow \text{Genetic Algorithm Search} \rightarrow \text{Optimum Yarn Quality} \]

This kind of approach is useful because textile mills often face a practical question: “Given several cotton lots, which combination of fibre properties will give the best yarn quality?” Traditionally, this decision depends on experience, HVI values, past spinning behaviour and the spinner’s judgement. A model-based approach does not replace experience, but it can support that experience with data.

What We Are Trying to Model

In this demonstration, we take six cotton fibre properties as input variables. These variables represent the raw material side of the spinning problem and are commonly used to judge whether a cotton lot is suitable for a particular yarn requirement.

Fibre Parameter Meaning
FS Fibre strength
FE Fibre elongation
UHML Upper half mean length
UI Uniformity index
FF Fibre fineness
SFC Short fibre content

These fibre properties are then used to predict four yarn quality parameters. The important point is that these yarn properties do not all move in the same direction. For yarn strength and elongation, higher values are preferred. For unevenness and hairiness, lower values are preferred.

Yarn Quality Parameter Desired Direction
Yarn strength Higher is better
Yarn elongation Higher is better
Unevenness U% Lower is better
Hairiness index Lower is better

This is important because yarn quality is not a single number. A yarn with high strength but high hairiness may not be acceptable. Similarly, a yarn with good elongation but poor evenness may create fabric defects. Therefore, the model must balance several responses together.

\[ \text{Good Yarn Quality} = \text{High Strength} + \text{High Elongation} + \text{Low Unevenness} + \text{Low Hairiness} \]

Why We Are Using Assumed Data

For this blog, we assume suitable data because actual spinning mill data may not be available to every reader. The assumed data follows textile logic. For example, higher fibre strength should generally improve yarn strength. Higher short fibre content should generally increase unevenness and hairiness. Better uniformity should generally improve yarn regularity.

However, it is important to remember that this is only a learning model. A real mill should train the model using its own data. Cotton variety, bale mixing, machine condition, humidity, carding efficiency, drafting settings and twist level can all influence the final yarn result.

Important positioning: This is an educational Python demonstration inspired by spinning optimisation logic. It should not be treated as a universal formula for cotton yarn prediction.

Step 1: Importing the Required Libraries

We first import the Python libraries needed for the model. We use numpy and pandas for data handling, scikit-learn for Support Vector Regression, and scipy for optimisation.

import numpy as np
import pandas as pd

from sklearn.model_selection import train_test_split
from sklearn.svm import SVR
from sklearn.multioutput import MultiOutputRegressor
from sklearn.preprocessing import StandardScaler
from sklearn.pipeline import Pipeline
from sklearn.metrics import mean_absolute_percentage_error

from scipy.optimize import differential_evolution

Here, SVR is the prediction model. Since we want to predict more than one yarn property, we use MultiOutputRegressor. This allows the SVR model to predict yarn strength, elongation, unevenness and hairiness together.

Step 2: Creating Assumed Cotton Fibre Data

Now we create a synthetic dataset. Each row represents one cotton fibre sample or cotton lot. The values are generated within reasonable practical ranges, so that the demonstration remains close to spinning logic.

np.random.seed(42)

n_samples = 80

data = pd.DataFrame({
    "FS": np.random.uniform(25, 36, n_samples),       # Fibre strength, cN/tex
    "FE": np.random.uniform(5.0, 8.5, n_samples),     # Fibre elongation, %
    "UHML": np.random.uniform(0.85, 1.25, n_samples), # Upper half mean length, inch
    "UI": np.random.uniform(76, 88, n_samples),       # Uniformity index
    "FF": np.random.uniform(3.2, 5.2, n_samples),     # Fibre fineness, µg/in
    "SFC": np.random.uniform(4, 15, n_samples)        # Short fibre content, %
})

The six variables are:

\[ FS,\ FE,\ UHML,\ UI,\ FF,\ SFC \]

These represent the raw material side of the problem. In real mill practice, such values may come from HVI testing or other fibre testing systems.

Step 3: Creating Assumed Yarn Quality Relationships

Next, we create synthetic yarn quality values. These are not random numbers alone. They are based on textile logic. For example, yarn strength is assumed to improve with fibre strength, fibre length and uniformity, but reduce with short fibre content.

Similarly, unevenness and hairiness are assumed to increase when short fibre content is high. In actual mill data, these relationships may be more complex, but this simplified structure is useful for understanding the modelling workflow.

noise = np.random.normal(0, 0.3, n_samples)

data["Yarn_Strength"] = (
    0.35 * data["FS"]
    + 2.2 * data["UHML"]
    + 0.06 * data["UI"]
    - 0.18 * data["SFC"]
    + noise
)

data["Yarn_Elongation"] = (
    0.45 * data["FE"]
    + 0.03 * data["UI"]
    - 0.04 * data["SFC"]
    + np.random.normal(0, 0.15, n_samples)
)

data["Unevenness_U"] = (
    18
    - 0.08 * data["UI"]
    + 0.28 * data["SFC"]
    + 0.35 * data["FF"]
    - 0.9 * data["UHML"]
    + np.random.normal(0, 0.25, n_samples)
)

data["Hairiness"] = (
    3.5
    + 0.18 * data["SFC"]
    + 0.35 * data["FF"]
    - 0.7 * data["UHML"]
    + np.random.normal(0, 0.15, n_samples)
)

This step is important because a machine learning model needs input-output examples. In a real mill, these output values would come from yarn testing instruments, such as strength testers, evenness testers and hairiness measuring systems.

\[ \text{Fibre Properties} \rightarrow \text{Yarn Properties} \]

Step 4: Defining Inputs and Outputs

Now we separate the input variables and output variables. The variable X contains cotton fibre properties, while the variable y contains yarn quality properties.

X = data[["FS", "FE", "UHML", "UI", "FF", "SFC"]]

y = data[[
    "Yarn_Strength",
    "Yarn_Elongation",
    "Unevenness_U",
    "Hairiness"
]]

This is the basic supervised learning structure. In textile language, we are asking the model to learn how cotton fibre data is connected with yarn quality.

\[ X \rightarrow y \]
\[ \text{Cotton Fibre Data} \rightarrow \text{Yarn Quality} \]

Step 5: Splitting the Data

The data is divided into training and testing sets. The model learns from the training data and is evaluated on the testing data. This helps us understand whether the model can make reasonable predictions on new data.

X_train, X_test, y_train, y_test = train_test_split(
    X, y,
    test_size=0.2,
    random_state=42
)

We use 80% of the data for training and 20% for testing. This is a common approach in machine learning. The purpose of testing is to check whether the model can make reasonable predictions on data it has not seen during training.

Step 6: Training the SVR Model

Support Vector Regression is used as the prediction engine. Since fibre-to-yarn relationships may be non-linear, we use an RBF kernel. The model is placed inside a pipeline along with a scaler.

svr_model = Pipeline([
    ("scaler", StandardScaler()),
    ("svr", MultiOutputRegressor(
        SVR(kernel="rbf", C=100, gamma="scale", epsilon=0.1)
    ))
])

svr_model.fit(X_train, y_train)

The StandardScaler is used because SVR is sensitive to scale. Fibre strength, fibre elongation, UHML, uniformity index and short fibre content are measured on different scales. Scaling helps the model treat the variables more fairly.

\[ FS, FE, UHML, UI, FF, SFC \rightarrow \text{Strength, Elongation, Unevenness, Hairiness} \]

In practical words, once the model is trained, we can give it a new cotton fibre profile and ask: what yarn quality is likely to result from this cotton?

Step 7: Checking Prediction Error

After training the model, we evaluate its prediction error on test data. This step is important because optimisation is only useful when the prediction model itself is reasonably reliable.

y_pred = svr_model.predict(X_test)

mape = mean_absolute_percentage_error(
    y_test,
    y_pred,
    multioutput="raw_values"
)

performance = pd.DataFrame({
    "Yarn Property": y.columns,
    "MAPE": mape
})

print(performance)

MAPE means Mean Absolute Percentage Error. Lower MAPE indicates better prediction accuracy. The exact values will change because the data is synthetic, but the purpose here is to show how prediction performance can be evaluated.

Yarn Property Expected Interpretation
Yarn strength Lower error means the model is predicting strength more reliably.
Yarn elongation Lower error means the model is capturing stretch behaviour better.
Unevenness U% Moderate error may occur because unevenness depends on many process factors.
Hairiness Error depends on how well fibre fineness, length and short fibre content explain hairiness.

Step 8: Creating Desirability Functions

Prediction alone is not enough. We also need to decide what is desirable. For yarn strength and elongation, higher values are better. For unevenness and hairiness, lower values are better. So we create two types of desirability functions.

def desirability_higher(value, low, high):
    """
    Higher value is better.
    Returns desirability between 0 and 1.
    """
    if value <= low:
        return 0
    elif value >= high:
        return 1
    else:
        return (value - low) / (high - low)


def desirability_lower(value, low, high):
    """
    Lower value is better.
    Returns desirability between 0 and 1.
    """
    if value <= low:
        return 1
    elif value >= high:
        return 0
    else:
        return (high - value) / (high - low)

The meaning is simple. A desirability value of 0 means undesirable, while a desirability value of 1 means ideal. For example, if yarn strength is too low, its desirability becomes 0. If it reaches the desired upper level, its desirability becomes 1.

\[ 0 = \text{Undesirable}, \qquad 1 = \text{Ideal} \]

For unevenness and hairiness, the logic is reversed. Lower values are better, so the desirability is highest when these values are low.

Step 9: Combining Multiple Desirability Scores

Now we combine the four yarn quality scores into one overall desirability value. This allows us to judge yarn quality as a balanced combination of several responses, rather than as one isolated property.

def overall_desirability(predicted_values):
    """
    predicted_values order:
    [Yarn_Strength, Yarn_Elongation, Unevenness_U, Hairiness]
    """

    strength, elongation, unevenness, hairiness = predicted_values

    d_strength = desirability_higher(
        strength,
        low=14.0,
        high=17.0
    )

    d_elongation = desirability_higher(
        elongation,
        low=4.5,
        high=6.5
    )

    d_unevenness = desirability_lower(
        unevenness,
        low=10.5,
        high=13.5
    )

    d_hairiness = desirability_lower(
        hairiness,
        low=4.0,
        high=6.5
    )

    desirabilities = np.array([
        d_strength,
        d_elongation,
        d_unevenness,
        d_hairiness
    ])

    if np.any(desirabilities == 0):
        return 0

    return np.prod(desirabilities) ** (1 / len(desirabilities))

The model uses the geometric mean of the individual desirability values. This is useful because it prevents one very good property from hiding a very poor property. If any one desirability becomes zero, the overall desirability becomes zero.

\[ D = (d_1 \times d_2 \times d_3 \times d_4)^{1/4} \]

This reflects real spinning logic. A yarn cannot be considered excellent if it has very good strength but extremely poor evenness or hairiness.

Step 10: Defining the Optimisation Objective

The Genetic Algorithm needs an objective function. Since the algorithm used here minimises the objective, we return negative desirability. Minimising negative desirability is the same as maximising desirability.

def objective_function(fibre_params):
    """
    GA minimizes the objective.
    Since we want maximum desirability,
    we minimize negative desirability.
    """

    fibre_params = np.array(fibre_params).reshape(1, -1)

    predicted_yarn_quality = svr_model.predict(fibre_params)[0]

    desirability_score = overall_desirability(predicted_yarn_quality)

    return -desirability_score

The objective function follows a simple logic. First, it receives a possible set of cotton fibre parameters. Then it predicts yarn quality using the SVR model. Finally, it converts that predicted yarn quality into a desirability score.

\[ \text{Fibre Parameters} \rightarrow \text{Predicted Yarn Quality} \rightarrow \text{Desirability Score} \]

Step 11: Setting Practical Bounds

The optimisation must stay within practical cotton fibre limits. We define lower and upper bounds for each fibre property. This prevents the algorithm from suggesting unrealistic values.

bounds = [
    (25, 36),      # FS: Fibre strength
    (5.0, 8.5),   # FE: Fibre elongation
    (0.85, 1.25), # UHML
    (76, 88),     # UI
    (3.2, 5.2),   # FF
    (4, 15)       # SFC
]

For example, the algorithm should not suggest an impossible fibre strength or an impractical short fibre content. In mill practice, these bounds should be based on actual cotton availability and the type of yarn being produced.

Step 12: Running the Genetic Algorithm

Now we run the optimisation. Here, differential_evolution works like a Genetic Algorithm. It starts with several possible fibre combinations, evaluates them, keeps better solutions, modifies them and continues searching.

result = differential_evolution(
    objective_function,
    bounds=bounds,
    strategy="best1bin",
    maxiter=100,
    popsize=20,
    mutation=(0.5, 1),
    recombination=0.7,
    seed=42
)

The idea is to try a fibre combination, predict the yarn quality, score the desirability, and then improve the combination. After several generations, the algorithm finds a fibre-property combination that gives high overall desirability.

\[ \text{Try Fibre Combination} \rightarrow \text{Predict Yarn Quality} \rightarrow \text{Score Desirability} \rightarrow \text{Improve Combination} \]

Step 13: Getting the Best Fibre Parameters

Once the optimisation is complete, we extract the best fibre values and the predicted yarn quality. These values represent the best fibre-property combination found within the defined practical limits.

best_fibre_params = result.x
best_desirability = -result.fun

best_prediction = svr_model.predict(
    np.array(best_fibre_params).reshape(1, -1)
)[0]

We can then display the optimum fibre parameters in a simple table. In actual mill application, this table can help compare available cotton lots with the fibre profile suggested by the model.

optimum_fibre = pd.DataFrame({
    "Fibre Parameter": ["FS", "FE", "UHML", "UI", "FF", "SFC"],
    "Optimised Value": best_fibre_params
})

print(optimum_fibre)
Fibre Parameter Model Meaning
FS Optimum fibre strength suggested by the model.
FE Optimum fibre elongation suggested by the model.
UHML Optimum upper half mean length suggested by the model.
UI Optimum uniformity index suggested by the model.
FF Optimum fibre fineness suggested by the model.
SFC Optimum short fibre content suggested by the model.

Step 14: Predicting Yarn Quality at the Optimum Point

Finally, we display the yarn quality predicted for the optimum fibre profile. This is the most practically useful output because it shows the expected yarn result.

optimum_yarn = pd.DataFrame({
    "Yarn Property": [
        "Yarn Strength",
        "Yarn Elongation",
        "Unevenness U%",
        "Hairiness Index"
    ],
    "Predicted Value": best_prediction
})

print(optimum_yarn)

print(f"Overall desirability score: {best_desirability:.4f}")

The output tells us what yarn quality the model expects from the optimum cotton fibre profile. This is the real value of the model. It does not only say that a cotton is good. It says that a particular cotton fibre profile is expected to give a certain level of yarn strength, elongation, unevenness and hairiness.

Complete Python Code

The complete code is given below. It can be copied into Jupyter Notebook, Google Colab, or any Python environment where the required libraries are installed.

# ------------------------------------------------------------
# Cotton Yarn Quality Optimisation Model
# SVR + Genetic Algorithm + Desirability Function
# ------------------------------------------------------------

import numpy as np
import pandas as pd

from sklearn.model_selection import train_test_split
from sklearn.svm import SVR
from sklearn.multioutput import MultiOutputRegressor
from sklearn.preprocessing import StandardScaler
from sklearn.pipeline import Pipeline
from sklearn.metrics import mean_absolute_percentage_error

from scipy.optimize import differential_evolution


# ------------------------------------------------------------
# 1. Assume suitable spinning data
# ------------------------------------------------------------

np.random.seed(42)

n_samples = 80

data = pd.DataFrame({
    "FS": np.random.uniform(25, 36, n_samples),       # Fibre strength, cN/tex
    "FE": np.random.uniform(5.0, 8.5, n_samples),     # Fibre elongation, %
    "UHML": np.random.uniform(0.85, 1.25, n_samples), # Upper half mean length, inch
    "UI": np.random.uniform(76, 88, n_samples),       # Uniformity index
    "FF": np.random.uniform(3.2, 5.2, n_samples),     # Fibre fineness, µg/in
    "SFC": np.random.uniform(4, 15, n_samples)        # Short fibre content, %
})

# ------------------------------------------------------------
# 2. Create assumed yarn-quality relationships
# ------------------------------------------------------------

noise = np.random.normal(0, 0.3, n_samples)

data["Yarn_Strength"] = (
    0.35 * data["FS"]
    + 2.2 * data["UHML"]
    + 0.06 * data["UI"]
    - 0.18 * data["SFC"]
    + noise
)

data["Yarn_Elongation"] = (
    0.45 * data["FE"]
    + 0.03 * data["UI"]
    - 0.04 * data["SFC"]
    + np.random.normal(0, 0.15, n_samples)
)

data["Unevenness_U"] = (
    18
    - 0.08 * data["UI"]
    + 0.28 * data["SFC"]
    + 0.35 * data["FF"]
    - 0.9 * data["UHML"]
    + np.random.normal(0, 0.25, n_samples)
)

data["Hairiness"] = (
    3.5
    + 0.18 * data["SFC"]
    + 0.35 * data["FF"]
    - 0.7 * data["UHML"]
    + np.random.normal(0, 0.15, n_samples)
)

# ------------------------------------------------------------
# 3. Define input and output variables
# ------------------------------------------------------------

X = data[["FS", "FE", "UHML", "UI", "FF", "SFC"]]

y = data[[
    "Yarn_Strength",
    "Yarn_Elongation",
    "Unevenness_U",
    "Hairiness"
]]

# ------------------------------------------------------------
# 4. Train-test split
# ------------------------------------------------------------

X_train, X_test, y_train, y_test = train_test_split(
    X, y,
    test_size=0.2,
    random_state=42
)

# ------------------------------------------------------------
# 5. Build SVR model
# ------------------------------------------------------------

svr_model = Pipeline([
    ("scaler", StandardScaler()),
    ("svr", MultiOutputRegressor(
        SVR(kernel="rbf", C=100, gamma="scale", epsilon=0.1)
    ))
])

svr_model.fit(X_train, y_train)

# ------------------------------------------------------------
# 6. Evaluate prediction performance
# ------------------------------------------------------------

y_pred = svr_model.predict(X_test)

mape = mean_absolute_percentage_error(
    y_test,
    y_pred,
    multioutput="raw_values"
)

performance = pd.DataFrame({
    "Yarn Property": y.columns,
    "MAPE": mape
})

print("\nPrediction error:")
print(performance)

# ------------------------------------------------------------
# 7. Desirability functions
# ------------------------------------------------------------

def desirability_higher(value, low, high):
    """
    Higher value is better.
    Returns desirability between 0 and 1.
    """
    if value <= low:
        return 0
    elif value >= high:
        return 1
    else:
        return (value - low) / (high - low)


def desirability_lower(value, low, high):
    """
    Lower value is better.
    Returns desirability between 0 and 1.
    """
    if value <= low:
        return 1
    elif value >= high:
        return 0
    else:
        return (high - value) / (high - low)


def overall_desirability(predicted_values):
    """
    predicted_values order:
    [Yarn_Strength, Yarn_Elongation, Unevenness_U, Hairiness]
    """

    strength, elongation, unevenness, hairiness = predicted_values

    d_strength = desirability_higher(
        strength,
        low=14.0,
        high=17.0
    )

    d_elongation = desirability_higher(
        elongation,
        low=4.5,
        high=6.5
    )

    d_unevenness = desirability_lower(
        unevenness,
        low=10.5,
        high=13.5
    )

    d_hairiness = desirability_lower(
        hairiness,
        low=4.0,
        high=6.5
    )

    desirabilities = np.array([
        d_strength,
        d_elongation,
        d_unevenness,
        d_hairiness
    ])

    if np.any(desirabilities == 0):
        return 0

    return np.prod(desirabilities) ** (1 / len(desirabilities))

# ------------------------------------------------------------
# 8. Objective function for optimisation
# ------------------------------------------------------------

def objective_function(fibre_params):
    """
    Optimiser minimizes the objective.
    Since we want maximum desirability,
    we minimize negative desirability.
    """

    fibre_params = np.array(fibre_params).reshape(1, -1)

    predicted_yarn_quality = svr_model.predict(fibre_params)[0]

    desirability_score = overall_desirability(predicted_yarn_quality)

    return -desirability_score

# ------------------------------------------------------------
# 9. Define practical bounds for cotton fibre properties
# ------------------------------------------------------------

bounds = [
    (25, 36),      # FS: Fibre strength
    (5.0, 8.5),   # FE: Fibre elongation
    (0.85, 1.25), # UHML
    (76, 88),     # UI
    (3.2, 5.2),   # FF
    (4, 15)       # SFC
]

# ------------------------------------------------------------
# 10. Run Genetic Algorithm style optimisation
# ------------------------------------------------------------

result = differential_evolution(
    objective_function,
    bounds=bounds,
    strategy="best1bin",
    maxiter=100,
    popsize=20,
    mutation=(0.5, 1),
    recombination=0.7,
    seed=42
)

best_fibre_params = result.x
best_desirability = -result.fun

best_prediction = svr_model.predict(
    np.array(best_fibre_params).reshape(1, -1)
)[0]

# ------------------------------------------------------------
# 11. Display optimum fibre parameters
# ------------------------------------------------------------

optimum_fibre = pd.DataFrame({
    "Fibre Parameter": ["FS", "FE", "UHML", "UI", "FF", "SFC"],
    "Optimised Value": best_fibre_params
})

print("\nOptimised cotton fibre parameters:")
print(optimum_fibre)

# ------------------------------------------------------------
# 12. Display predicted yarn quality at optimum fibre values
# ------------------------------------------------------------

optimum_yarn = pd.DataFrame({
    "Yarn Property": [
        "Yarn Strength",
        "Yarn Elongation",
        "Unevenness U%",
        "Hairiness Index"
    ],
    "Predicted Value": best_prediction
})

print("\nPredicted yarn quality at optimum fibre parameters:")
print(optimum_yarn)

print(f"\nOverall desirability score: {best_desirability:.4f}")

How to Interpret the Model Output

The first output is the prediction error. This tells us how well the SVR model predicts yarn properties from fibre properties. In a real project, this step is extremely important because a poor prediction model will lead to poor optimisation.

The second output is the optimum fibre parameter table. This tells us what fibre profile the algorithm selected as the best combination within the given limits. The third output is the predicted yarn quality at that optimum fibre profile, which is the most practically useful output.

Finally, the desirability score tells us how close the solution is to the ideal balanced yarn quality. A score close to 1 means the solution is highly desirable. A score close to 0 means the solution is poor.

Why This Model Is Useful for Textile Mills

This type of model can support raw material decisions in spinning mills. A mill may have several cotton lots available, each with different fibre properties. Instead of relying only on experience, the mill can use data to estimate the likely yarn quality from different fibre profiles.

The model can help answer practical questions. Which cotton fibre profile gives better yarn strength without increasing hairiness? How much short fibre content can be tolerated for a target yarn quality? What balance of fibre strength, length and uniformity gives the best overall yarn performance? Which raw material parameters should be prioritised for a particular yarn count?

This is useful because the cost of raw material is one of the most important cost components in spinning. If a mill can select cotton more scientifically, it can improve quality, reduce trial-and-error and possibly avoid overpaying for fibre properties that are not essential for a particular yarn.

Important Limitations

This model uses assumed data. Therefore, the numerical results should not be used directly for production decisions. The relationships created in the code are textile-logical, but they are not based on actual mill trials.

In a real spinning mill, the model should be trained using actual fibre and yarn test data. The data should include cotton fibre properties, yarn count, spinning system, machine settings, humidity conditions and final yarn test results.

The model shown here is also specific to the selected variables. In actual production, other factors such as trash content, micronaire, maturity, neps, carding quality, draft settings, spindle speed and twist multiplier may also influence yarn quality.

Therefore, this model should be treated as a framework, not as a finished industrial solution.

Final Conclusion

This Python demonstration shows how raw material selection in spinning can be converted into a data-driven optimisation problem. The SVR model predicts yarn quality from cotton fibre properties. The Genetic Algorithm searches for the best fibre-property combination. The desirability function balances several yarn quality requirements into one score.

The most important idea is that yarn quality should not be optimised through one parameter alone. A good yarn must be strong, extensible, even and less hairy. Therefore, the best cotton is not always the strongest or longest cotton. It is the cotton with the right balance of properties for the required yarn.

In that sense, this model gives a practical bridge between textile science and data science:

\[ \text{Spinning Knowledge} + \text{Machine Learning} + \text{Optimisation} = \text{Better Raw Material Decisions} \]

For students, this model is a good way to understand how artificial intelligence can be applied in spinning. For mills, the same logic can become a decision-support tool when trained with real production data.

General Disclaimer

This article is for educational and general textile knowledge purposes only. The Python model uses assumed data and simplified textile relationships for demonstration. Actual yarn quality depends on cotton variety, bale mixing, fibre testing accuracy, blow room settings, carding efficiency, draw frame performance, roving quality, ring frame settings, twist, humidity, machine condition and testing methods. Mills should use their own validated production data before applying such models for commercial raw material selection.

Buy my books at Amazon.com
How to cite this article:
Goyal, P. Part 2: Building a Python Model for Cotton Yarn Quality Optimisation Using SVR, Genetic Algorithm and Desirability Function. My Textile Notes. Available at: http://mytextilenotes.blogspot.com/2026/05/part-2-building-python-model-for-cotton.html
Have a textile question?

If you have a question related to this topic, you are welcome to ask it in the My Textile Notes Discussion Forum.

Students, merchandisers, designers, researchers and textile professionals are welcome to participate.

No comments:

Post a Comment

Total Pageviews