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

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

Thanks for writing this, I enjoyed it

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

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

I just added 

y=y.astype('int')

below 

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

y = loan_dataset.values[:,12]

it worked fine.

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.

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

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

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

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'