<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sairam manne</title>
    <description>The latest articles on DEV Community by Sairam manne (@mannesairam).</description>
    <link>https://dev.to/mannesairam</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3129218%2F62012de0-fad5-41e8-a53c-5bad533cc495.jpeg</url>
      <title>DEV Community: Sairam manne</title>
      <link>https://dev.to/mannesairam</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mannesairam"/>
    <language>en</language>
    <item>
      <title>[Boost]</title>
      <dc:creator>Sairam manne</dc:creator>
      <pubDate>Thu, 15 May 2025 13:55:43 +0000</pubDate>
      <link>https://dev.to/mannesairam/-2ffm</link>
      <guid>https://dev.to/mannesairam/-2ffm</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/mannesairam/statsmodels-library-an-overview-n0m" class="crayons-story__hidden-navigation-link"&gt;Statsmodels Library: An Overview&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/mannesairam" class="crayons-avatar  crayons-avatar--l  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3129218%2F62012de0-fad5-41e8-a53c-5bad533cc495.jpeg" alt="mannesairam profile" class="crayons-avatar__image"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/mannesairam" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Sairam manne
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Sairam manne
                
              
              &lt;div id="story-author-preview-content-2474033" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/mannesairam" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3129218%2F62012de0-fad5-41e8-a53c-5bad533cc495.jpeg" class="crayons-avatar__image" alt=""&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Sairam manne&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/mannesairam/statsmodels-library-an-overview-n0m" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;May 12 '25&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/mannesairam/statsmodels-library-an-overview-n0m" id="article-link-2474033"&gt;
          Statsmodels Library: An Overview
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/machinelearning"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;machinelearning&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/datascience"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;datascience&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/beginners"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;beginners&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/statsmodels"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;statsmodels&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/mannesairam/statsmodels-library-an-overview-n0m" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;1&lt;span class="hidden s:inline"&gt; reaction&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/mannesairam/statsmodels-library-an-overview-n0m#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              Comments


              &lt;span class="hidden s:inline"&gt;Add Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            5 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
      <category>machinelearning</category>
      <category>datascience</category>
      <category>beginners</category>
      <category>statsmodels</category>
    </item>
    <item>
      <title>Statsmodels Library: An Overview</title>
      <dc:creator>Sairam manne</dc:creator>
      <pubDate>Mon, 12 May 2025 16:28:08 +0000</pubDate>
      <link>https://dev.to/mannesairam/statsmodels-library-an-overview-n0m</link>
      <guid>https://dev.to/mannesairam/statsmodels-library-an-overview-n0m</guid>
      <description>&lt;h3&gt;
  
  
  Table of Contents
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Introduction&lt;/li&gt;
&lt;li&gt;History&lt;/li&gt;
&lt;li&gt;When to use&lt;/li&gt;
&lt;li&gt;Installation&lt;/li&gt;
&lt;li&gt;Features&lt;/li&gt;
&lt;li&gt;Ordinary least squares&lt;/li&gt;
&lt;li&gt;Statistical tests&lt;/li&gt;
&lt;li&gt;
Learning Resources &lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Python ecosystem is equipped with many tools and libraries which primarily focus on prediction or machine learning. &lt;br&gt;
For example, &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;scikit-learn&lt;/code&gt; focuses on predictive modeling and machine learning and  does not provide statistical summaries (like p-values, confidence intervals, R² adj.).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;SciPy.stats&lt;/code&gt;focuses on  Individual statistical tests and distributions but has no modeling framework (like OLS or GLM).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Other libraries like &lt;code&gt;linearmodels&lt;/code&gt; , &lt;code&gt;PyMC / Bambi&lt;/code&gt; , &lt;code&gt;Pingouin&lt;/code&gt; have their own limitations.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;Statsmodels&lt;/code&gt; was developed to fill the gap created by these existing tools.&lt;/p&gt;
&lt;h2&gt;
  
  
  History
&lt;/h2&gt;

&lt;p&gt;The development of &lt;code&gt;statsmodels&lt;/code&gt; began as an effort to bring robust statistical modeling capabilities to the Python ecosystem that, at the time, were largely dominated by R and MATLAB. While Python had gained popularity in data science due to its general-purpose programming strengths and libraries like &lt;code&gt;NumPy&lt;/code&gt;, &lt;code&gt;SciPy&lt;/code&gt;, and &lt;code&gt;pandas&lt;/code&gt;, it lacked a comprehensive library for classical statistical inference and econometric modeling.&lt;/p&gt;
&lt;h2&gt;
  
  
  When to use?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;use statsmodels library when  you need a detailed statistical output and tests.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;when the focus is on inference and interpretability and not on prediction.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;when working with time series or econometrics.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;By using Python's package manager pip you can easily install it. In your  terminal type the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install statsmodels

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Installing with conda:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;conda install -c conda-forge statsmodels

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For importing in google colab:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# loads the main API module of statsmodels which has datasets, statistical tests, time series models, statistical models (like OLS, GLM)
import statsmodels.api as sm

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Features
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Statistical models&lt;/u&gt;:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Linear Regression (OLS)&lt;/li&gt;
&lt;li&gt;Generalized Linear Models (logistic regression, poisson regression)&lt;/li&gt;
&lt;li&gt;Time series analysis&lt;/li&gt;
&lt;li&gt;Mixed Linear Models&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Statistical tests&lt;/u&gt;:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;T-tests&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ANOVA&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Chi-square tests&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cointegration tests&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Data Exploration&lt;/u&gt;:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Summary Statistics&lt;/li&gt;
&lt;li&gt;correlation analysis&lt;/li&gt;
&lt;li&gt;Multicollinearity analysis&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Model diagnostics and inference&lt;/u&gt;:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Confidence intervals&lt;/li&gt;
&lt;li&gt;p-value&lt;/li&gt;
&lt;li&gt;R - squared&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Ordinary least squares
&lt;/h2&gt;

&lt;p&gt;We will be performing ordinary least squares using this library.&lt;br&gt;
OLS is a statistical method in linear regression to estimate the relationship between a dependable variable and one or more independent variables.&lt;/p&gt;

&lt;p&gt;Ordinary Least Squares tries to minimize the sum of the squared differences, also called as residuals between the observed values and the values predicted by a linear model. &lt;/p&gt;

&lt;p&gt;OLS finds the best-fitting line that explains the relationship between the input variables and the output variable i.e X and Y.&lt;/p&gt;

&lt;p&gt;To perform OLS, we need to import a dataset. In our case, we will be using &lt;a href="https://www.kaggle.com/datasets/uciml/iris" rel="noopener noreferrer"&gt;iris dataset&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;The below code imports all the necessary libraries&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://pandas.pydata.org/docs/getting_started/index.html#getting-started" rel="noopener noreferrer"&gt;pandas&lt;/a&gt; - used for data manipulation and data analysis&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://numpy.org/doc/stable/user/absolute_beginners.html" rel="noopener noreferrer"&gt;numpy&lt;/a&gt; - used for numerical computations.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://scikit-learn.org/stable/" rel="noopener noreferrer"&gt;Sklearn&lt;/a&gt; library has few in-built datasets from which we will import iris dataset.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pandas as pd
import numpy as  np
import statsmodels.api as sm
from sklearn import datasets
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To perform operations on a dataset, we load it first&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iris = datasets.load_iris()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, &lt;code&gt;iris&lt;/code&gt; contains data in the form of an array and not a dataframe&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(iris.keys())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# output
dict_keys(['data', 'target', 'frame', 'target_names', 'DESCR', 'feature_names', 'filename', 'data_module'])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To convert the data into a pandas dataframe,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# independent variables
features = pd.DataFrame(iris.data,columns = iris.feature_names)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# dependent variable
target = pd.DataFrame(iris.target, columns= ['target'])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, the array like data is being converted into the pandas dataframe&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;features.sample(5)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzxeq428ei6qrb992hgd7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzxeq428ei6qrb992hgd7.png" alt="Preview of the dataset" width="800" height="258"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;target.sample(5)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa7hyx3sbj8oemgwy3gux.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa7hyx3sbj8oemgwy3gux.png" alt="Output of target variable" width="163" height="265"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, load independent variables into X and dependent variable to y to train the model.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;X = features
y = target
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Later by using the statsmodels library, we fit the model.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;model = sm.OLS(y,X).fit()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;prediction = model.predict(X)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(model.summary())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg11lvaj7msma2g5abn7a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg11lvaj7msma2g5abn7a.png" alt="output of the model" width="800" height="539"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above screenshot shows the detailed summary of the fitted model. This is highly useful for evaluating model's performance and assumptions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Statistical tests
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;em&gt;&lt;u&gt;Two-sample t-test (independent):&lt;/u&gt;&lt;/em&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;import the necessary libraries required to perform the task&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import statsmodels.stats.weightstats as smw
import numpy as np

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;create 2 variables which represent two independent groups using numpy library&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;group1 = np.array([2.9, 3.0, 2.5, 2.6, 3.2])
group2 = np.array([3.8, 2.7, 4.0, 2.4, 2.9])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;t_stat&lt;/code&gt;: This is the calculated t-statistic value. It measures how far apart the group &lt;em&gt;means&lt;/em&gt; are.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;p_value&lt;/code&gt;: This is used to determine the significance of the hypothesis test and is expressed between 0 &amp;amp; 1.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;small p-value (&amp;lt;=0.05) indicates strong proof against null &lt;br&gt;
hypothesis.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;large p-value (&amp;gt;0.05) indicates weak evidence against null hypothesis.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;df&lt;/code&gt;: Degrees of freedom used in the test. Influences the shape of the t-distribution.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;t_stat, p_value, df = smw.ttest_ind(group1, group2, usevar='pooled') 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print("t-statistic:", t_stat)
print("p-value:", p_value)
print("degrees of freedom:", df)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9q1oszcptu0pz1w9jjwz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9q1oszcptu0pz1w9jjwz.png" alt="output image" width="446" height="97"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;&lt;u&gt;one way anova:&lt;/u&gt;&lt;/em&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import statsmodels.api as sm
import statsmodels.formula.api as smf
import pandas as pd
from statsmodels.stats.anova import anova_lm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;data = {
    'score': [88, 90, 92, 85, 87, 89, 75, 78, 72],
    'method': ['A', 'A', 'A', 'B', 'B', 'B', 'C', 'C', 'C']
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;df = pd.DataFrame(data)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Fit OLS model with categorical predictor
model = smf.ols('score ~ C(method)', data=df).fit()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Perform ANOVA
anova_results = anova_lm(model, typ=2)  # Type II SS is standard
print(anova_results)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;&lt;u&gt;Chi-square test:&lt;/u&gt;&lt;/em&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pandas as pd
from scipy.stats import chi2_contingency
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;data = {
    'Method_A': [30, 10],  # [Pass, Fail]
    'Method_B': [25, 15],
    'Method_C': [20, 20]
}
df = pd.DataFrame(data, index=['Pass', 'Fail'])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chi2, p, dof, expected = chi2_contingency(df)

print("Chi-square statistic:", chi2)
print("p-value:", p)
print("Degrees of freedom:", dof)
print("Expected frequencies:\n", expected)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqgebeq1l6270720j8izo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqgebeq1l6270720j8izo.png" alt="result image" width="621" height="232"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Learning Resources
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.statsmodels.org/stable/index.html" rel="noopener noreferrer"&gt;Official Documentation&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.geeksforgeeks.org/statsmodels-library-tutorial/" rel="noopener noreferrer"&gt;GeeksforGeeks&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Hope this article helped you get started with &lt;code&gt;statsmodels&lt;/code&gt; and understand its key features. If you found it useful, feel free to share it with others who might benefit too. Keep exploring, experimenting, and happy learning!&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>datascience</category>
      <category>beginners</category>
      <category>statsmodels</category>
    </item>
  </channel>
</rss>
