|
O‘zbekiston respublikasi axborot texnologiyalari va
|
bet | 4/4 | Sana | 26.11.2023 | Hajmi | 0,74 Mb. | | #105655 |
Bog'liq Machine learning 2-amaliyLogistik 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;
}
|
| |