<?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: JashMehulShah</title>
    <description>The latest articles on DEV Community by JashMehulShah (@jashmehulshah).</description>
    <link>https://dev.to/jashmehulshah</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4126633%2F35d34706-ad40-4fe0-af20-d6dc25a1e9ca.png</url>
      <title>DEV Community: JashMehulShah</title>
      <link>https://dev.to/jashmehulshah</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jashmehulshah"/>
    <language>en</language>
    <item>
      <title>Building a Stock Market Predictor: What Worked and What I'd Change</title>
      <dc:creator>JashMehulShah</dc:creator>
      <pubDate>Tue, 15 Sep 2026 16:50:01 +0000</pubDate>
      <link>https://dev.to/jashmehulshah/building-a-stock-market-predictor-what-worked-and-what-id-change-3l7d</link>
      <guid>https://dev.to/jashmehulshah/building-a-stock-market-predictor-what-worked-and-what-id-change-3l7d</guid>
      <description>&lt;p&gt;When I started this project, I wanted to see how far I could get with a simple linear regression model trying to forecast stock closing prices — and turn that into a basic buy/sell signal. Here's what I learned.&lt;/p&gt;

&lt;p&gt;My Approach&lt;br&gt;
Data: Historical stock/index data pulled live via the yfinance API (Yahoo Finance)&lt;br&gt;
Model: Linear regression on historical price data — chosen deliberately as a baseline before reaching for anything more complex&lt;br&gt;
Output: Visualized price trends, predicted future closing prices, and a simple buy/sell recommendation derived from predicted movement&lt;br&gt;
Evaluation: Compared the model's predicted closing prices against actual prices to see how closely the trend line tracked reality, and checked whether the buy/sell signal would have pointed the right direction over the test period&lt;br&gt;
python&lt;br&gt;
`# Core idea: fit a linear regression on historical closing prices&lt;br&gt;
model = LinearRegression()&lt;br&gt;
model.fit(X_train, y_train)&lt;/p&gt;

&lt;h1&gt;
  
  
  Evaluate on held-out data
&lt;/h1&gt;

&lt;p&gt;test_predictions = model.predict(X_test)&lt;br&gt;
rmse = np.sqrt(mean_squared_error(y_test, test_predictions))&lt;br&gt;
Results`&lt;br&gt;
&lt;a href="https://dev.tourl"&gt;&lt;/a&gt;&lt;br&gt;
On a held-out test set (20% of the data, unseen during training), the model's RMSE was ~3,575 index points — against a BSE Sensex trading in the 50,000–85,000 range over this period, that's roughly a 4-5% average error. Not something you'd trade on, but a reasonable fit for a straight-line model.&lt;/p&gt;

&lt;p&gt;The more interesting finding came from the buy/sell logic: the model recommends BUY for every timeframe I tested — 10 days, 1 month, even 1 year out. At first that looked like a bug. It isn't — it's a direct consequence of the model. Since linear regression fits a single straight line to Days vs. Close, and the Sensex trended upward across my 2020-2025 training window, the fitted slope is positive. A positive slope can only ever project further up. The model is structurally incapable of recommending SELL unless the entire historical window it was trained on was trending downward. That's a real limitation, not noise — and a useful thing to have discovered by testing it rather than just trusting the output.&lt;/p&gt;

&lt;p&gt;Why This Matters to Me&lt;/p&gt;

&lt;p&gt;This project is the seed of something I want to take further — I'm interested in applying ML to finance more seriously, and this was a first, honest attempt at seeing where a simple model's limits are. Building it taught me more about the limits of ML on noisy real-world data than any tutorial did.&lt;/p&gt;

&lt;p&gt;Code for this project is on &lt;a href="https://github.com/JashMehulShah/stockmarketpredictionmodel/blob/main/main.py" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;``&lt;/p&gt;

</description>
      <category>api</category>
      <category>datascience</category>
      <category>machinelearning</category>
      <category>python</category>
    </item>
  </channel>
</rss>
