<jupyter_start><jupyter_text>CatBoost Algorithm  CatBoost is a gradient boosting framework which attempts to solve for Categorical features using a permutation driven alternative compared to the classical algorithm.  Advantages 1. Little preprcessing required.2. Faster in comparision with other algorithm (reason being use symmetric trees).3. Faster GPU implementation. Installation of CatBoost<jupyter_code>!pip install catboost  #using pip to install catboost<jupyter_output>Requirement already satisfied: catboost in /usr/local/lib/python3.7/dist-packages (0.26.1)
Requirement already satisfied: matplotlib in /usr/local/lib/python3.7/dist-packages (from catboost) (3.2.2)
Requirement already satisfied: pandas>=0.24.0 in /usr/local/lib/python3.7/dist-packages (from catboost) (1.1.5)
Requirement already satisfied: plotly in /usr/local/lib/python3.7/dist-packages (from catboost) (4.4.1)
Requirement already satisfied: six in /usr/local/lib/python3.7/dist-packages (from catboost) (1.15.0)
Requirement already satisfied: graphviz in /usr/local/lib/python3.7/dist-packages (from catboost) (0.10.1)
Requirement already satisfied: scipy in /usr/local/lib/python3.7/dist-packages (from catboost) (1.4.1)
Requirement already satisfied: numpy>=1.16.0 in /usr/local/lib/python3.7/dist-packages (from catboost) (1.19.5)
Requirement already satisfied: python-dateutil>=2.7.3 in /usr/local/lib/python3.7/dist-packages (from pandas>=0.24.0->catboost) (2.8.2)
Requirement already satis[...]<jupyter_text>Importing the necessary Libraries<jupyter_code>import pandas as pd   #For data manipulation and analysis
from catboost import CatBoostClassifier 
from sklearn.model_selection import train_test_split # For spliting into test and train set
from sklearn.metrics import accuracy_score, f1_score  # For checking of the accuracy of model<jupyter_output><empty_output><jupyter_text>Loading Data<jupyter_code>data=pd.read_csv("data.csv")   
data.head()<jupyter_output><empty_output><jupyter_text>Seprating the X and Y from the data<jupyter_code>X=data.loc[:,data.columns!="Loan_Status"]
Y=data.loc[:,data.columns=="Loan_Status"]
X<jupyter_output><empty_output><jupyter_text>Test and train spilt<jupyter_code>X_train, X_test, y_train, y_test = train_test_split(X, Y,test_size=0.2,random_state=0)
X_train.head()
y_train.head()<jupyter_output><empty_output><jupyter_text>Creating a CatBoostClassifier<jupyter_code>model = CatBoostClassifier(task_type='GPU', iterations=150, 
                              random_state = 2000, 
                              eval_metric="F1")<jupyter_output><empty_output><jupyter_text>Model Fitting<jupyter_code>model.fit(X_train, y_train, cat_features= ["Credit_History"], plot=True,eval_set=(X_test, y_test))<jupyter_output><empty_output><jupyter_text>Predicting the values for X_test<jupyter_code>y_pred=model.predict(X_test)<jupyter_output><empty_output><jupyter_text>Finding the accuracy of model  using f1_score and accuracy_score<jupyter_code>f1_score(y_test, y_pred)

accuracy_score(y_test,y_pred)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10740013097576949, 'fraction_numerical': 0.026522593320235755, 'mean_word_length': 6.36144578313253, 'pattern_counts': {'":': 0, '<': 36, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '502988', 'license': 'MIT', 'n_tokens_mistral': 1067, 'n_tokens_neox': 1037, 'n_words': 221, 'path': 'Datascience_With_Python/Machine Learning/Algorithms/CatBoost/CatBoost_Algorithm.ipynb', 'repo_name': 'vishnupriya129/winter-of-contributing', 'size': '3054'}