Home » ML
      Bookmark ·  Report ·  More actions.. Lock comments ·  Pin thread

Machine learning project in python to predict loan approval (Part 6 of 6)

404

nVector

posted on 06 Sep 18

Enjoy great content like this and a lot more !

Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds




victor
victor12-Sep-18

Thanks for writing this, I enjoyed it

In the following code ------------------------------------------------------------------------------------------------------------ CODE ------------------------------------------------------------------------------------------------------------ model = LogisticRegression() model.fit(x_train,y_train) predictions = model.predict(x_test) print(accuracy_score(y_test, predictions)) ------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------ ERROR ------------------------------------------------------------------------------------------------------------ ValueError Traceback (most recent call last) in () 1 model = LogisticRegression() ----> 2 model.fit(x_train,y_train) 3 predictions = model.predict(x_test) 4 print(accuracy_score(y_test, predictions)) ~AppDataLocalContinuumanaconda3libsite-packagessklearnlinear_modellogistic.py in fit(self, X, y, sample_weight) 1215 X, y = check_X_y(X, y, accept_sparse='csr', dtype=_dtype, 1216 order="C") -> 1217 check_classification_targets(y) 1218 self.classes_ = np.unique(y) 1219 n_samples, n_features = X.shape ~AppDataLocalContinuumanaconda3libsite-packagessklearnutilsmulticlass.py in check_classification_targets(y) 170 if y_type not in ['binary', 'multiclass', 'multiclass-multioutput', 171 'multilabel-indicator', 'multilabel-sequences']: --> 172 raise ValueError("Unknown label type: %r" % y_type) 173 174 ValueError: Unknown label type: 'unknown' ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

anish21-Apr-19

For the above comment, the type of the values is Long, and I guess that's why it's not accepting it. Just convert it to int by: X = X.astype('int') Y = Y.astype('int') and then seperate into test and train data Worked for me, hope it helps

Jyotir21-Dec-19

I just added 

y=y.astype('int')

below 

X = loan_dataset.values[:, 6:11]

y = loan_dataset.values[:,12]

it worked fine.

Jyotir21-Dec-19

Thanks so much for sharing these three projects! I enjoyed working on them and learnt the basics.

I was looking for the hyperlinks for the texts in Next steps. Are those tasks for us?

Thanks.

nVector21-Dec-19

Glad it was useful. Yes, The next steps are action items

Jyotir22-Dec-19

Thanks again!

asish-cse19-Jul-20

Without approval status, how can I label data? Any suggestions or tutorial?

nVector20-Jul-20

I do not understand the training data needs labels so that the model can understand and train on it. We cannot have training data without labels

Sai-Aishwarya17-Mar-21

I'm getting an error while training the data

ValueError Traceback (most recent call last)

<ipython-input-16-5fd6998833ff> in <module>

1 model = LogisticRegression()

----> 2 model.fit(x_train,y_train)

3 predictions = model.predict(x_test)

4 print(accuracy_score(y_test, predictions))

~anaconda3libsite-packagessklearnlinear_model\_logistic.py in fit(self, X, y, sample_weight)

1343 order="C",

1344 accept_large_sparse=solver != 'liblinear')

-> 1345 check_classification_targets(y)

1346 self.classes_ = np.unique(y)

1347

~anaconda3libsite-packagessklearnutilsmulticlass.py in check_classification_targets(y)

170 if y_type not in ['binary', 'multiclass', 'multiclass-multioutput',

171 'multilabel-indicator', 'multilabel-sequences']:

--> 172 raise ValueError("Unknown label type: %r" % y_type)

173

174

ValueError: Unknown label type: 'unknown'