<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>OpenText Analytics Database 26.2.x – Logistic regression</title>
    <link>/en/data-analysis/ml-predictive-analytics/classification-algorithms/logistic-regression/</link>
    <description>Recent content in Logistic regression on OpenText Analytics Database 26.2.x</description>
    <generator>Hugo -- gohugo.io</generator>
    
	  <atom:link href="/en/data-analysis/ml-predictive-analytics/classification-algorithms/logistic-regression/index.xml" rel="self" type="application/rss+xml" />
    
    
      
        
      
    
    
    <item>
      <title>Data-Analysis: Building a logistic regression model</title>
      <link>/en/data-analysis/ml-predictive-analytics/classification-algorithms/logistic-regression/building-logistic-regression-model/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/data-analysis/ml-predictive-analytics/classification-algorithms/logistic-regression/building-logistic-regression-model/</guid>
      <description>
        
        
        &lt;p&gt;This logistic regression example uses a small data set named mtcars. The example shows how to build a model that predicts the value of &lt;code&gt;am&lt;/code&gt;, which indicates whether the car has an automatic or a manual transmission. It uses the given values of all the other features in the data set.&lt;/p&gt;
&lt;p&gt;In this example, roughly 60% of the data is used as training data to create a model. The remaining 40% is used as testing data against which you can test your logistic regression model.&lt;/p&gt;
Before you begin the example, &lt;a href=&#34;../../../../../en/data-analysis/ml-predictive-analytics/download-ml-example-data/&#34;&gt;load the Machine Learning sample data&lt;/a&gt;.
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Create the logistic regression model, named &lt;code&gt;logistic_reg_mtcars&lt;/code&gt;, using the &lt;code&gt;mtcars_train&lt;/code&gt; training data.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT LOGISTIC_REG(&amp;#39;logistic_reg_mtcars&amp;#39;, &amp;#39;mtcars_train&amp;#39;, &amp;#39;am&amp;#39;, &amp;#39;cyl, wt&amp;#39;
   USING PARAMETERS exclude_columns=&amp;#39;hp&amp;#39;);
        LOGISTIC_REG
----------------------------
 Finished in 15 iterations

(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;View the summary output of &lt;code&gt;logistic_reg_mtcars&lt;/code&gt;.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
=&amp;gt; SELECT GET_MODEL_SUMMARY(USING PARAMETERS model_name=&amp;#39;logistic_reg_mtcars&amp;#39;);
--------------------------------------------------------------------------------
=======
details
=======
predictor|coefficient|  std_err  |z_value |p_value
---------+-----------+-----------+--------+--------
Intercept| 262.39898 |44745.77338| 0.00586| 0.99532
cyl      | 16.75892  |5987.23236 | 0.00280| 0.99777
wt       |-119.92116 |17237.03154|-0.00696| 0.99445

==============
regularization
==============
type| lambda
----+--------
none| 1.00000

===========
call_string
===========
logistic_reg(&amp;#39;public.logistic_reg_mtcars&amp;#39;, &amp;#39;mtcars_train&amp;#39;, &amp;#39;&amp;#34;am&amp;#34;&amp;#39;, &amp;#39;cyl, wt&amp;#39;
USING PARAMETERS exclude_columns=&amp;#39;hp&amp;#39;, optimizer=&amp;#39;newton&amp;#39;, epsilon=1e-06,
max_iterations=100, regularization=&amp;#39;none&amp;#39;, lambda=1)


===============
Additional Info
===============
Name              |Value
------------------+-----
iteration_count   | 20
rejected_row_count|  0
accepted_row_count| 20
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create a table named &lt;code&gt;mtcars_predict_results&lt;/code&gt;. Populate this table with the prediction outputs you obtain from running the &lt;code&gt;PREDICT_LOGISTIC_REG&lt;/code&gt; function on your test data. View the results in the &lt;code&gt;mtcars_predict_results&lt;/code&gt; table.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE TABLE mtcars_predict_results AS
   (SELECT car_model, am, PREDICT_LOGISTIC_REG(cyl, wt
   USING PARAMETERS model_name=&amp;#39;logistic_reg_mtcars&amp;#39;)
   AS Prediction FROM mtcars_test);
CREATE TABLE


=&amp;gt; SELECT * FROM mtcars_predict_results;
   car_model    | am | Prediction
----------------+----+------------
 AMC Javelin    |  0 |          0
 Hornet 4 Drive |  0 |          0
 Maserati Bora  |  1 |          0
 Merc 280       |  0 |          0
 Merc 450SL     |  0 |          0
 Toyota Corona  |  0 |          1
 Volvo 142E     |  1 |          1
 Camaro Z28     |  0 |          0
 Datsun 710     |  1 |          1
 Honda Civic    |  1 |          1
 Porsche 914-2  |  1 |          1
 Valiant        |  0 |          0
(12 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Evaluate the accuracy of the &lt;code&gt;PREDICT_LOGISTIC_REG&lt;/code&gt; function, using the &lt;a href=&#34;../../../../../en/sql-reference/functions/ml-functions/model-evaluation/confusion-matrix/#&#34;&gt;CONFUSION_MATRIX&lt;/a&gt; evaluation function.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT CONFUSION_MATRIX(obs::int, pred::int USING PARAMETERS num_classes=2) OVER()
   FROM (SELECT am AS obs, Prediction AS pred FROM mtcars_predict_results) AS prediction_output;
 class | 0 | 1 |                   comment
-------+---+---+---------------------------------------------
     0 | 6 | 1 |
     1 | 1 | 4 | Of 12 rows, 12 were used and 0 were ignored
(2 rows)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In this case, &lt;code&gt;PREDICT_LOGISTIC_REG&lt;/code&gt; correctly predicted that four out of five cars with a value of &lt;code&gt;1&lt;/code&gt; in the &lt;code&gt;am&lt;/code&gt; column have a value of &lt;code&gt;1&lt;/code&gt;. Out of the seven cars which had a value of &lt;code&gt;0&lt;/code&gt; in the &lt;code&gt;am&lt;/code&gt; column, six were correctly predicted to have the value &lt;code&gt;0&lt;/code&gt;. One car was incorrectly classified as having the value &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;see-also&#34;&gt;See also&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/ml-functions/model-evaluation/confusion-matrix/#&#34;&gt;CONFUSION_MATRIX&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/ml-functions/model-evaluation/lift-table/#&#34;&gt;LIFT_TABLE&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/ml-functions/ml-algorithms/logistic-reg/#&#34;&gt;LOGISTIC_REG&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/ml-functions/transformation-functions/predict-logistic-reg/#&#34;&gt;PREDICT_LOGISTIC_REG&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;../../../../../en/sql-reference/functions/ml-functions/model-management/get-model-summary/#&#34;&gt;GET_MODEL_SUMMARY&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
  </channel>
</rss>
