[Python] Machine learning not predicting correct results

Discussão em 'Python' iniciado por Stack, Setembro 15, 2024.

  1. Stack

    Stack Membro Participativo

    I am working on creating a simple Python machine learning script which will predict if loan will be approved or not based on below parameters

    business experience: should be greater than 7
    year of founded: should be after 2015
    loan: no previous or current loan


    If above conditions matches, then only loan will be approved. This dataset can be downloaded from this link:

    https://drive.google.com/file/d/1QtJ3EED7KDqJDrSHxHB6g9kc5YAfTlmF/view?usp=sharing

    For above data, I have below script

    from sklearn.linear_model import LogisticRegression
    import pandas as pd
    import numpy as np

    data = pd.read_csv("test2.csv")
    data.head()

    X = data[["Business Exp", "Year of Founded", "Previous/Current Loan"]]
    Y = data["OUTPUT"]

    clf = LogisticRegression()
    clf.fit(X, Y)

    test_x2 = np.array([[9, 2017, 0]])
    Y_pred = clf.predict(test_x2)
    print(Y_pred)


    I am passing the test data in test_x2. Test data is if business exp is 9, year of founded is 2017 and no current/previous loan, so that means loan will be provided. So it should predict and the result should be 1 but it shows 0. Is there any issue with the code or with the dataset. As I am beginner in machine learning and still learning it so I have created this custom dataset for my own understanding.

    Continue reading...

Compartilhe esta Página