<jupyter_start><jupyter_text>Conversion a Dolar<jupyter_code>df.loc[df['Total_Amount_Currency'] == 'JPY', 'Total_Amount'] = df['Total_Amount']*0.0096
df.loc[df['Total_Amount_Currency'] == 'JPY', 'Total_Amount_Currency'] = 'USD'

df.loc[df['Total_Amount_Currency'] == 'EUR', 'Total_Amount'] = df['Total_Amount']*1.17
df.loc[df['Total_Amount_Currency'] == 'EUR', 'Total_Amount_Currency'] = 'USD'

df.loc[df['Total_Amount_Currency'] == 'AUD', 'Total_Amount'] = df['Total_Amount']*0.70
df.loc[df['Total_Amount_Currency'] == 'AUD', 'Total_Amount_Currency'] = 'USD'

df.loc[df['Total_Amount_Currency'] == 'GBP', 'Total_Amount'] = df['Total_Amount']*1.29
df.loc[df['Total_Amount_Currency'] == 'GBP', 'Total_Amount_Currency'] = 'USData'
short_df = df[['Region', 'Total_Amount', 'Delivery_Year', 'Delivery_Quarter','Stage' ]].rename(columns={'Stage': 'Decision'})
short_df = short_df[ (short_df['Decision'] == 'Closed Won') | (short_df['Decision'] == 'Closed Lost') ]<jupyter_output><empty_output><jupyter_text>Probanding<jupyter_code>from sklearn.model_selection import train_test_split
from sklearn.metrics import classification_report, confusion_matrix
from sklearn.ensemble import RandomForestClassifier
from sklearn import preprocessing
X = short_df.drop( 'Decision', axis=1 )
y = short_df['Decision']
X = X.drop(columns='Total_Amount')
X
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)
from sklearn.preprocessing import LabelEncoder
from sklearn.preprocessing import OneHotEncoder
X_train
ohe = OneHotEncoder()
ohe.fit(X_train)
X_train_enc = ohe.transform(X_train)
X_test_enc = ohe.transform(X_test)
rfc = RandomForestClassifier(n_estimators=1000)
#n_estimators se refiere a la cantidad de arboles de decisiones que usa el rfc
rfc.fit(X_train_enc, y_train)
rfc_pred = rfc.predict(X_test_enc)
print(classification_report(y_test, rfc_pred))
print(confusion_matrix(y_test, rfc_pred))<jupyter_output>precision    recall  f1-score   support

 Closed Lost       0.59      0.49      0.54      2236
  Closed Won       0.65      0.73      0.69      2829

    accuracy                           0.63      5065
   macro avg       0.62      0.61      0.61      5065
weighted avg       0.62      0.63      0.62      5065

[[1097 1139]
 [ 756 2073]]
{'fraction_non_alphanumeric': 0.13940193491644678, 'fraction_numerical': 0.04309586631486367, 'mean_word_length': 5.198910081743869, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '446441', 'license': 'MIT', 'n_tokens_mistral': 886, 'n_tokens_neox': 845, 'n_words': 157, 'path': 'ArbolDeDecision/RandomForest/.ipynb_checkpoints/RandomForest-checkpoint.ipynb', 'repo_name': 'BautistaXifro/Machine-Learning-Datos', 'size': '2274'}