diff --git a/svm.cpp b/svm.cpp new file mode 100644 index 0000000000..7372d669e2 --- /dev/null +++ b/svm.cpp @@ -0,0 +1,38 @@ +#include +#include +#include +using namespace std; + +// Basit bir linear SVM örneği (öğrenme yok, sadece mantık gösterimi) +class SVM +{ +public: + vector weights; + double bias; + + SVM() + { + weights = {0.5, -0.3}; + bias = 0.1; + } + + int predict(vector x) + { + double sum = bias; + for (int i = 0; i < x.size(); i++) + sum += x[i] * weights[i]; + return sum >= 0 ? 1 : -1; + } +}; + +int main() +{ + SVM model; + vector> data = {{1, 2}, {-1, -2}, {2, 3}, {-2, -3}}; + for (auto &x : data) + { + cout << "Prediction for (" << x[0] << ", " << x[1] << "): " + << model.predict(x) << endl; + } + return 0; +}