예제 #1
0
                            verbose=1)

# Train the model on training data
rf.fit(train.drop(["smiles", "logS", "Classification"], axis=1),
       train["Classification"])

# Use the forest's predict method on the test data
predictions = rf.predict(
    test.drop(["smiles", "logS", "Classification"], axis=1))
predictions_t = rf.predict(
    train.drop(["smiles", "logS", "Classification"], axis=1))

#Get r^2
from sklearn.metrics import accuracy_score
print('Train Sklearn accuracy:',
      round(accuracy_score(predictions_t, train["Classification"]), 2))
print('Pred Sklearn accuracy:',
      round(accuracy_score(predictions, test["Classification"]), 2))
from sklearn.metrics import classification_report

print("Train\n", classification_report(predictions_t, train["Classification"]))
print("Predict\n", classification_report(predictions, test["Classification"]))

try:
    from notifyending import notify_ending
    notify_ending("Finished fitting random forest")
except:
    print("Random forest")

#quit()
예제 #2
0
import pickle
with open('catboost_backup.pickle', 'wb') as f:
    pickle.dump(model, f)

predictrain = model.predict(cattrain)
predictest = model.predict(cattest)

data = {
    'Catboost': ['Train', 'Test', 'Validate'],
    'Precision': [ptrain, ptest, pvalid]
}
data = pd.DataFrame(data)
data.to_csv("Precision_Catboost.csv")

#LOad model
"""
from_file = CatBoostClassifier()
from_file.load_model("Catboost_Sol")


with open('catboost_backup.pickle', 'rb') as f:
    model = pickle.load(f)
"""

try:
    from notifyending import notify_ending
    notify_ending("Finished fitting random forest with catboost")
except:
    print("Random forest")