प्रेडिक्शंस की गणना और वर्णन

Python में Generalized Linear Models

Ita Cirovic Donev

Data Science Consultant

प्रेडिक्शंस की गणना

मॉडल फिट मिलने के बाद

  1. मूल $x$ मानों के लिए fitted values

मॉडल फिटिंग प्रक्रिया का आरेख.

Python में Generalized Linear Models

प्रेडिक्शंस की गणना

मॉडल फिट मिलने के बाद

  1. मूल $x$ मानों के लिए fitted values

  2. नए $x$ मानों के लिए predicted values

मॉडल फिटिंग और प्रेडिक्शन गणना की प्रक्रिया का आरेख.

Python में Generalized Linear Models

प्रेडिक्शंस की गणना

  • हॉर्सशू क्रैब मॉडल y ~ weight $$ \mu = \frac{\exp(-3.6947+1.8151 \times weight)}{1+\exp(-3.6947+1.8151 \times weight)} $$

  • नया मापन: weight = 2.85

$$ \mu = \frac{\exp(-3.6947+1.8151 \times \color{blue}{2.85})}{1+\exp(-3.6947+1.8151 \times \color{blue}{2.85})} = 0.814 $$

Python में Generalized Linear Models

Python में प्रेडिक्शंस

  • डेटासेट new_data के लिए मॉडल प्रेडिक्शंस निकालें
    # Compute model predictions
    model_GLM.predict(exog = new_data)
    
Python में Generalized Linear Models

Probabilities से classes तक

परिभाषित probability कटऑफ पर मॉडल आउटपुट का विभाजन.

Python में Generalized Linear Models

क्लास प्रेडिक्शंस की गणना

# मॉडल से fitted probabilities निकालें
crab['fitted'] = model.fittedvalues.values
# कट-ऑफ मान तय करें
cut_off = 0.4
# क्लास प्रेडिक्शंस निकालें
crab['pred_class'] = np.where(crab['fitted'] > cut_off, 1, 0)
Python में Generalized Linear Models

क्लास प्रेडिक्शंस की गणना

# हर क्लास के occurrences गिनें
crab['pred_class'].value_counts()
1    151
0     22
कट-ऑफ $\hat y=1$ $\hat y=0$
$\mu = 0.4$ 151 22
$\mu = 0.5$ 126 47
Python में Generalized Linear Models

Confusion matrix

खाली confusion matrix.

Python में Generalized Linear Models

Confusion matrix - True Negatives

Confusion matrix में true negatives का प्रदर्शन.

Python में Generalized Linear Models

Confusion matrix - True Positives

Confusion matrix में true negatives और true positives का प्रदर्शन.

Python में Generalized Linear Models

Confusion matrix - False Positives

Confusion matrix में true negatives, true positives और false positives का प्रदर्शन.

Python में Generalized Linear Models

Confusion matrix - False Negatives

Confusion matrix में true negatives, true positives, false positives और false negatives का प्रदर्शन.

Python में Generalized Linear Models

Python में confusion matrix

print(pd.crosstab(y_actual, y_predicted, 
            rownames=['Actual'], colnames=['Predicted'], 
            margins = True))
Predicted   0    1  All
Actual                 
0          15   47   62
1           7  104  111
All        22  151  173
Python में Generalized Linear Models

अभ्यास करते हैं!

Python में Generalized Linear Models

Preparing Video For Download...