Skip to content

Commit

Permalink
class try 2
Browse files Browse the repository at this point in the history
  • Loading branch information
michelleg06 committed Jan 13, 2024
1 parent ea33562 commit f8f1ebc
Show file tree
Hide file tree
Showing 7 changed files with 201 additions and 370 deletions.
2 changes: 1 addition & 1 deletion classification.Rmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
#title: "Classification with Logistic Regression"
title: "Classification with Logistic Regression"
#author: "Dr. Stephan Dietrich & Michelle González Amador"
#date: '2022-09-21'
output: html_document
Expand Down
547 changes: 189 additions & 358 deletions classification.html

Large diffs are not rendered by default.

Binary file modified classification_files/figure-html/unnamed-chunk-21-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion intro.html
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,7 @@ <h3><strong>An introduction to Python programming</strong></h3>
## Model: OLS Adj. R-squared: 0.507
## Method: Least Squares F-statistic: 46.27
## Date: Sat, 13 Jan 2024 Prob (F-statistic): 3.83e-62
## Time: 11:00:15 Log-Likelihood: -2386.0
## Time: 11:19:33 Log-Likelihood: -2386.0
## No. Observations: 442 AIC: 4794.
## Df Residuals: 431 BIC: 4839.
## Df Model: 10
Expand Down
4 changes: 2 additions & 2 deletions predictionpolicy.html
Original file line number Diff line number Diff line change
Expand Up @@ -4897,7 +4897,7 @@ <h3>
## Model: OLS Adj. R-squared: 0.598
## Method: Least Squares F-statistic: 498.3
## Date: Sat, 13 Jan 2024 Prob (F-statistic): 0.00
## Time: 11:00:30 Log-Likelihood: -5189.2
## Time: 11:19:48 Log-Likelihood: -5189.2
## No. Observations: 9024 AIC: 1.043e+04
## Df Residuals: 8996 BIC: 1.063e+04
## Df Model: 27
Expand Down Expand Up @@ -4956,7 +4956,7 @@ <h3>
## Model: OLS Adj. R-squared: 0.598
## Method: Least Squares F-statistic: 431.9
## Date: Sat, 13 Jan 2024 Prob (F-statistic): 0.00
## Time: 11:00:30 Log-Likelihood: -5189.2
## Time: 11:19:49 Log-Likelihood: -5189.2
## No. Observations: 9024 AIC: 1.043e+04
## Df Residuals: 8996 BIC: 1.063e+04
## Df Model: 27
Expand Down
16 changes: 8 additions & 8 deletions treebasedmodels.html
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,9 @@ <h3>
rf_train &lt;- train(poor ~ .,
data = Train_df,
method = &quot;ranger&quot; # estimates a Random Forest algorithm via the ranger pkg (you may need to install the ranger pkg)
)</code></pre>
<pre><code>## Growing trees.. Progress: 100%. Estimated remaining time: 0 seconds.</code></pre>
<pre class="r"><code># First glimpse at our random forest model
)

# First glimpse at our random forest model
print(rf_train)</code></pre>
<pre><code>## Random Forest
##
Expand Down Expand Up @@ -810,7 +810,7 @@ <h3>
<pre><code>## Confusion Matrix: [[ 529 279]
## [ 150 1298]]</code></pre>
<pre class="python"><code>ConfusionMatrixDisplay(confusion_matrix=cm).plot() # create confusion matrix plot</code></pre>
<pre><code>## &lt;sklearn.metrics._plot.confusion_matrix.ConfusionMatrixDisplay object at 0x2baced390&gt;</code></pre>
<pre><code>## &lt;sklearn.metrics._plot.confusion_matrix.ConfusionMatrixDisplay object at 0x2b7c58e80&gt;</code></pre>
<pre class="python"><code>plt.show() # display confusion matrix plot created above</code></pre>
<p><img src="treebasedmodels_files/figure-html/unnamed-chunk-13-1.png" width="672" />
Based on our out-of-sample predictions, the Random Forest algorithm
Expand Down Expand Up @@ -852,12 +852,12 @@ <h3>
random_search.fit(X_train, y_train)</code></pre>
<style>#sk-container-id-4 {color: black;background-color: white;}#sk-container-id-4 pre{padding: 0;}#sk-container-id-4 div.sk-toggleable {background-color: white;}#sk-container-id-4 label.sk-toggleable__label {cursor: pointer;display: block;width: 100%;margin-bottom: 0;padding: 0.3em;box-sizing: border-box;text-align: center;}#sk-container-id-4 label.sk-toggleable__label-arrow:before {content: "▸";float: left;margin-right: 0.25em;color: #696969;}#sk-container-id-4 label.sk-toggleable__label-arrow:hover:before {color: black;}#sk-container-id-4 div.sk-estimator:hover label.sk-toggleable__label-arrow:before {color: black;}#sk-container-id-4 div.sk-toggleable__content {max-height: 0;max-width: 0;overflow: hidden;text-align: left;background-color: #f0f8ff;}#sk-container-id-4 div.sk-toggleable__content pre {margin: 0.2em;color: black;border-radius: 0.25em;background-color: #f0f8ff;}#sk-container-id-4 input.sk-toggleable__control:checked~div.sk-toggleable__content {max-height: 200px;max-width: 100%;overflow: auto;}#sk-container-id-4 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {content: "▾";}#sk-container-id-4 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-4 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-4 input.sk-hidden--visually {border: 0;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;}#sk-container-id-4 div.sk-estimator {font-family: monospace;background-color: #f0f8ff;border: 1px dotted black;border-radius: 0.25em;box-sizing: border-box;margin-bottom: 0.5em;}#sk-container-id-4 div.sk-estimator:hover {background-color: #d4ebff;}#sk-container-id-4 div.sk-parallel-item::after {content: "";width: 100%;border-bottom: 1px solid gray;flex-grow: 1;}#sk-container-id-4 div.sk-label:hover label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-4 div.sk-serial::before {content: "";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: 0;}#sk-container-id-4 div.sk-serial {display: flex;flex-direction: column;align-items: center;background-color: white;padding-right: 0.2em;padding-left: 0.2em;position: relative;}#sk-container-id-4 div.sk-item {position: relative;z-index: 1;}#sk-container-id-4 div.sk-parallel {display: flex;align-items: stretch;justify-content: center;background-color: white;position: relative;}#sk-container-id-4 div.sk-item::before, #sk-container-id-4 div.sk-parallel-item::before {content: "";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: -1;}#sk-container-id-4 div.sk-parallel-item {display: flex;flex-direction: column;z-index: 1;position: relative;background-color: white;}#sk-container-id-4 div.sk-parallel-item:first-child::after {align-self: flex-end;width: 50%;}#sk-container-id-4 div.sk-parallel-item:last-child::after {align-self: flex-start;width: 50%;}#sk-container-id-4 div.sk-parallel-item:only-child::after {width: 0;}#sk-container-id-4 div.sk-dashed-wrapped {border: 1px dashed gray;margin: 0 0.4em 0.5em 0.4em;box-sizing: border-box;padding-bottom: 0.4em;background-color: white;}#sk-container-id-4 div.sk-label label {font-family: monospace;font-weight: bold;display: inline-block;line-height: 1.2em;}#sk-container-id-4 div.sk-label-container {text-align: center;}#sk-container-id-4 div.sk-container {/* jupyter's `normalize.less` sets `[hidden] { display: none; }` but bootstrap.min.css set `[hidden] { display: none !important; }` so we also need the `!important` here to be able to override the default hidden behavior on the sphinx rendered scikit-learn.org. See: https://github.com/scikit-learn/scikit-learn/issues/21755 */display: inline-block !important;position: relative;}#sk-container-id-4 div.sk-text-repr-fallback {display: none;}</style><div id="sk-container-id-4" class="sk-top-container"><div class="sk-text-repr-fallback"><pre>RandomizedSearchCV(cv=5, estimator=RandomForestClassifier(random_state=42),
n_iter=5,
param_distributions={&#x27;max_depth&#x27;: &lt;scipy.stats._distn_infrastructure.rv_discrete_frozen object at 0x2bad6f3a0&gt;,
&#x27;n_estimators&#x27;: &lt;scipy.stats._distn_infrastructure.rv_discrete_frozen object at 0x2bad6f730&gt;},
param_distributions={&#x27;max_depth&#x27;: &lt;scipy.stats._distn_infrastructure.rv_discrete_frozen object at 0x2b7cd7610&gt;,
&#x27;n_estimators&#x27;: &lt;scipy.stats._distn_infrastructure.rv_discrete_frozen object at 0x2b7cd7d60&gt;},
random_state=42)</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class="sk-container" hidden><div class="sk-item sk-dashed-wrapped"><div class="sk-label-container"><div class="sk-label sk-toggleable"><input class="sk-toggleable__control sk-hidden--visually" id="sk-estimator-id-4" type="checkbox" ><label for="sk-estimator-id-4" class="sk-toggleable__label sk-toggleable__label-arrow">RandomizedSearchCV</label><div class="sk-toggleable__content"><pre>RandomizedSearchCV(cv=5, estimator=RandomForestClassifier(random_state=42),
n_iter=5,
param_distributions={&#x27;max_depth&#x27;: &lt;scipy.stats._distn_infrastructure.rv_discrete_frozen object at 0x2bad6f3a0&gt;,
&#x27;n_estimators&#x27;: &lt;scipy.stats._distn_infrastructure.rv_discrete_frozen object at 0x2bad6f730&gt;},
param_distributions={&#x27;max_depth&#x27;: &lt;scipy.stats._distn_infrastructure.rv_discrete_frozen object at 0x2b7cd7610&gt;,
&#x27;n_estimators&#x27;: &lt;scipy.stats._distn_infrastructure.rv_discrete_frozen object at 0x2b7cd7d60&gt;},
random_state=42)</pre></div></div></div><div class="sk-parallel"><div class="sk-parallel-item"><div class="sk-item"><div class="sk-label-container"><div class="sk-label sk-toggleable"><input class="sk-toggleable__control sk-hidden--visually" id="sk-estimator-id-5" type="checkbox" ><label for="sk-estimator-id-5" class="sk-toggleable__label sk-toggleable__label-arrow">estimator: RandomForestClassifier</label><div class="sk-toggleable__content"><pre>RandomForestClassifier(random_state=42)</pre></div></div></div><div class="sk-serial"><div class="sk-item"><div class="sk-estimator sk-toggleable"><input class="sk-toggleable__control sk-hidden--visually" id="sk-estimator-id-6" type="checkbox" ><label for="sk-estimator-id-6" class="sk-toggleable__label sk-toggleable__label-arrow">RandomForestClassifier</label><div class="sk-toggleable__content"><pre>RandomForestClassifier(random_state=42)</pre></div></div></div></div></div></div></div></div></div></div>
<pre class="python"><code># create an object / variable that containes the best hyperparameters, according to our search:

Expand Down
Binary file modified treebasedmodels_files/figure-html/unnamed-chunk-8-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f8f1ebc

Please sign in to comment.