O‘zbekiston respublikasi axborot texnologiyalari va




Download 0,74 Mb.
bet4/4
Sana26.11.2023
Hajmi0,74 Mb.
#105655
1   2   3   4
Bog'liq
Machine learning 2-amaliy

Logistik regressiya C++
#include
#include
#include
#include
#include
using namespace std;
int main() {
double x[100],y[100],y1[100],loss[100];
srand(time(0));
ofstream Logistik;
Logistik.open("Logistik_reg.csv");
for(int i=0;i<100;i++){
x[i]=rand()%10;
y[i]=rand()%10;
cout<<"\n x["< cout<<" y["< y1[i]=1/(1+exp(-y[i]));
cout<<" y1["< if(y[i]<=x[i]) {
cout<<" -> True "<<1;
}
else {
cout<<" -> False "<<0;
}
loss[i]=fabs((1-y[i])*log(1-y1[i])+y[i]*log(y1[i]));
} Logistik<<" Y1 "< for(int i=0;i<100;i++){
if(y1[i]<=0.5) y1[i]=0;
else y1[i]=1;
Logistik< } Logistik<<" Loss "< for(int i=0;i<100;i++){
Logistik< }

return 0;
}

Download 0,74 Mb.
1   2   3   4




Download 0,74 Mb.

Bosh sahifa
Aloqalar

    Bosh sahifa



O‘zbekiston respublikasi axborot texnologiyalari va

Download 0,74 Mb.